Why won't this display the front face of the triangle with lines.
Code:
glBegin(GL_TRIANGLES);
glPolygonMode(GL_FRONT, GL_LINE);
glVertex3f(-1.0f, -1.0f, -5.1f);
glVertex3f( 0.0f, 1.0f, -5.1f);
glVertex3f( 1.0f, -1.0f, -5.1f);
glEnd();
Printable View
Why won't this display the front face of the triangle with lines.
Code:
glBegin(GL_TRIANGLES);
glPolygonMode(GL_FRONT, GL_LINE);
glVertex3f(-1.0f, -1.0f, -5.1f);
glVertex3f( 0.0f, 1.0f, -5.1f);
glVertex3f( 1.0f, -1.0f, -5.1f);
glEnd();
I dropped that in place of the triangle create lines in one of my programs, and it drew a triangle just fine.
With just the lines? Not filled......I mean draw a triangle with lines.....not filled....Thanks btw
See I want the triangle to drawn ( at least the front part ) using not lines, not filled, I thought this was the function used to do this.
glPolygonMode(GL_FRONT, GL_LINE);
but it doesn't seem to work.
The default is to fill the region with color. To change the way polygons are drawn, you would use:
void glPolygonMode(GLenum face, GLenum mode);
The only thing i can think is that the mode is set to fill (default) still and is over-riding the command to draw in lines. I have never used the above method before, so you will have to look it up.
your front is actually your back.
it is actualy showing(logical back ) which is your front.
draw it counter clockwise and it will be ok.
you can't call glPolygonMode() in-between glBegin() and glEnd(). call it before.
EDIT, got it work people, apparently you have to call glEnable (GL_LINE_SMOOTH) for some reason.
Thanks no one it's working now.....hey people I am also having problems with this.......it won't smooth out the lines.
Code:
glPolygonMode(GL_BACK, GL_LINE);
glBegin(GL_TRIANGLES);
glEnable(GL_POLYGON_SMOOTH);
glVertex3f(-1.0f, -1.0f, -5.1f);
glVertex3f( 0.0f, 1.0f, -5.1f);
glVertex3f( 1.0f, -1.0f, -5.1f);
glEnd();
The book says something about lines of with (1.0) but I don't really understand what it's refering to.
glEnable() should not be called inbetween glBegin() and glEnd()