Draw polygon face and line in one line

Draw polygon face and line in one line

Post by Gunter Gemme » Sun, 19 Aug 2001 04:37:12



Hi,

I have a question concerning OpenGL. I would like to draw a polygon with a
specific color and a line around it. Is there a command to do this? If I use
glBegin(POLYGON), only the face is painted...

Thanks
    Gunter

 
 
 

Draw polygon face and line in one line

Post by Clemens Ladisc » Tue, 21 Aug 2001 16:50:24



> I have a question concerning OpenGL. I would like to draw a polygon with a
> specific color and a line around it.

You have to draw the interior and the outline seperately:

glPolygonMode(..., GL_FILL);
glColor(...);
draw_polygon...
glPolygonMode(..., GL_LINE);
glColor(...);
draw_polygon...

You could use glBegin(GL_LINE_LOOP) in place of glPolygonMode(..., GL_LINE)
as well.

If you use a z-buffer, there will be dropouts because the polygon and the
outline have similar depth values. In this case, enable polygon offset
somewhere in the rendering setup code:
    glPolygonOffset(1.0, 2);
    glEnable(GL_POLYGON_OFFSET_FILL);

HTH
Clemens