# How do I make GL draw a border on polygons?

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

## 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 on other sites
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 on other sites
Thanks, that seems to work good enough.

The function is glLineWidth(glFloat), by the way

##### 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 modeglPolygonMode(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 modeglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

##### 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.

• 10
• 17
• 9
• 13
• 41