PDA

View Full Version : glEnable(GL_CULL_FACE) and glEnable(GL_DEPTH_TEST)



RoiiG
04-02-2010, 07:45 PM
Hello all!

When Have I to use glEnable(GL_CULL_FACE) and/or glEnable(GL_DEPTH_TEST) ?



Without none enabled I get:
http://img30.imageshack.us/img30/9897/badlight.th.png (http://img30.imageshack.us/i/badlight.png/)

With both enabled I get:
http://img144.imageshack.us/img144/6145/both.th.png (http://img144.imageshack.us/i/both.png/)

I'm asking this because, in my app, when I enable both, I get the same results that when I enable only GL_DEPTH_TEST.
So Can I disable GL_CULL_FACE without problems?

Thank you and sorry for my english!

ZbuffeR
04-03-2010, 03:08 AM
GL_CULL_FACE is to be enabled for performance reasons, as it easily removes half of the triangles to draw, normally without visual artifacts if your geometry is watertight, and CCW.
GL_DEPTH_TEST is to be enabled to avoid ugly artifacts that depend on the angle of view and drawing order (otherwise ie. if back of the cube is drawn last, if will appear "above" the front of the cube).
So yes, both should be enabled.

RoiiG
04-03-2010, 11:06 AM
Ok thank you Zbuffer!