Talk About Network

Google





Graphics > OpenGL 3D API > Depth Buffer to...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 4764 of 5061
Post > Topic >>

Depth Buffer to texture

by "Randall Wheeler" <rwgames68@[EMAIL PROTECTED] > May 23, 2008 at 07:38 PM

I need to get the depth buffer copied to a texture but it doesn't seem to
be 
working. Based on a lot of googling, I've tried both
(GL_TEXTURE_2D and GL_TEXTURE_RECTANGLE_ARB)
(GL_FLOAT and GL_UNSIGNED_BYTE)
 I'm using FBO for water reflection/refraction which works great but can't

get a depth texture from it or from the code below.




(width=height=1024   FBO disabled)

glGenTextures(1, &tex_depth);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB,tex_depth);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_DEPTH_COMPONENT16, width, 
height, 0, GL_DEPTH_COMPONENT, GL_FLOAT,NULL);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MAG_FILTER,
GL_LINEAR);



glView****t( 0, 0, width,height );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
gluLookAt(Camera->x, Camera->y, 
Camera->z,Camera->lx,Camera->ly,Camera->lz,0,1,0);

Terrain.DrawArray();

glBindTexture(GL_TEXTURE_RECTANGLE_ARB,tex_depth);
glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB,0,GL_DEPTH_COMPONENT16, 0,0, 
width,height, 0);



I'm pulling my hair out....
 




 3 Posts in Topic:
Depth Buffer to texture
"Randall Wheeler&quo  2008-05-23 19:38:47 
Re: Depth Buffer to texture
"Dave Eberly" &  2008-05-24 19:51:55 
Re: Depth Buffer to texture
"Randall Wheeler&quo  2008-05-27 20:38:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 17:02:22 PST 2009.