Re: glPolygonOffset Needing Extreme Values
- From: "jbwest" <jbwest@xxxxxxxxxxx>
- Date: Thu, 15 Mar 2007 17:05:44 -0800
"Maik Wagner" <maik-wagner@xxxxxx> wrote in message
news:etbmic$igg$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
crjjrc wrote:
Hi. I'm trying to draw an outline around a polygonal model. Most
examples online do something like this:
draw wireframe model
offset depth by negative values
draw solid model
I tried this, but found some problems with some polygons in the solid
model appearing before closer polygons. This occurred near the edges
of the model, where I suppose the depth slope was high. I want the
solid model to appear normally, so I thought this would make more
sense:
draw solid model
offset depth by positive values
draw wireframe model
In this order, I don't need to worry about getting the parameters to
glPolygonOffset just right.
However, I'm having a really hard time getting those lines pushed back
far enough. If I call glPolygonOffset(10.0f, 10.0f), I get this
image:
http://www.cs.utk.edu/~cjohnson/forothers/teapot_low.png
The lines apparently aren't pushed back far enough, as you can see.
So, I c
all glPolygonOffset with the exorbitant parameters of 100000000.0f and
1000000000.0f, and I get:
http://www.cs.utk.edu/~cjohnson/forothers/teapot_high.png
This is what I want. But just several orders of magnitude less still
yields lines appearing before the solid model. This seems odd.
To make matters more confusing, when I draw the wireframe model, I
have to enable GL_POLYGON_OFFSET_FILL, though the polygon mode is
GL_LINE. (Using GL_POLYGON_OFFSET_LINE has no effect.) This seems to
contradict the red book's description of how glPolygonOffset works.
Here's the relevant code. The model is contained in a display list,
and just contains a call to glutSolidTeapot or a gluSphere.
glCallList(object_list + list_offset);
/* It doesn't make sense to me why polygon offset needs to be on
* for fill mode and not line, but this is the only way it works.
*/
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glPolygonOffset(100000000.0f, 1000000000.0f);
glLineWidth(6.0f);
glDisable(GL_LIGHTING);
glColor3fv(rgb);
glCallList(object_list + list_offset);
glLineWidth(1.0f);
glEnable(GL_LIGHTING);
glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
zNear and zFar are reasonably set to 0.1 and 200.0f. I think this is
reasonable, isn't it? If anyone can offer any explanation of why I
need to use OFFSET_FILL and why I need such large values to make a
difference, I'd appreciate it.
- Chris
Speaking in z-buffer precision, those aren't large values, and thats where
polygon-offset works. glPolygonOffset is normaly not used to move the
whole geometry in the z-buffer as you do, it should just avoid artifacts
where z-Buffer gets inprecise in differentiating 2 values.
The first way to go you mentioned is used to draw a solid model along with
its wireframe model. PolygonOffset is just used to make sure the wireframe
one is drawn correctly.
I am not aware of how outlines like you want are drawn normaly. But the
way you go, you also could draw 2 solid models, instead of the wireframe
model.
You are still drawing a polygon (glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);)
and not a line (glBegin(GL_LINES)).
jbw
.
- Follow-Ups:
- Re: glPolygonOffset Needing Extreme Values
- From: crjjrc
- Re: glPolygonOffset Needing Extreme Values
- References:
- glPolygonOffset Needing Extreme Values
- From: crjjrc
- Re: glPolygonOffset Needing Extreme Values
- From: Maik Wagner
- glPolygonOffset Needing Extreme Values
- Prev by Date: Antialiasing OpenGL in MFC?
- Next by Date: Re: Antialiasing OpenGL in MFC?
- Previous by thread: Re: glPolygonOffset Needing Extreme Values
- Next by thread: Re: glPolygonOffset Needing Extreme Values
- Index(es):
Relevant Pages
|