Skip to main content
gamedev.net
🔒 Locked

single sided triangles

Started by SelethD 6 replies 650+ views
Original Post
SelethD
SelethD
This seems like its probably a very easy solution, but I just dont know enough about OpenGL to do it. When I draw a triangle, I can see it from both sides. I dont want this, since I will have solid objects and the back side will never be seen. What do I need to set or enable to only draw the 'front' of the triangle? thanks
Sneftel
Sneftel
look up glCullMode.
tychon
tychon
glEnable( GL_CULL_FACE ), I think it was. There's a way to set whether a face is defined by CW or CCW formation, but I can't remember it off hand.
Promit
Promit
glFrontFace would be the last part of the puzzle.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
SelethD
SelethD
ok, thanks ill experiment from here, :)
swiftcoder
swiftcoder
If you haven't reached it already,
glEnable(GL_CULL_FACE);glFrontFace(GL_CCW); // or GL_CW depending on whether you specify the vertices// of the triangle in counter-clockwise or clockwise order.

should do the trick ;)
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
SelethD
SelethD
Is it necessary to do this, I mean is there a performance gain in culling the back faces?
swiftcoder
swiftcoder
Quote:
Original post by SelethD
Is it necessary to do this, I mean is there a performance gain in culling the back faces?

Yes, there is. Basically it just cuts down on the number of primitives being sent down the graphics pipeline.
It is also often used to prevent graphical artifacts from appearing in various situations.
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.