PDA

View Full Version : Problems with depth test and culling



dee.dw
09-29-2003, 11:21 AM
Hello!

I'm new to OpenGL and having some troubles. For programming I use Linux (Mandrake 9.1) with QT 3.2.1. I only want to use gl.h library, if it possible. http://www.opengl.org/discussion_boards/ubb/smile.gif
For beginning I buy a book „Jetzt lerne ich Open GL“ (It's in German, maybe someone knows it!) It's mainly written for MS Visual C++, but the OpenGL commands should work under Linux too.
I must say that I think I don't have any hardware support under linux because of lack of drivers fpr my ATI card. But I thought OpenGL can render all in software mode and so all commands can be used, or am I wrong here?

My biggest problem is the GL_DEPTH_TEST. If I enable it, my scene is empty. I've searched for this issue in this forum and found a lot of threads but none helped me really. I've also set glDepthFunc(GL_LESS).
Therefore I have some objects that are in front of the scene instead in the rear because I've defined them later in the code.

My second „problem“ is the culling. If I use the code from the examples in the book. They use glCullFace(GL_FRONT) and everything looks fine. If I use this my front-sides are missing. If I use glCullFace(GL_BACK) under Linux the scene looks right. Both times glFrontFace(CCW) is used.

I hope someone could help me. Until now I don't need anything of this in my later project. But I planned to have an animations scene and therefore I need the depth test.

Greetings from Germany,
Dee

09-29-2003, 11:26 AM
To answer the second part of your question, glCullFace() only draws either clockwise objects or counterclockwise objects. It leaves out the other and doesn't render it, to increase your FPS. You should either draw all your objects clockwise or counterclockwise, choose one. If you then use glCullFace(), it will only render the side that you can see, and the scene will run faster! I hope this answers your question.

dee.dw
09-30-2003, 09:16 AM
At first: Thanks for your help! I know the definition of the methods, but as you can see below they behave different in Windows and Linux.

I'm a little bit wiser now with the help of another german forum. The depth test does now working right!

But if you want to look at http://www.stud.uni-giessen.de/~su2754/opengl/ogl.htm

The three Pictures show the result in Windows and two in Linux. After repainting the window (e.g. resize, etc.) I loose all my shadows in Linux. Why?

And in Windows I set glFrontFace(GL_CCW) and flCullFace(GL_FRONT). But under Linux I get the wrong result as shown in the other pictures. Only with CCW and BACK it's shown right! Does Linux and Windows calculate this thing in different way?

At the top of the htm-file there are Zip-Files with the whole Projects for Linux and Windows, executables ("ausführbare") for those who won't compile it and the main cpp-files.

Maybe now someone can help me some more! http://www.opengl.org/discussion_boards/ubb/smile.gif

Greetings, Dee