Jump to content
  • Advertisement
Sign in to follow this  

Polygon appearing as triangle [Solved]

This topic is 3089 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm making a 3d car driving demo for my graphics course, and I've hit a maddening bug when trying to draw a 2d interface over the top. Basically when I draw this:
start2D();
	textures.bindTexture(0,speedo);
	glBegin(GL_POLYGON);
		glTexCoord2i(0,0); glVertex2i(10,10);
		glTexCoord2i(0,1); glVertex2i(10,134);
		glTexCoord2i(1,0); glVertex2i(200,10);
		glTexCoord2i(1,1); glVertex2i(200,134);
	glEnd();
end2D();


it appears like this: The polygon becomes a triangle, ignoring the top left vertex. I might be missing something obvious, but any suggestions are welcome. [Edited by - dig412 on December 6, 2009 3:38:47 PM]

Share this post


Link to post
Share on other sites
Advertisement
It's called backface culling.
If you orient the triangle in clockwise (CW) order, the triangle won't be drawn (by default). Orient it counter-clockwise (CCW).

glBegin(GL_QUAD);
glTexCoord2i(0,0); glVertex2i(10,10);
glTexCoord2i(1,0); glVertex2i(200,10);
glTexCoord2i(1,1); glVertex2i(200,134);
glTexCoord2i(0,1); glVertex2i(10,134);
glEnd();


4<----3
^
CCW |
|
1---->2

Share this post


Link to post
Share on other sites
Damn, I knew it was going to be something obvious!
Thanks!

I thought both of them would be culled though, since they're specified in the same direction.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!