diff -r 73b6c478378e -r 41b38b9e05a2 src/gl/partrenderer.cpp --- a/src/gl/partrenderer.cpp Sun Apr 09 01:12:00 2023 +0300 +++ b/src/gl/partrenderer.cpp Sun Apr 09 12:23:32 2023 +0300 @@ -101,21 +101,6 @@ Q_EMIT projectionMatrixChanged(this->projectionMatrix); } -static constexpr GLenum getGlTypeForArrayClass(const gl::ArrayClass vboClass) -{ - switch (vboClass) - { - case gl::ArrayClass::Lines: - case gl::ArrayClass::ConditionalLines: - return GL_LINES; - case gl::ArrayClass::Triangles: - return GL_TRIANGLES; - case gl::ArrayClass::Quads: - return GL_QUADS; - } - throw std::runtime_error{"bad value for vboClass"}; -} - void PartRenderer::paintGL() { glEnable(GL_DEPTH_TEST); @@ -178,9 +163,9 @@ glLineWidth(this->renderPreferences.lineThickness); const auto renderAllArrays = [this](){ // Lines need to be rendered last so that anti-aliasing does not interfere with polygon rendering. - this->renderVao(gl::ArrayClass::Triangles); - this->renderVao(gl::ArrayClass::Quads); - this->renderVao(gl::ArrayClass::Lines); + this->renderVao(); + this->renderVao(); + this->renderVao(); }; if (this->renderPreferences.wireframe and this->renderPreferences.style != gl::RenderStyle::PickScene) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); @@ -195,15 +180,15 @@ glEnable(GL_CULL_FACE); glCullFace(GL_BACK); this->setFragmentStyle(gl::FragmentStyle::BfcGreen); - renderVao(gl::ArrayClass::Triangles); - renderVao(gl::ArrayClass::Quads); + renderVao(); + renderVao(); glCullFace(GL_FRONT); this->setFragmentStyle(gl::FragmentStyle::BfcRed); - renderVao(gl::ArrayClass::Triangles); - renderVao(gl::ArrayClass::Quads); + renderVao(); + renderVao(); glDisable(GL_CULL_FACE); this->setFragmentStyle(gl::FragmentStyle::Normal); - renderVao(gl::ArrayClass::Lines); + renderVao(); break; case gl::RenderStyle::RandomColors: this->setFragmentStyle(gl::FragmentStyle::RandomColors); @@ -248,12 +233,12 @@ this->needBuild = true; } -void PartRenderer::renderVao(const gl::ArrayClass arrayClass) +void PartRenderer::renderVao(const gl::ArrayClass arrayClass, const GLenum glType) { gl::bindModelShaderVertexArray(&this->shaders, arrayClass); const std::size_t vertexCount = gl::vertexCount(&this->shaders, arrayClass); this->checkForGLErrors(); - glDrawArrays(getGlTypeForArrayClass(arrayClass), 0, static_cast(vertexCount)); + glDrawArrays(glType, 0, static_cast(vertexCount)); this->checkForGLErrors(); gl::releaseModelShaderVertexArray(&this->shaders, arrayClass); this->checkForGLErrors();