70 for (int i = 0; i < gl::NUM_ARRAY_CLASSES; i += 1) |
70 for (int i = 0; i < gl::NUM_ARRAY_CLASSES; i += 1) |
71 { |
71 { |
72 auto& object = this->glObjects[i]; |
72 auto& object = this->glObjects[i]; |
73 object.program = new QOpenGLShaderProgram; |
73 object.program = new QOpenGLShaderProgram; |
74 object.program->create(); |
74 object.program->create(); |
75 object.program->addShaderFromSourceCode(QOpenGLShader::Vertex, ::vertexShaderSource); |
75 const bool vertexShaderCompiled = object.program->addShaderFromSourceCode(QOpenGLShader::Vertex, ::vertexShaderSource); |
76 object.program->addShaderFromSourceCode(QOpenGLShader::Fragment, ::fragmentShaderSource); |
76 QString log; |
|
77 if (not vertexShaderCompiled) |
|
78 { |
|
79 log += "\n" + tr("Vertex shader:") + "\n" + object.program->log(); |
|
80 } |
|
81 const bool fragmentShaderCompiled = object.program->addShaderFromSourceCode(QOpenGLShader::Fragment, ::fragmentShaderSource); |
|
82 if (not fragmentShaderCompiled) |
|
83 { |
|
84 log += "\n" + tr("Fragment shader:") + "\n" + object.program->log(); |
|
85 } |
|
86 if (not vertexShaderCompiled or not fragmentShaderCompiled) |
|
87 { |
|
88 QMessageBox::critical(nullptr, tr("Shader compile error"), tr("Could not compile shaders.") + "\n" + log); |
|
89 std::exit(-1); |
|
90 } |
77 object.program->link(); |
91 object.program->link(); |
78 object.program->bind(); |
92 object.program->bind(); |
79 object.buffer.create(); |
93 object.buffer.create(); |
80 object.buffer.bind(); |
94 object.buffer.bind(); |
81 object.buffer.setUsagePattern(QOpenGLBuffer::DynamicDraw); |
95 object.buffer.setUsagePattern(QOpenGLBuffer::DynamicDraw); |