c++ - Change the values of OpenGL's z-buffer -


i want pass matrix depth values z-buffer of opengl.somewhere found can use gldrawpixels(640,480,gl_depth_component,gl_float,normalizedmappeddepthmat.ptr());

where mat opencv mat.is possible change z-buffer values in opengl using texture binding?if so,how?

with programmable pipeline, can write gl_fragcoord in fragment shader, setting per-pixel z value. feature, can implement render-to-depth-buffer feature quite rendering full-screen quad (or else, if want overwrite sub-region of whole buffer). reasonably modern gl, able use single-channle texture formats enough precision gl_r32f. older gl versions, can manually combine rgb or rgba channels of standard 8bit textures 24 or 32 bit values.

however, there little details have take account. writing depth buffer occurs if gl_depth_test enabled. of course might discard of fragments (if depth-buffer not cleared before). 1 way around setting gldepthfunc() gl_always during depth-buffer rendering.

you must keep in mind rendering writes all buffers, not depth buffer. if don't want modify color buffer, can set gldrawbuffer() gl_none, or can use glcolormask() prevent overwriting it. if use stencil buffer, should disable or mask out writing it, of course.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -