PDA

View Full Version : Problem drawing lines correctly in cube vertices



The_Notorious
01-16-2015, 07:04 AM
1594

I guess you can see what the problem is. The lines around the cubes that are side by side are not drawing correctly.
Is there any opengl function that can solve my problem?

Agent D
01-17-2015, 01:43 AM
If the lines use the same vertex positions as the cube triangles, you have a depth-fighting problem (your lines versus the triangles).

Try specifying a depht offset using glPolygonOffset (https://www.opengl.org/sdk/docs/man3/xhtml/glPolygonOffset.xml). You also have to glEnable the depth offset for lines (GL_POLYGON_OFFSET_LINE).

Something like this:


glEnable( GL_POLYGON_OFFSET_LINE );
glPolygonOffset( -1.0f, -1.0f );