View Full Version : Drawing Help lines
02-20-2012, 04:28 AM
As a beginner in OpenGL I am trying to plot a 3D solid model existing of a large number of Triangles. For debugging purposes I want smetimes to plot also the edges of the triangles. For that reason I plot also the lines between the point of each triangle but I only can see them whenever I disable plotting the triangles. I tried then in both cases:
First drawing the triangles and later the edges and the other way around. I flush only after I have drawn all (one time in a loop)
Can somebody tell me what I have to do.
02-20-2012, 03:57 PM
Depth test is causing this effect. Using polygon offset can help to some extent. Try enabling POLYGON_OFFSET_FILL before you draw filled triangles, and use glPolygonOffset(factor, units) with factor and units 1.0f, you can also experiment with other values.
This two pass polygon offset method however is not perfect. You can search internet for single pass wireframe shader to find out better techniques.
02-21-2012, 01:35 AM
The simple solution, as it is only for debugging, is to replace the draw call of GL_TRIANGLES with GL_LINE_STRIP. If you do the change dynamically, when the user presses a key, you can switch between one and the other efficiently.
Problem with this solution is that that GL_LINE_STRIP will draw some lines between triangles that are not connected. But it will probably look good.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.