Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenGL depth test problem

Started by Jesse Chounard May 1, 2001 at 3:30 PM 4 replies 8.9k views
Original Post
Jesse Chounard
Jesse Chounard
Hello, I''m having trouble with depth testing in OpenGL. When I have the depth func set to GL_EQUAL (or GL_LEQUAL or GL_GEQUAL) everything is drawn, as if no testing is happening. If I use GL_GREATER or GL_LESS, nothing is drawn. This leads me to believe that all of the Z-buffer calculations are the same. That doesn''t make any sense to me, though, because everything is appearing correctly on the screen, except for the far objects drawing over the near ones. Anybody ever seen this behaviour before? Lemme know if you need more info. Thanks for any help. Jesse
Andrea
Andrea
Have you glEnabled the depth test ?

With glDepthFunc() you define the depth function test but you must enable it with glEnable(GL_DEPTH_TEST);

The default OpenGL settings is NO depth test!
IpSeDiXiT
Freeky
Freeky
[quote name='Jesse Chounard' timestamp='988795117' post='1232306']
Thanks Anon. My nearplane was indeed set to zero. I changed it and now everything is rendering (or rather, not rendering) correctly.

Thanks a ton for the help.

Jesse
[/quote]
Thanks you verry much! I was not hard indeed. All I needed to do was typing one line of code and it's fixed now!
For everyone with the same problem, the code to enable depth test is:
[CODE]
glEnable(GL_DEPTH_TEST);
[/CODE]
Thanks again!







swiftcoder
swiftcoder
Moved to the OpenGL forum, where it belongs.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.