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)
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
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.
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