How do I remove unseen faces?
Heya ppls, I''ve recently been building a new game, and it''s all looking quite impressive at the moment, HOWEVER, it runs quite slowly, and I am looking for ways to speed it up.
Can someone tell me how to remove backfaces ( unseen ones ), that aren''t needed to be drawn to the screen.
It''d be much appreciated.
Hope some of you guys can help me out here.
Thanx in advance
~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
What you could do, is use the plane equation to determine which side the camera is on, in relation to the polygon/face. For instance, find the plane equation of the polygon, & then substitute the camera''s position in for x,y & z. If the result is negative, then do this:
glEnable(GL_CULL_FACE) //Enable face culling
glCullFace(GL_FRONT) //Since you are behind the plane, clip the front
if the result is positive, then do this:
glEnable(GL_CULL_FACE) //Enable face culling
glCullFace(GL_BACK) //Since you are infront of the plane, clip the back
if the result is equal to zero, then do this:
glEnable(GL_CULL_FACE) //Enable face culling
glCullFace(GL_FRONT_AND_BACK) //Since you are sitting on the plane, clip the whole polygon.
-- wav
glEnable(GL_CULL_FACE) //Enable face culling
glCullFace(GL_FRONT) //Since you are behind the plane, clip the front
if the result is positive, then do this:
glEnable(GL_CULL_FACE) //Enable face culling
glCullFace(GL_BACK) //Since you are infront of the plane, clip the back
if the result is equal to zero, then do this:
glEnable(GL_CULL_FACE) //Enable face culling
glCullFace(GL_FRONT_AND_BACK) //Since you are sitting on the plane, clip the whole polygon.
-- wav
Thanx so much guys..... I never knew it was that simple! hehehe
15 seconds coding, and BAM! it runs smoother already! hehehe
Thanx again guys, I really appreciate it.
~Cobra~
15 seconds coding, and BAM! it runs smoother already! hehehe
Thanx again guys, I really appreciate it.
~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement