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