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

Backface culling

Started by PH-Neutre May 5, 2000 at 5:36 AM 3 replies 1.3k views
Original Post
PH-Neutre
PH-Neutre
hi, what exactly is backface culling, and how to implemente it with OpenGL ? Thanks in advance, PH.
Ingenu
Ingenu
Backface culling is to suppress the backfaces polygons.
Backfacing polygons are pols that are not facing you, that''s the ones that you don''t need to render.

Imagine a plane.
It''s define by 2 quads, one for each face.
Do you really want to compute vertex lighting, mapping... on the side you don''t see ?
No, so you do backface culling.

OpenGL (as well as Direct3D) did it for you I think you must activate it (if it''s not the default value) with the glEnable() command.

Notice that OpenGL (and Direct3D) are doing backface 2D culling at the end of the process (just before displaying), you can save extra operations by doing 3D culling using surface normals before the projection as been computed.

In 3d gfx (like anywhere) you must suppress as much stuff as you can as soon as possible.

Hope it helps.

-* Sounds, music and story makes the difference between good and great games *-
-* So many things to do, so little time to spend. *-
Morgan
Morgan
The actual code to do this is:

glCullFace( GL_BACK );
glEnable( GL_CULL_FACE );

Remember that the vertices of your triangles, polygons, etc, must entered counter-clockwise for it to work correctly;

Morgan
PH-Neutre
PH-Neutre
Thanks a lot, Ingenu and Morgan !
It helps me a lot.

PH.
MadKeithV
MadKeithV
To clear up a little thing, you can actually set vertex order any way you want, and you can tell OpenGL which way will be forward.
You can set glCullFace( GL_FRONT ) , for example,
or use glFrontFace( GL_CCW ) or glFrontFace( GL_CW );

So basically, you can pick which way is forward if you want.

What morgan described is the default setting if you don''t change anything.


#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.

Topic Locked

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

Sign in to reply to this topic.