diff -r a5111f4e6412 -r 918b6c0f8b5b src/gl/partrenderer.cpp --- a/src/gl/partrenderer.cpp Fri Dec 13 15:55:56 2019 +0200 +++ b/src/gl/partrenderer.cpp Fri Dec 13 21:35:59 2019 +0200 @@ -21,15 +21,6 @@ this->rotation *= QQuaternion::fromAxisAndAngle({0, 1, 0}, 330); } -// https://stackoverflow.com/a/12943456 -static void perspectiveGL(GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar) -{ - //fH = tan( (fovY / 2) / 180 * pi ) * zNear; - const GLdouble fH = std::tan(fovY / 360 * pi) * zNear; - const GLdouble fW = fH * aspect; - glFrustum(-fW, fW, -fH, fH, zNear, zFar); -} - /* * Pads a 3×3 matrix into a 4×4 one by adding cells from the identity matrix. */ @@ -63,17 +54,27 @@ void PartRenderer::resizeGL(int width, int height) { constexpr GLfloat near = 1.0f; - constexpr GLfloat far = 1.0e+05f; + constexpr GLfloat far = 1e+05f; glViewport (0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - ::perspectiveGL(45.0f, static_cast(width) / static_cast(height), near, far); + gluPerspective(45.0f, static_cast(width) / static_cast(height), near, far); glMatrixMode(GL_MODELVIEW); } // https://www.codemiles.com/c-opengl-examples/drawing-teapot-using-opengl-t9010.html?mobile=on void PartRenderer::paintGL() { + switch (this->renderStyle) + { + case gl::RenderStyle::Normal: + case gl::RenderStyle::BfcRedGreen: + case gl::RenderStyle::RandomColors: + break; + case gl::RenderStyle::Wireframe: + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + break; + } glMatrixMode(GL_MODELVIEW); // clear the drawing buffer. glClear(GL_COLOR_BUFFER_BIT); @@ -116,3 +117,10 @@ } this->lastMousePosition = pointToPointF(event->pos()); } + +void PartRenderer::setRenderStyle(const gl::RenderStyle newStyle) +{ + this->renderStyle = newStyle; + this->update(); +} +