glPolygonOffset

Started by
3 comments, last by Allebarde 22 years, 1 month ago
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
Advertisement
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

http://uk.geocities.com/sloppyturds/gotterdammerung.html
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:

polyo=0;

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

glPolygonOffset(polyo,-1);

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

polyo-=.1;

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


zintel.com - 3d graphics & more or less
zintel.com - 3d graphics & more or less
Someone forgot that i''m french
I''m not sure to understand
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

http://www.gamedev.net/community/forums/topic.asp?topic_id=82368

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


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

This topic is closed to new replies.

Advertisement