Fix shader on win32

master
huxingyi 2020-03-20 17:11:48 +09:30
parent aa9b0b518b
commit 6fcb86a191
6 changed files with 24 additions and 23 deletions

View File

@ -1,6 +1,8 @@
Changes between 1.0.0-rc.1 and 1.0.0-rc.2: Changes between 1.0.0-rc.1 and 1.0.0-rc.3:
--------------------------------------------------
- Fix negative skinning weight - Fix negative skinning weight
- Fix IBL shader - Fix IBL shader
- Add win32 release
Changes between 1.0.0-beta.29 and 1.0.0-rc.1: Changes between 1.0.0-beta.29 and 1.0.0-rc.1:
-------------------------------------------------- --------------------------------------------------

View File

@ -66,10 +66,10 @@ macx {
} }
isEmpty(HUMAN_VERSION) { isEmpty(HUMAN_VERSION) {
HUMAN_VERSION = "1.0.0-rc.2" HUMAN_VERSION = "1.0.0-rc.3"
} }
isEmpty(VERSION) { isEmpty(VERSION) {
VERSION = 1.0.0.32 VERSION = 1.0.0.33
} }
HOMEPAGE_URL = "https://dust3d.org/" HOMEPAGE_URL = "https://dust3d.org/"

View File

@ -63,18 +63,6 @@ void ModelMeshBinder::enableEnvironmentLight()
void ModelMeshBinder::paint(ModelShaderProgram *program) void ModelMeshBinder::paint(ModelShaderProgram *program)
{ {
static int s_softwareGlState = 0;
if (0 == s_softwareGlState) {
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
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;
}
}
MeshLoader *newMesh = nullptr; MeshLoader *newMesh = nullptr;
bool hasNewMesh = false; bool hasNewMesh = false;
if (m_newMeshComing) { if (m_newMeshComing) {
@ -127,7 +115,6 @@ void ModelMeshBinder::paint(ModelShaderProgram *program)
m_environmentSpecularMap = nullptr; m_environmentSpecularMap = nullptr;
if (program->isCoreProfile() && if (program->isCoreProfile() &&
m_environmentLightEnabled && m_environmentLightEnabled &&
2 == s_softwareGlState &&
(m_hasMetalnessMap || m_hasRoughnessMap)) { (m_hasMetalnessMap || m_hasRoughnessMap)) {
DdsFileReader irradianceFile(":/resources/cedar_bridge_irradiance.dds"); DdsFileReader irradianceFile(":/resources/cedar_bridge_irradiance.dds");
m_environmentIrradianceMap = irradianceFile.createOpenGLTexture(); m_environmentIrradianceMap = irradianceFile.createOpenGLTexture();
@ -236,7 +223,7 @@ void ModelMeshBinder::paint(ModelShaderProgram *program)
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoEdge); QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoEdge);
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
// glDrawArrays GL_LINES crashs on Mesa GL // glDrawArrays GL_LINES crashs on Mesa GL
if (2 == s_softwareGlState) { if (program->isCoreProfile()) {
program->setUniformValue(program->textureEnabledLoc(), 0); program->setUniformValue(program->textureEnabledLoc(), 0);
program->setUniformValue(program->normalMapEnabledLoc(), 0); program->setUniformValue(program->normalMapEnabledLoc(), 0);
program->setUniformValue(program->metalnessMapEnabledLoc(), 0); program->setUniformValue(program->metalnessMapEnabledLoc(), 0);
@ -324,6 +311,10 @@ void ModelMeshBinder::cleanup()
m_normalMap = nullptr; m_normalMap = nullptr;
delete m_metalnessRoughnessAmbientOcclusionMap; delete m_metalnessRoughnessAmbientOcclusionMap;
m_metalnessRoughnessAmbientOcclusionMap = nullptr; m_metalnessRoughnessAmbientOcclusionMap = nullptr;
delete m_environmentIrradianceMap;
m_environmentIrradianceMap = nullptr;
delete m_environmentSpecularMap;
m_environmentSpecularMap = nullptr;
} }
void ModelMeshBinder::showWireframes() void ModelMeshBinder::showWireframes()

View File

@ -1,4 +1,3 @@
#include <QSurfaceFormat>
#include <QFile> #include <QFile>
#include <map> #include <map>
#include "modelshaderprogram.h" #include "modelshaderprogram.h"
@ -22,9 +21,9 @@ bool ModelShaderProgram::isCoreProfile()
return m_isCoreProfile; return m_isCoreProfile;
} }
ModelShaderProgram::ModelShaderProgram() ModelShaderProgram::ModelShaderProgram(bool isCoreProfile)
{ {
if (QSurfaceFormat::defaultFormat().profile() == QSurfaceFormat::CoreProfile) { if (isCoreProfile) {
this->addShaderFromSourceCode(QOpenGLShader::Vertex, loadShaderSource(":/shaders/default.core.vert")); this->addShaderFromSourceCode(QOpenGLShader::Vertex, loadShaderSource(":/shaders/default.core.vert"));
this->addShaderFromSourceCode(QOpenGLShader::Fragment, loadShaderSource(":/shaders/default.core.frag")); this->addShaderFromSourceCode(QOpenGLShader::Fragment, loadShaderSource(":/shaders/default.core.frag"));
m_isCoreProfile = true; m_isCoreProfile = true;

View File

@ -6,7 +6,7 @@
class ModelShaderProgram : public QOpenGLShaderProgram class ModelShaderProgram : public QOpenGLShaderProgram
{ {
public: public:
ModelShaderProgram(); ModelShaderProgram(bool isCoreProfile);
int projectionMatrixLoc(); int projectionMatrixLoc();
int modelMatrixLoc(); int modelMatrixLoc();
int normalMatrixLoc(); int normalMatrixLoc();

View File

@ -4,6 +4,7 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <math.h> #include <math.h>
#include <QVector4D> #include <QVector4D>
#include <QSurfaceFormat>
#include "modelwidget.h" #include "modelwidget.h"
#include "util.h" #include "util.h"
@ -123,7 +124,15 @@ void ModelWidget::initializeGL()
glClearColor(bgcolor.redF(), bgcolor.greenF(), bgcolor.blueF(), 1); glClearColor(bgcolor.redF(), bgcolor.greenF(), bgcolor.blueF(), 1);
} }
m_program = new ModelShaderProgram; bool isCoreProfile = false;
const char *versionString = (const char *)glGetString(GL_VERSION);
if (nullptr != versionString &&
'\0' != versionString[0] &&
0 == strstr(versionString, "Mesa")) {
isCoreProfile = QSurfaceFormat::defaultFormat().profile() == QSurfaceFormat::CoreProfile;
}
m_program = new ModelShaderProgram(isCoreProfile);
// Create a vertex array object. In OpenGL ES 2.0 and OpenGL 2.x // Create a vertex array object. In OpenGL ES 2.0 and OpenGL 2.x
// implementations this is optional and support may not be present // implementations this is optional and support may not be present