I draw a 3D shape with both fill mode and lines mode "wire frame", I get intersection between triangles and lines.
I enable the depth buffer before I renderGL.Enable(EnableCap.DepthTest);
, this is the code of drawing the model:
GL.BindVertexArray(VAO);
Vector4 color;
int colorLoc = GL.GetUniformLocation(programID, "color");
if (BorderThickness > 0)
{
color = new Vector4((float)BorderColor.R / 255, (float)BorderColor.G / 255, (float)BorderColor.B / 255, (float)BorderColor.A / 255);
GL.Uniform4(colorLoc, color.X, color.Y, color.Z, color.W);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
GL.LineWidth(BorderThickness);
GL.DrawArrays(PrimitiveType.LineStrip, 0, _positions.Count);
}
color = new Vector4((float)FillColor.R / 255, (float)FillColor.G / 255, (float)FillColor.B / 255, (float)FillColor.A / 255);
GL.Uniform4(colorLoc, color.X, color.Y, color.Z, color.W);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
GL.DrawArrays(PrimitiveType.Triangles, 0, _positions.Count);
GL.BindVertexArray(0);
I got the following result:
The result after adding glPolygonOffset
It fix the issue but the lines are not clear.