--- a/src/gl/compiler.cpp Wed Jan 22 01:17:11 2020 +0200 +++ b/src/gl/compiler.cpp Wed Jan 22 22:41:17 2020 +0200 @@ -36,7 +36,7 @@ void main() { vColor = color; - gl_Position = projection * modelview * CameraTransformation * vec4(position, 1.0); + gl_Position = CameraTransformation * vec4(position, 1.0); } )"; @@ -72,8 +72,22 @@ auto& object = this->glObjects[i]; object.program = new QOpenGLShaderProgram; object.program->create(); - object.program->addShaderFromSourceCode(QOpenGLShader::Vertex, ::vertexShaderSource); - object.program->addShaderFromSourceCode(QOpenGLShader::Fragment, ::fragmentShaderSource); + const bool vertexShaderCompiled = object.program->addShaderFromSourceCode(QOpenGLShader::Vertex, ::vertexShaderSource); + QString log; + if (not vertexShaderCompiled) + { + log += "\n" + tr("Vertex shader:") + "\n" + object.program->log(); + } + const bool fragmentShaderCompiled = object.program->addShaderFromSourceCode(QOpenGLShader::Fragment, ::fragmentShaderSource); + if (not fragmentShaderCompiled) + { + log += "\n" + tr("Fragment shader:") + "\n" + object.program->log(); + } + if (not vertexShaderCompiled or not fragmentShaderCompiled) + { + QMessageBox::critical(nullptr, tr("Shader compile error"), tr("Could not compile shaders.") + "\n" + log); + std::exit(-1); + } object.program->link(); object.program->bind(); object.buffer.create(); @@ -233,3 +247,25 @@ return static_cast<std::uint8_t>(vboAddress.vboClass) * gl::numVboSubclasses + static_cast<std::uint8_t>(vboAddress.vboSubclass); } + +QMatrix4x4 gl::toQMatrix(const glm::mat4& matrix) +{ + return { + matrix[0][0], + matrix[0][1], + matrix[0][2], + matrix[0][3], + matrix[1][0], + matrix[1][1], + matrix[1][2], + matrix[1][3], + matrix[2][0], + matrix[2][1], + matrix[2][2], + matrix[2][3], + matrix[3][0], + matrix[3][1], + matrix[3][2], + matrix[3][3], + }; +}