Преглед изворни кода

found opengl bug quick fix

Nicolas Winkler пре 4 година
родитељ
комит
98171b6962
3 измењених фајлова са 12 додато и 4 уклоњено
  1. 8 2
      EscapeTimeVisualWidget.cpp
  2. 1 0
      EscapeTimeVisualWidget.h
  3. 3 2
      FractalWidget.cpp

+ 8 - 2
EscapeTimeVisualWidget.cpp

@@ -88,6 +88,12 @@ void ETVImage::draw(float x, float y, float w, float h,
     program->setUniformValue(gradientScaler, 1.0f / float(owner.gradientTextureMax));
     program->setUniformValue(maxIterations, float(owner.maxIterations));
 
+
+    QMatrix4x4 pmvMatrix;
+    pmvMatrix.ortho(QRect{ 0, 0, owner.getResolutionX(), owner.getResolutionY() });
+    int matrixLocation = program->uniformLocation("matrix");
+    program->setUniformValue(matrixLocation, pmvMatrix);
+
     gl.glEnable(GL_TEXTURE_2D);
     owner.program->bind();
 
@@ -227,10 +233,10 @@ void EscapeTimeVisualWidget::initializeGL(void)
     "    while(k <= 250) {\n"
     "        float aa = a * a;\n"
     "        float bb = b * b;\n"
-    "        float abab = 2 * a * b;\n"
+    "        float abab = 2.0 * a * b;\n"
     "        a = aa - bb + ca;\n"
     "        b = abab + cb;\n"
-    "        if (aa + bb >= 16.0f) break;\n"
+    "        if (aa + bb >= 16.0) break;\n"
     "        k = k + 1;\n"
     "    }\n"
     "    return float(k);\n"

+ 1 - 0
EscapeTimeVisualWidget.h

@@ -31,6 +31,7 @@ class EscapeTimeVisualWidget :
     Q_OBJECT
 
     friend class ETVImage;
+protected:
     QOpenGLShaderProgram* program;
     QOpenGLShaderProgram* renderTextures;
     QOpenGLShaderProgram* juliaPreviewer;

+ 3 - 2
FractalWidget.cpp

@@ -1,7 +1,7 @@
 #include "FractalWidget.h"
 #include <QMouseEvent>
 
-
+#include <QOpenGLShaderProgram>
 #include <QPainter>
 
 
@@ -187,8 +187,9 @@ void FractalWidget::resizeGL(int w, int h)
 void FractalWidget::paintGL(void)
 {
     updateAnimations();
+    EscapeTimeVisualWidget::program->bind();
     FractalZoomWidget::paintGL();
-    EscapeTimeVisualWidget::drawJulia(0.3, 0.2);
+    EscapeTimeVisualWidget::juliaPreviewer->bind();
 
     if (selectingPoint) {
         const auto& vp = getViewport();