Problem drawing lines correctly in cube vertices


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?

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. You also have to glEnable the depth offset for lines (GL_POLYGON_OFFSET_LINE).

Something like this:

glPolygonOffset( -1.0f, -1.0f );