From e84f37a518c44cb0a2c77005be2daf72b00e6f03 Mon Sep 17 00:00:00 2001 From: Jeremy HU Date: Sat, 24 Sep 2022 02:23:04 +1000 Subject: [PATCH] Mimic wireframe thickness --- application/sources/model_widget.cc | 8 ++++++++ application/sources/monochrome_opengl_vertex.h | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/application/sources/model_widget.cc b/application/sources/model_widget.cc index 04548336..5e8f7272 100644 --- a/application/sources/model_widget.cc +++ b/application/sources/model_widget.cc @@ -480,6 +480,14 @@ void ModelWidget::paintGL() #ifdef GL_LINE_SMOOTH f->glEnable(GL_LINE_SMOOTH); #endif + + // The built-in line width settings is not been well supported on all platforms, + // for example, the line range on 5.15.57.1-microsoft-standard-WSL2 is 1, + // that means the wireframe will not looking good, + // hence, we use the polygon offset to mimic thickness of wireframes + f->glEnable(GL_POLYGON_OFFSET_FILL); + f->glPolygonOffset(1.0, 1.0); + f->glViewport(0, 0, m_widthInPixels, m_heightInPixels); m_world.setToIdentity(); diff --git a/application/sources/monochrome_opengl_vertex.h b/application/sources/monochrome_opengl_vertex.h index 50ba04e2..3bd04367 100644 --- a/application/sources/monochrome_opengl_vertex.h +++ b/application/sources/monochrome_opengl_vertex.h @@ -10,9 +10,9 @@ typedef struct GLfloat posX; GLfloat posY; GLfloat posZ; - GLfloat colorR = 1.0; - GLfloat colorG = 1.0; - GLfloat colorB = 1.0; + GLfloat colorR = 0.0; + GLfloat colorG = 0.0; + GLfloat colorB = 0.0; GLfloat alpha = 1.0; } MonochromeOpenGLVertex; #pragma pack(pop)