Hi, not sure whether to post this in the beginnners or advanced forum so thought I would start here.
I am trying to display the z buffer as a texture in the upper right corner of the screen. The following code seems to always give me a pure white texture. I should be getting a texture that shows the rendered scene in grayscale, kind of. I have a geforce 3. Anyone know what I am doing wrong? Is there a rendering state I need to change before displaying the texture or is there something I need to do before copying the z buffer to a texture?
Render(); //renders lots of objects
//texture has already been setup as
//GL_DEPTH_COMPONENT
//like this
//glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, 256, 256, 0 );
glBindTexture( GL_TEXTURE_2D, iTexture );
glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256 );
glViewport( 640 - 256, 480 - 256, 256, 256 );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glDisable( GL_LIGHTING );
glDisable( GL_CULL_FACE );
glEnable( GL_TEXTURE_2D );
glBegin( GL_QUADS );
glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
glTexCoord2f( 0.0f, 0.0f );
glVertex2f( -1.0f, -1.0f );
glTexCoord2f( 1.0f, 0.0f );
glVertex2f( 1.0f, -1.0f );
glTexCoord2f( 1.0f, 1.0f );
glVertex2f( 1.0f, 1.0f );
glTexCoord2f( 0.0f, 1.0f );
glVertex2f( -1.0f, 1.0f );
glEnd();
KC