How do I make GL draw a border on polygons?
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.
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.
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.
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.
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);
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement