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....


|