Advertisement Jump to content


This topic is now archived and is closed to further replies.



This topic is 6169 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have again a problem with a function (excuse but being french, I don''t always understand the red book GLfloat polyfactor = 1.0; GLfloat polyunits = 1.0; glEnable(GL_DEPTH_TEST); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(polyfactor, polyunits); // I don''t understand what for this function is //I don''t find it in MSDN glCallList (list); //displays a sphere glDisable(GL_POLYGON_OFFSET_FILL); // I don''t find GL_POLYGON_OFFSET_FILL in MSDN glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); glColor3f (1.0, 1.0, 1.0); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glCallList (list); //display a wire sphere glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); In fact, I don''t really know what this code does. It seems that it allowed us to display a solid sphere with a wire sphere aroud it.. Thanx

Share this post

Link to post
Share on other sites
mdsn is crap u wont find anything there thats more recent than 4 years.
polygonoffset gives the affected polygons a zbias eg if u draw 2 polygons in the same place + want the second one to be ''above slightly'' the first u will use polygonoffset. this is necessary when u do certain things that give different z values for a polygon eg say u draw a polygon + want to draw a clipped polygon (perhaps blended) in exactlyy the same place u would think the z values for the polygons will be the same? no they are not cause each polygon goes different calculations, thus to prevent z fighting use polygon offset

Share this post

Link to post
Share on other sites
I currently have a small terrain that I texture-layer 4 times, I use polyoffset to ensure proper drawing.

I don''t know all the mathematical details, but what I do is maintain a polyoffset value that starts at 0:


In my display routine I refer to the var in the command:


and I decrement by .1 after everytime I draw a layer:


Thus every layer gets an increasing negative value of offset. This seems to work, but don''t know if this is optimum. Looks good tho. I do this in a 3d world of +-1000 units, the values in the offset command are related somewhat to the world size, I had to try different values via key/slider adjustment to arrive at a satisfactory visual. The red book describes this in a bit of detail, but I just played with it.

zin - 3d graphics & more or less

Share this post

Link to post
Share on other sites
MSDN did has the explain about it...

"When GL_POLYGON_OFFSET is enabled, each fragment's depth value will be offset after it is interpolated from the depth values of the appropriate vertices. The value of the offset is factor * £Gz + r * units, where £Gz is a measurement of the change in depth relative to the screen area of the polygon, and r is the smallest value that is guaranteed to produce a resolvable offset for a given implementation. The offset is added before the depth test is performed and before the value is written into the depth buffer."

I know it is a litter offset on z values to let you
render coplanar polygons (like shadow etc) correctly.

But in fact I don't understand what msdn talking about it! :-(
(I mean 'exactly' ^^)

also see my another question at

p.s. also see "Z-bias" using in DX's help.

Edited by - Yann on February 26, 2002 9:24:08 PM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!