Using glDrawPixels and GL_DEPTH_COMPONENT

Started by
0 comments, last by d9930380 22 years, 9 months ago
I want to load a photographic background and depth information into the Color Buffer and the Depth Buffer however I seem to be having a problem with the depth buffer so I just tried the easiest thing I could test. int size = pDepth->GetWidth() * pDepth->GetHeight(); float* zBuffer = new float[size]; for( int i=0; i = 0.0f; // At The beginning glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); { glDrawPixels( pDepth->GetWidth(), pDepth->GetHeight(), GL_DEPTH_COMPONENT, GL_FLOAT, zBuffer ); } glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); delete[] zBuffer; glFlush(); Now when I draw an object with glDepthFunc( GL_LESS ); I shouldn''t see any objects, right ? Well I do, so can anyone help me out in finding a simple sample that does something similar. Oh, as these are "slow" commands. I have assumed that when I come to optimizing I can use glCopyPixels to blt between video memory requiring no conversion and no transfer over bus. Therefore being quick as the background and the depth info doesn''t change. Is this correct also? Thanks.
Advertisement
WTF

I finnaly sorted it out.

It appears you have to:

glEnable( GL_DEPTH_TEST );

before the call:

glDrawPixels( pDepth->GetWidth(),
pDepth->GetHeight(),
GL_DEPTH_COMPONENT,
GL_FLOAT,
zBuffer );

Why, and where is this written.

Arrrrgggghhhh :-)

This topic is closed to new replies.

Advertisement