Solving Z-Fighting in OpenGL 3 or 4
(I don't want to use deprecated code)
I have a wire frame polygon that forms a tube (made of four GL_TRIANGLE_STRIP) and I want to show its edges; not the interior wire frame lines though. When I add GL_LINES to show the edges, the mix with the polygon edges looks bad. I assume this is Z-Fighting?
This is my drawing command where the vector holds GL_TRIANGLE_STRIP (filled polygons) & GL_LINES (edge lines):
for(std::vector<batch_structure*>::iterator it = m_batch_structure_Vec.begin(); it!=m_batch_structure_Vec.end();it++)
glDrawArrays((*it)->primitiveType, 0, (*it)->nNumVerts);
GLenum primitiveType; // What am I drawing....
GLuint nNumVerts; // Number of verticies in this batch
I think glEdgeFlag is deprecated; plus it doesn't seem that it would work with glDrawArrays.
The SuperBible6th showed how to make two passes by drawing a filled polygon and then again draw a wire frame and used these lines of code which looks great; except I don't want to see the interior wire frame lines
// Draw black outline
glPolygonOffset(-1.0f, -1.0f); // Shift depth values
// Draw lines antialiased
// Draw black wireframe version of geometry
shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBlack);
How can I get clear edge lines to show up well on polygons.
Any help is appreciated.
That is exactly what I needed. Thank You!