1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Fix wireframe mode in opengl3 driver (#15626)

`GL_LINES` isn't suitable, because it makes lines between pairs of 2 vertices,
not loops around 3 vertices.
Support for OpenGL ES isn't simple, as it has no `glPolygonMode`. And showing broken
wireframe (i.e. with `GL_LINES`) would cause confusion.
This commit is contained in:
DS 2025-01-06 19:39:17 +01:00 committed by GitHub
parent f467bde6ac
commit 431c5c8b36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 9 deletions

View file

@ -1032,9 +1032,7 @@ void COpenGL3DriverBase::drawGeneric(const void *vertices, const void *indexList
GL.DrawElements(GL_TRIANGLE_FAN, primitiveCount + 2, indexSize, indexList);
break;
case scene::EPT_TRIANGLES:
GL.DrawElements((LastMaterial.Wireframe) ? GL_LINES : (LastMaterial.PointCloud) ? GL_POINTS
: GL_TRIANGLES,
primitiveCount * 3, indexSize, indexList);
GL.DrawElements(GL_TRIANGLES, primitiveCount * 3, indexSize, indexList);
break;
default:
break;
@ -1313,6 +1311,17 @@ void COpenGL3DriverBase::setBasicRenderStates(const SMaterial &material, const S
getGLBlend(srcAlphaFact), getGLBlend(dstAlphaFact));
}
// fillmode
if (Version.Spec != OpenGLSpec::ES && // not supported in gles
(resetAllRenderStates ||
lastmaterial.Wireframe != material.Wireframe ||
lastmaterial.PointCloud != material.PointCloud)) {
GL.PolygonMode(GL_FRONT_AND_BACK,
material.Wireframe ? GL_LINE :
material.PointCloud ? GL_POINT :
GL_FILL);
}
// Polygon Offset
if (resetAllRenderStates ||
lastmaterial.PolygonOffsetDepthBias != material.PolygonOffsetDepthBias ||