Fix wireframe mode in opengl3 driver ()

`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
2 changed files with 22 additions and 9 deletions
irr/src/OpenGL
src/client

@ -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 ||

@ -2256,16 +2256,20 @@ void Game::toggleDebug()
smgr->setGlobalDebugData(state == 4 ? bbox_debug_flag : 0,
state == 4 ? 0 : bbox_debug_flag);
if (state == 1)
if (state == 1) {
m_game_ui->showTranslatedStatusText("Debug info shown");
else if (state == 2)
} else if (state == 2) {
m_game_ui->showTranslatedStatusText("Profiler graph shown");
else if (state == 3)
m_game_ui->showTranslatedStatusText("Wireframe shown");
else if (state == 4)
} else if (state == 3) {
if (driver->getDriverType() == video::EDT_OGLES2)
m_game_ui->showTranslatedStatusText("Wireframe not supported by video driver");
else
m_game_ui->showTranslatedStatusText("Wireframe shown");
} else if (state == 4) {
m_game_ui->showTranslatedStatusText("Bounding boxes shown");
else
} else {
m_game_ui->showTranslatedStatusText("All debug info hidden");
}
}