diff -r bbb901b97404 -r 90443fb328ea src/gl/partrenderer.cpp --- a/src/gl/partrenderer.cpp Fri Jan 31 00:25:35 2020 +0200 +++ b/src/gl/partrenderer.cpp Sat Feb 01 15:33:57 2020 +0200 @@ -103,26 +103,49 @@ glClearColor(0.8f, 0.8f, 0.8f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); - glEnable(GL_LIGHTING); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1.0f, 1.0f); switch (this->renderStyle) { case gl::RenderStyle::Normal: + this->setFragmentStyle(gl::FragmentStyle::Normal); + this->renderAllArrays(); + break; case gl::RenderStyle::BfcRedGreen: + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + this->setFragmentStyle(gl::FragmentStyle::BfcGreen); + renderVao(gl::ArrayClass::Triangles); + renderVao(gl::ArrayClass::Quads); + glCullFace(GL_FRONT); + this->setFragmentStyle(gl::FragmentStyle::BfcRed); + renderVao(gl::ArrayClass::Triangles); + renderVao(gl::ArrayClass::Quads); + glDisable(GL_CULL_FACE); + this->setFragmentStyle(gl::FragmentStyle::Normal); + renderVao(gl::ArrayClass::Lines); case gl::RenderStyle::RandomColors: + this->setFragmentStyle(gl::FragmentStyle::RandomColors); + this->renderAllArrays(); break; case gl::RenderStyle::Wireframe: glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + this->setFragmentStyle(gl::FragmentStyle::Normal); + this->renderAllArrays(); break; } + glDisable(GL_POLYGON_OFFSET_FILL); +} + +void PartRenderer::renderAllArrays() +{ // Lines need to be rendered last so that anti-aliasing does not interfere with polygon rendering. renderVao(gl::ArrayClass::Triangles); renderVao(gl::ArrayClass::Quads); renderVao(gl::ArrayClass::Lines); - glDisable(GL_POLYGON_OFFSET_FILL); } + void PartRenderer::updateViewMatrix() { // I'm not quite sure why using the exponent function on the zoom factor causes linear zoom behavior @@ -188,6 +211,19 @@ this->update(); } +/** + * @brief Changes the color of rendered fragments + * @param newFragmentStyle new fragment style to use + */ +void PartRenderer::setFragmentStyle(gl::FragmentStyle newFragmentStyle) +{ + this->compiler->setUniform("fragmentStyle", static_cast(newFragmentStyle)); +} + +/** + * @brief Changes the way the scene is rendered + * @param newStyle new render style to use + */ void PartRenderer::setRenderStyle(const gl::RenderStyle newStyle) { this->renderStyle = newStyle;