PDA

View Full Version : Depth Test Problem



glfreak
02-20-2008, 11:30 PM
Does GL_DEPTH_TEST state interact with texturing states by any means?

Here's the code I have trouble with.

void SetRenderStates()
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMultMatrixd(&m_quadProjMatd[0][0]);

//glDisable(GL_DEPTH_TEST);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glActiveTexture(GL_TEXTURE0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_RECTANGLE_ARB);
}

void DrawQuad()
{
glDisable(GL_DEPTH_TEST);

glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_tex);

glBegin(GL_QUADS);
.....
glEnd();

glEnable(GL_DEPTH_TEST);
}

void RestoreRenderStates()
{
glDisable(GL_TEXTURE_RECTANGLE_ARB);

glDisable(GL_BLEND);

//glEnable(GL_DEPTH_TEST);

glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}

main()
{
....
SetRenderStates();

for (...) {
Draw();
}

RestoreRenderStates();

}

Before Draw(), depth test should be disabled then enabled after rendering a set of quads.

It works when I switch depth test state within draw block, however when I add gl Enable/Disable depth test to the set/reset rendering functions, the textures appear missed up and somehow drifted and magnified....any reason?

Hardware ATI MobilityRadeon X1600.

Komat
02-21-2008, 01:48 AM
In the past I had problem with the texture rectangle textures on ATI cards. As I understand it, they do not support the unnormalized coordinates natively so the driver has to generate shader code to handle them. Sometimes the driver forgot to update the shader when different texture was bound resulting in something similiar to what you see. Setting some unrelated state (in my state the blending mode) caused it to notice that there was change and update the shader. It is possible that this is also the case.

glfreak
02-21-2008, 11:22 AM
Thanks. So it's ATI/AMD problem...I think I need to update the drivers since I still have the ones that come with Acer installed. I tried once to update and it did not allow me cause the hardware needed the "Acer" compatible drivers...I dunno how these guys work!!!

Jan
02-21-2008, 03:34 PM
Try this (http://www.driverheaven.net/modtool/). It's a tool that modifies ATI's inf-files, such that you can install the Catalyst drivers for desktop cards also on laptops. I use it, since my Asus laptop would otherwise also be stuck with some very old driver.

Jan.

Jan
02-21-2008, 03:37 PM
And by the way, i had NEVER any problems with the "unofficial" drivers, they work just fine. AFAIK it's a "political" decision, why ATI allows the drivers to be installed on some laptops and not on others. Some companies want more control over what gets installed on their products, so they ask ATI to not allow the monthly drivers to be installed on their laptops.

Jan.

glfreak
02-21-2008, 10:06 PM
ic...but to have buggy drivers as well

glfreak
02-23-2008, 01:54 AM
I updated the drivers, the same.

glfreak
02-23-2008, 02:04 AM
Besdies I tried the same logic with direct3D and it worked fine.

glfreak
02-24-2008, 06:19 PM
Now disabled depth test for everything, and got the same results, then set the DepthFunc to lequal and the same bad results...it seems rectangular texture deos not work when depth test is something different than less than unless they are put just before glBegin./End...weird

Brolingstanz
02-24-2008, 06:29 PM
try not using rectangular textures.