113 glClearColor( |
113 glClearColor( |
114 static_cast<float>(backgroundColor.redF()), |
114 static_cast<float>(backgroundColor.redF()), |
115 static_cast<float>(backgroundColor.greenF()), |
115 static_cast<float>(backgroundColor.greenF()), |
116 static_cast<float>(backgroundColor.blueF()), |
116 static_cast<float>(backgroundColor.blueF()), |
117 1.0f); |
117 1.0f); |
118 this->compiler->setUniform("useLighting", true); |
118 this->compiler->setUniform("useLighting", GL_TRUE); |
119 } |
119 } |
120 else |
120 else |
121 { |
121 { |
122 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
122 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
123 this->compiler->setUniform("useLighting", false); |
123 this->compiler->setUniform("useLighting", GL_FALSE); |
124 } |
124 } |
125 this->compiler->setUniform("selectedColor", vec3FromQColor(this->renderPreferences.selectedColor)); |
125 this->compiler->setUniform("selectedColor", vec3FromQColor(this->renderPreferences.selectedColor)); |
126 this->compiler->setUniform("highlighted", this->highlighted.value); |
126 this->compiler->setUniform("highlighted", this->highlighted.value); |
|
127 this->checkForGLErrors(); |
127 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
128 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
128 glEnable(GL_DEPTH_TEST); |
129 glEnable(GL_DEPTH_TEST); |
129 glEnable(GL_POLYGON_OFFSET_FILL); |
130 glEnable(GL_POLYGON_OFFSET_FILL); |
130 glPolygonOffset(1.0f, 1.0f); |
131 glPolygonOffset(1.0f, 1.0f); |
131 glLineWidth(this->renderPreferences.lineThickness); |
132 glLineWidth(this->renderPreferences.lineThickness); |
185 |
186 |
186 void PartRenderer::renderVao(const gl::ArrayClass arrayClass) |
187 void PartRenderer::renderVao(const gl::ArrayClass arrayClass) |
187 { |
188 { |
188 this->compiler->bindVertexArray(arrayClass); |
189 this->compiler->bindVertexArray(arrayClass); |
189 const std::size_t vertexCount = this->compiler->vertexCount(arrayClass); |
190 const std::size_t vertexCount = this->compiler->vertexCount(arrayClass); |
|
191 this->checkForGLErrors(); |
190 glDrawArrays(getGlTypeForArrayClass(arrayClass), 0, static_cast<GLsizei>(vertexCount)); |
192 glDrawArrays(getGlTypeForArrayClass(arrayClass), 0, static_cast<GLsizei>(vertexCount)); |
|
193 this->checkForGLErrors(); |
191 this->compiler->releaseVertexArray(arrayClass); |
194 this->compiler->releaseVertexArray(arrayClass); |
192 this->checkForGLErrors(); |
195 this->checkForGLErrors(); |
193 } |
196 } |
194 |
197 |
195 void PartRenderer::checkForGLErrors() |
198 void PartRenderer::checkForGLErrors() |
248 const gl::RenderStyle oldRenderStyle = this->renderPreferences.style; |
251 const gl::RenderStyle oldRenderStyle = this->renderPreferences.style; |
249 this->renderPreferences.style = gl::RenderStyle::PickScene; |
252 this->renderPreferences.style = gl::RenderStyle::PickScene; |
250 this->makeCurrent(); |
253 this->makeCurrent(); |
251 this->renderScene(); |
254 this->renderScene(); |
252 std::array<GLbyte, 3> data; |
255 std::array<GLbyte, 3> data; |
|
256 this->checkForGLErrors(); |
253 glReadPixels(where.x(), this->height() - where.y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &data[0]); |
257 glReadPixels(where.x(), this->height() - where.y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &data[0]); |
|
258 this->checkForGLErrors(); |
254 this->renderPreferences.style = oldRenderStyle; |
259 this->renderPreferences.style = oldRenderStyle; |
255 this->update(); |
260 this->update(); |
256 return gl::Compiler::idFromColor(data); |
261 return gl::Compiler::idFromColor(data); |
257 } |
262 } |
258 |
263 |