opengl - Precision of glReadPixels when reading unsigned int -
i having problems storing , retrieving 32 bit unsigned framebuffer. max value framebuffer on intel laptop (nvidia card , ubuntu) is:
4.294.967.295
however, max value can read, reason, only:
1.040.992.698
i wondering if can tell me if doing wrong or if limitation of graphics card.
i setting framebuffer this:
// generate render , frame buffer objects glgenrenderbuffers( 1, &colorbufid ); glgenrenderbuffers( 1, &depthbufid ); glgenframebuffers ( 1, &framebufid ); // setup renderbuffer glbindrenderbuffer(gl_renderbuffer, colorbufid); glrenderbufferstorage(gl_renderbuffer, gl_r32ui, _viewwidth, _viewheight); // setup depth buffer glbindrenderbuffer(gl_renderbuffer, depthbufid); glrenderbufferstorage(gl_renderbuffer, gl_depth_component32, _viewwidth, _viewheight); // setup framebuffer glbindframebuffer( gl_framebuffer, framebufid ); glframebufferrenderbuffer( gl_framebuffer, gl_color_attachment0, gl_renderbuffer, colorbufid ); glframebufferrenderbuffer( gl_framebuffer, gl_depth_attachment, gl_renderbuffer, depthbufid ); // check if went glenum stat = glcheckframebufferstatus(gl_framebuffer); if(stat != gl_framebuffer_complete) { printf("stat=%d != %d\n", stat, gl_framebuffer_complete); error(); exit(0); } // define framebuffer outputs written const glenum bufs[] = { gl_none, gl_color_attachment0 }; gldrawbuffers(2, bufs);
now when try read pixel
const uint32_t max_uint = std::numeric_limits< uint32_t >::max(); glclearbufferuiv(gl_renderbuffer, colorbufid, &max_uint); glclear( gl_color_buffer_bit | gl_depth_buffer_bit | gl_stencil_buffer_bit ); uint32_t pix_value=0; glreadpixels(0, 0, 1, 1, gl_red_integer, gl_unsigned_int, &pix_value);
the value of pix_value = 1.040.992.698.
i have tried use 'gl_red' instead of 'gl_red_integer' still not work.
(for interested, reason i'm trying above picking objects)
edit: in end had nothing precision. not clearing buffer correctly. se answer below
ok found error:
this correct command clear buffer:
glclearbufferuiv(gl_color, colorbufid, &undef_idx); glclear( /*gl_color_buffer_bit |*/ gl_depth_buffer_bit | gl_stencil_buffer_bit );
Comments
Post a Comment