Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Problems with polygonoffset

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

Hi, I'm new to opengl. I've got the problem, that I want to draw serveral different cubes. I draw the cubes and the edges, so I can watch the edges or the surfaces or both. Some sample code: --------------------------------------------------------------------- ... double orgFactor; double orgUnits; glGetDoublev(GL_POLYGON_OFFSET_FACTOR,&orgFactor); glGetDoublev(GL_POLYGON_OFFSET_UNITS,&orgUnits); ... glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(orgFactor, orgUnits); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); ... glBegin(GL_QUADS); ... glEND(); ... glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(orgFactor, orgUnits); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); ... glBegin(GL_QUADS); ... glEnd(); ... --------------------------------------------------------------------- So my problem is as follows. I cannot be sure, if two cubes have coplanar sides. So there will be some zfighting. I thought I could solve the problem by using polygonoffset (by the way, do I have to use glEnable(GL_DEPTH_TEST); when using polygonoffset???). Example: 1. create new cube (a) 2. create new cube (b) 3. a and b have coplanar backsides (a contains b) 4. using positiv orgFactor and orgUnits shows me the parts of a which are not inside b. 5. create new cube (c) 6. b and c have coplnar frontsides (b contains c) 7. using positiv orgFactor and orgUnits does not show me c. All I get is some zfighting. I see some of the surfaces of c. 8. create new cube (d) 9. delete cube b 10. d has the same size as b 11. in my renderroutine the cubes will be rendered a,c,d 12. now I get the result I want. Seeing the sides of a and c. 13. problem: I cannot be sure in which order the cubes will be added and which sizes they will have. It's up to the user to determine such things. Anyone got an idea how I can solve this problem? Some idea at least which deals with opengl. If opengl cannot deal with such things any hint to it will be appreciated. Thanks in advance...

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.

GameDev.net 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!