PDA

View Full Version : Texturing and depth testing



yaro_dup1
01-16-2003, 12:49 PM
Hi,

I have a problem with texture mapping and depht testing.
When I render a few polygons with mapped textures and each of them is on another Z position. I always see the polygon which has the smallest Z value doesn't matter where is camera positioned in the scene. So that's why I set glEnable(GL_DEPTH_DEST) but then polygons are "crashing" when for example I make a scene rotation. Is there any way to fix it without depht testing?

mdog1234
01-16-2003, 01:08 PM
did you remember to do a
glClear(GL_DEPTH_BUFFER_BIT);

also if you are using glut you might want to put this in your code as well
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); The GLUT_DEPTH is the new part. the other parts are up to do depending on your needs.

yaro_dup1
01-17-2003, 01:38 AM
Yes. I have the line:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

now i'm searching for some mistake in my program, i've got NeHe's tutorial and if I render the polygons there all is OK!
I have to work a little so I will find the problem!

I don't use GLUT.

thanks anyway

yaro_dup1
01-17-2003, 02:48 AM
I did find the error!
It was in gluPerspective - zNear = 0
One small mistake, i changed zNear when I experimented with fonts. This error crashes all of polygons... wondering.

yaro