Mimic wireframe thickness

master
Jeremy HU 2022-09-24 02:23:04 +10:00
parent 61869d89dd
commit e84f37a518
2 changed files with 11 additions and 3 deletions

View File

@ -480,6 +480,14 @@ void ModelWidget::paintGL()
#ifdef GL_LINE_SMOOTH #ifdef GL_LINE_SMOOTH
f->glEnable(GL_LINE_SMOOTH); f->glEnable(GL_LINE_SMOOTH);
#endif #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); f->glViewport(0, 0, m_widthInPixels, m_heightInPixels);
m_world.setToIdentity(); m_world.setToIdentity();

View File

@ -10,9 +10,9 @@ typedef struct
GLfloat posX; GLfloat posX;
GLfloat posY; GLfloat posY;
GLfloat posZ; GLfloat posZ;
GLfloat colorR = 1.0; GLfloat colorR = 0.0;
GLfloat colorG = 1.0; GLfloat colorG = 0.0;
GLfloat colorB = 1.0; GLfloat colorB = 0.0;
GLfloat alpha = 1.0; GLfloat alpha = 1.0;
} MonochromeOpenGLVertex; } MonochromeOpenGLVertex;
#pragma pack(pop) #pragma pack(pop)