Skip to content

Commit

Permalink
fix(OpenGL/Framebuffer): size can be null
Browse files Browse the repository at this point in the history
  • Loading branch information
floryst committed Feb 23, 2024
1 parent b998863 commit ae23115
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
8 changes: 2 additions & 6 deletions Sources/Rendering/OpenGL/Framebuffer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,8 @@ function vtkFramebuffer(publicAPI, model) {
};

publicAPI.getSize = () => {
const size = [0, 0];
if (model.glFramebuffer !== null) {
size[0] = model.glFramebuffer.width;
size[1] = model.glFramebuffer.height;
}
return size;
if (model.glFramebuffer == null) return null;
return [model.glFramebuffer.width, model.glFramebuffer.height];
};

publicAPI.populateFramebuffer = () => {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Rendering/OpenGL/HardwareSelector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
model.framebuffer.setOpenGLRenderWindow(model._openGLRenderWindow);
model.framebuffer.saveCurrentBindingsAndBuffers();
const fbSize = model.framebuffer.getSize();
if (fbSize[0] !== size[0] || fbSize[1] !== size[1]) {
if (!fbSize || fbSize[0] !== size[0] || fbSize[1] !== size[1]) {
model.framebuffer.create(size[0], size[1]);
// this calls model.framebuffer.bind()
model.framebuffer.populateFramebuffer();
Expand Down
6 changes: 2 additions & 4 deletions Sources/Rendering/OpenGL/RenderWindow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,8 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
};

publicAPI.getFramebufferSize = () => {
if (model.activeFramebuffer) {
return model.activeFramebuffer.getSize();
}
return model.size;
const fbSize = model.activeFramebuffer?.getSize();
return fbSize || model.size;
};

publicAPI.getPixelData = (x1, y1, x2, y2) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ function vtkLineIntegralConvolution2D(publicAPI, model) {
const gl = model.context;

let fb = model.framebuffer;
if (!fb || size[0] !== fb.getSize()[0] || size[1] !== fb.getSize()[1]) {
const fbSize = fb.getSize();
if (!fb || !fbSize || size[0] !== fbSize || size[1] !== fbSize) {
fb = vtkFrameBuffer.newInstance();
fb.setOpenGLRenderWindow(model._openGLRenderWindow);
fb.saveCurrentBindingsAndBuffers();
Expand Down
2 changes: 1 addition & 1 deletion Sources/Rendering/OpenGL/VolumeMapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
model.framebuffer.populateFramebuffer();
} else {
const fbSize = model.framebuffer.getSize();
if (fbSize[0] !== size[0] || fbSize[1] !== size[1]) {
if (!fbSize || fbSize[0] !== size[0] || fbSize[1] !== size[1]) {
model.framebuffer.create(size[0], size[1]);
model.framebuffer.populateFramebuffer();
}
Expand Down

0 comments on commit ae23115

Please sign in to comment.