PDA

View Full Version : Depth_buffer



12-21-2001, 12:00 PM
I would like to use the DepthBuffer. I used this command to enable it:
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST );
and in the main loop:
glClear(GL_DEPTH_BUFFER_BIT);

but it doesn't work and I would like to know why(I still see the rectangle that should be in the back in the front)? can someone help me?
Thanx (sorry for my English...I'm Italian)

Jambolo
12-21-2001, 12:53 PM
Looks ok to me. I normally use the default GL_LESS.

Maybe you are calling glDepthMask(GL_FALSE)?

jacobmarner
12-21-2001, 01:04 PM
Or maybe you are looking in the opposite direction of what you think. Remember that the camera looks towards the negative z-axis so z=-1 is closer than z=-2

12-22-2001, 10:24 AM
the same programm made under Visual C++ works...but with C++ (normal) it doesn't.

Bob
12-23-2001, 02:51 AM
Ehm, can you explain that one a bit more please. You say it works with Visual C++, but not with normal C++?

Thing is, Visual C++ IS normal C++. The Visual part is just the name of Microsofts "normal" C++ compiler.

12-23-2001, 04:19 AM
you're right...what I wanted to say is that the programm I made starting from zero, where I included only windows.h, gl.h and glu.h (where I copied the "open a window" part), it's seems that it doesn't use the detph buffer, even if I tell him to use it (with enable(DEPTH_BUFFER....bla...bla));while with a programm that start with all the classes already done (MFC) the openGL seem to use the depth buffer normally.

Bob
12-24-2001, 03:58 AM
Do you even ask for a depth buffer when creating the pixel format? If you don't ask for a depth buffer, you can't say for sure you will get one.

12-24-2001, 08:37 AM
I found it! It' was my stupidity!...It's was glperspective(angle,aspect,near,far)...near and far should be positive...and I put 0.0 as value for near. I'm really sorry for stealing your time for such a stupid thing. Thax