Jump to content
  • Advertisement
Sign in to follow this  
thames

OpenGL GlPolygonOffset whats the deal here? is it good or bad?

This topic is 4773 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

I am trying to draw lots of filled polygons with primitives ontop. I understand the opengl glpolygonoffset only works on filled polygons, but is this the only way to stop them from interferring?? surely there is a better way? Please help!!! Tom

Share this post


Link to post
Share on other sites
Advertisement
The "better way" would be not to draw multiple polygons in the same location, any good reason why you can't simply avoid it?

The alternative to glPolygonOffset would be to do the decal math by hand.

Share this post


Link to post
Share on other sites
Could you explain what you're trying to do in a little more detail?

The polygons need not be filled to use PolygonOffset.
you can use any of the following enums:

GL_POLYGON_OFFSET_FILL
GL_POLYGON_OFFSET_LINE
GL_POLYGON_OFFSET_POINT

Share this post


Link to post
Share on other sites
Hi --

There are some performance reasons not to use glPolygonOffset. Since the polygon slope is factored into the actual distance that fragments are moved forward or backward in the z-buffer, fragments inside very steeply sloped (with respect to the camera) polygons can end up having a z value anywhere in the entire depth range. For this reason, hardware hierarchical z-culling algorithms have to be disabled or severely limited for regions in which polygons are rendered with glPolygonOffset turned on.

An alternative is to modify your projection matrix to perform a z-offset. You can read about this technique in Game Programming Gems 1, Section 4.1, or in Mathematics for 3D Game Programming and Computer Graphics, Section 9.1. Source code can be found here:

http://www.terathon.com/books/code/Listing9.1.txt

Share this post


Link to post
Share on other sites
thank you very much, i actually own this book and will have a look next time i am at home.

Much appreciated

Tom

Share this post


Link to post
Share on other sites
Quote:
An alternative is to modify your projection matrix to perform a z-offset.
What a neat idea. Thanks for the link too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!