How do I make GL draw a border on polygons?

Started by
3 comments, last by Promit 18 years, 8 months ago
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.
"ok, pac man is an old gameand, there are faces which is eatin up shits" - da madface
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.
Thanks, that seems to work good enough.

The function is glLineWidth(glFloat), by the way
"ok, pac man is an old gameand, there are faces which is eatin up shits" - da madface
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);

do unto others... and then run like hell.
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.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement