Fix crash on MesaGL
parent
69a586903b
commit
9f625f07ae
|
@ -308,10 +308,7 @@ DocumentWindow::DocumentWindow() :
|
|||
m_modelRenderWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
m_modelRenderWidget->move(DocumentWindow::m_modelRenderWidgetInitialX, DocumentWindow::m_modelRenderWidgetInitialY);
|
||||
m_modelRenderWidget->setMousePickRadius(m_document->mousePickRadius());
|
||||
#ifndef __linux__
|
||||
// FIXME: Toggle wireframe crash on linux/MesaGL
|
||||
m_modelRenderWidget->toggleWireframe();
|
||||
#endif
|
||||
|
||||
connect(m_modelRenderWidget, &ModelWidget::mouseRayChanged, m_document,
|
||||
[=](const QVector3D &nearPosition, const QVector3D &farPosition) {
|
||||
|
|
|
@ -197,6 +197,19 @@ void ModelMeshBinder::paint(ModelShaderProgram *program)
|
|||
if (m_renderEdgeVertexCount > 0) {
|
||||
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoEdge);
|
||||
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
||||
// glDrawArrays GL_LINES crashs on Mesa GL
|
||||
static int s_softwareGlState = 0;
|
||||
if (0 == s_softwareGlState) {
|
||||
const char *versionString = (const char *)f->glGetString(GL_VERSION);
|
||||
if (nullptr != versionString &&
|
||||
'\0' != versionString[0] &&
|
||||
0 == strstr(versionString, "Mesa")) {
|
||||
s_softwareGlState = 2;
|
||||
} else {
|
||||
s_softwareGlState = 1;
|
||||
}
|
||||
}
|
||||
if (2 == s_softwareGlState) {
|
||||
program->setUniformValue(program->textureEnabledLoc(), 0);
|
||||
program->setUniformValue(program->normalMapEnabledLoc(), 0);
|
||||
program->setUniformValue(program->metalnessMapEnabledLoc(), 0);
|
||||
|
@ -205,6 +218,7 @@ void ModelMeshBinder::paint(ModelShaderProgram *program)
|
|||
f->glDrawArrays(GL_LINES, 0, m_renderEdgeVertexCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_renderTriangleVertexCount > 0) {
|
||||
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoTriangle);
|
||||
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
||||
|
|
Loading…
Reference in New Issue