glPolygonOffset Needing Extreme Values
- From: "crjjrc" <crjjrc@xxxxxxxxx>
- Date: 15 Mar 2007 07:06:03 -0700
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
.
- Follow-Ups:
- Re: glPolygonOffset Needing Extreme Values
- From: Maik Wagner
- Re: glPolygonOffset Needing Extreme Values
- Prev by Date: Re: TexGen
- Next by Date: Re: glPolygonOffset Needing Extreme Values
- Previous by thread: OpenGL extensions in Linux (It's not hard?)
- Next by thread: Re: glPolygonOffset Needing Extreme Values
- Index(es):
Relevant Pages
|