23 #include "gl/compiler.h" |
23 #include "gl/compiler.h" |
24 #include "documentmanager.h" |
24 #include "documentmanager.h" |
25 #include "invert.h" |
25 #include "invert.h" |
26 #include "ring.h" |
26 #include "ring.h" |
27 |
27 |
28 static const char* vertexShaderSource = R"( |
28 constexpr char VERTEX_SHADER_SOURCE[] = R"( |
29 #version 330 core |
29 #version 330 core |
30 |
30 |
31 layout(location=0) in vec3 position; |
31 layout(location=0) in vec3 position; |
32 layout(location=1) in vec4 color; |
32 layout(location=1) in vec4 color; |
33 layout(location=2) in vec3 normal; |
33 layout(location=2) in vec3 normal; |
196 void gl::initializeModelShaders(gl::ModelShaders *modelShaders) |
196 void gl::initializeModelShaders(gl::ModelShaders *modelShaders) |
197 { |
197 { |
198 if (not modelShaders->initialized) { |
198 if (not modelShaders->initialized) { |
199 for (auto& shader : modelShaders->shaderObjects) { |
199 for (auto& shader : modelShaders->shaderObjects) { |
200 shader.program = std::make_unique<QOpenGLShaderProgram>(); |
200 shader.program = std::make_unique<QOpenGLShaderProgram>(); |
201 gl::buildShaders(shader.program.get(), ::vertexShaderSource, ::fragmentShaderSource); |
201 gl::buildShaders(shader.program.get(), VERTEX_SHADER_SOURCE, FRAGMENT_SHADER_SOURCE); |
202 shader.program->bind(); |
202 shader.program->bind(); |
203 shader.buffer.create(); |
203 shader.buffer.create(); |
204 shader.buffer.bind(); |
204 shader.buffer.bind(); |
205 shader.buffer.setUsagePattern(QOpenGLBuffer::DynamicDraw); |
205 shader.buffer.setUsagePattern(QOpenGLBuffer::DynamicDraw); |
206 shader.vertexArray.create(); |
206 shader.vertexArray.create(); |