Jump to content
  • Advertisement
Sign in to follow this  
Foobar of Integers

How do I make GL draw a border on polygons?

This topic is 4887 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 simple game, etc, etc. Anyway, I need to have borders drawn on my individual polygons (in this case GL_TRIANGLES) because without a black or white border, the models will just look like little blobs of color.I haven't quite moved onto textures yet, and the only other solution is to draw everything in wireframe, which I don't mind, but I'd rather just have polygons with edges, or some other way to make it easy to distinguish between individual GL_TRIANGLES.

Share this post


Link to post
Share on other sites
Advertisement
For each polygon use GL_LINE_LOOP, just send each point out.

glBegin(GL_LINE_LOOP);
glVertex3f ( x1, y1, z1);
glVertex3f ( x2, y2, z2);
glVertex3f ( x3, y3, z3);
glEnd();

You'll need to look up how to change the line weight. Cant remember off the top of my head.

Share this post


Link to post
Share on other sites
Remember there is also glPolygonMode. This allows you to submit your geometry exactly as usual (without changing the primitive type) and it will draw in wireframe.

eg.

// set to draw in wireframe mode
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glBegin(GL_TRIANGLES);
glVertex3f(x1,y1,z1);
glVertex3f(x2,y2,z2);
glVertex3f(x3,y3,z3);
glEnd();

// change it back from wireframe mode
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);


Share this post


Link to post
Share on other sites
I've had severe performance problems drawing geometry in wireframe mode under nVidia cards. I try to use it for debugging purposes only. You might want to be wary of using PolygonMode like that.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!