Skip to content

Commit dd835a5

Browse files
committed
fix float framebuffer being read in the wrong format
1 parent 63b260a commit dd835a5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

devices/gl/src/VisGLFrameObject.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,11 @@ void frame_allocate_objects(ObjectRef<Frame> frameObj)
248248
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, frameObj->fbo);
249249
gl.BindBuffer(GL_PIXEL_PACK_BUFFER, frameObj->colorbuffer);
250250
gl.ReadBuffer(GL_COLOR_ATTACHMENT0);
251-
gl.ReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
251+
if(frameObj->colorType == ANARI_FLOAT32_VEC4) {
252+
gl.ReadPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, 0);
253+
} else {
254+
gl.ReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
255+
}
252256

253257
if (frameObj->sceneubo == 0) {
254258
gl.GenBuffers(1, &frameObj->sceneubo);
@@ -910,7 +914,11 @@ void frame_render(ObjectRef<Frame> frameObj,
910914

911915
gl.BindBuffer(GL_PIXEL_PACK_BUFFER, frameObj->colorbuffer);
912916
gl.ReadBuffer(GL_COLOR_ATTACHMENT0);
913-
gl.ReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
917+
if(frameObj->colorType == ANARI_FLOAT32_VEC4) {
918+
gl.ReadPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, 0);
919+
} else {
920+
gl.ReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
921+
}
914922

915923
if (gl.VERSION_3_3) {
916924
gl.EndQuery(GL_TIME_ELAPSED);

0 commit comments

Comments
 (0)