newname
September 10, 2002, 6:04pm
1
Hi, I cann’t get depth buffer correctly. The result was always something like: -4294967296.00.
I use the codes like:
GLfloat * depthResults = new GLfloat[winWidth * winHeight];
memset(depthResults,0,winWidth*winHeight*sizeof(GLfloat));///added 020907
glReadPixels(0, 0, winWidth, winHeight, GL_DEPTH_COMPONENT, GL_FLOAT, depthResults);
long count=0;
for(int y = 0; y < winHeight; y++)
for(int x = 0; x < winWidth; x++)
{
GLfloat wzz=depthResults[winWidth * y + x];
if(wzz>1.0| |wzz<0.0)
continue; //error!
count++;
}
Any problems in it?
dawn
September 10, 2002, 11:53pm
2
Check for the exact window dimensions, because if winHeight or winWidth are larger than the real size of the gl window, the result of ReadPixels will be undefined (and that value of yours seems like that).
newname
September 11, 2002, 3:51am
3
I tried to use a small window, but the results were the same.
if I added two lines:
glPixelTransferf(GL_DEPTH_SCALE, 0.8f);
glPixelTransferf(GL_DEPTH_BIAS, 0.1f);
the results were always 0.00.
dawn
September 11, 2002, 4:18am
4
try to read only one component:
float value;
glReadPixels(10, 10, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &value);
and also check if you are running using hw acc.
newname
September 11, 2002, 5:21am
5
what’s “hw acc”?
When I run it in Win98, it sometimes seems correct. But in Win2k, it never succeeded.
hw acc == short_of(hardware acceleration)
newname
September 11, 2002, 11:26pm
7
How to check if I’m using the hardware acceleration.
Originally posted by davepermen:
hw acc == short_of(hardware acceleration)