PDA

View Full Version : polygon draw



ccouto
01-31-2012, 09:00 AM
Hello

I want to draw a polygon that has a line color and a different fill color, which is the best way to do this?

I was trying to use:
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
to draw the polygon fill color and then call
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
to draw its countour lines.

When I do this, if i have two consecutive polygons drawn this way the render scene sometimes doesn't display the contour line between them...

Thanks in advance

AllForum
02-01-2012, 04:01 AM
Hello,

I understand that sometimes you don't see the edge lines.
Do you call glPolygonOffset before drawing lines ? glPolygonOffset enables to draw the lines in front of the polygon face.

NB: I am a beginner. I am here to ask questions, not to contribute... Warning ! ;)

ccouto
02-01-2012, 04:21 AM
Hi!

Thank you. In fact I found the answer and it is related with what you said.

I have to draw the polygons twice.

First time to draw the inside color i call:


glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

Second time i need to call:

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
glEnable(GL_POLYGON_OFFSET_LINE)
glPolygonOffset(-1, -1)

This way it works just as i was expecting.

:)