Jelajahi Sumber

mac adaptions

Nicolas Winkler 4 tahun lalu
induk
melakukan
039ed4a1fb
3 mengubah file dengan 13 tambahan dan 5 penghapusan
  1. 10 2
      EscapeTimeVisualWidget.cpp
  2. 1 1
      FractalZoomWidget.cpp
  3. 2 2
      choosegenerators.cpp

+ 10 - 2
EscapeTimeVisualWidget.cpp

@@ -16,11 +16,19 @@ ETVImage::ETVImage(EscapeTimeVisualWidget& owner,
                    const Bitmap<float>& img) :
     owner{ owner }
 {
-    auto& gl = *owner.context()->functions();
+    auto& gl = *QOpenGLContext::currentContext()->functions();
     gl.glGenTextures(1, &textureId);
     gl.glActiveTexture(GL_TEXTURE0);
     gl.glBindTexture(GL_TEXTURE_2D, textureId);
 
+// workaround to weird bug appearing on OS X that the first time
+// a texture is displayed, it seems to display arbitrary graphics data
+// (e.g. parts of other windows or even old mandelbrot textures)
+//
+// bug doesn't appear if glTexImage2D is called twice with the image data
+#ifdef __APPLE__
+    gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, int(img.width), int(img.height), 0, GL_RED, GL_FLOAT, img.pixels.get());
+#endif // __APPLE__
     gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, int(img.width), int(img.height), 0, GL_RED, GL_FLOAT, img.pixels.get());
     gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
@@ -242,7 +250,7 @@ void EscapeTimeVisualWidget::initializeGL(void)
     "        if (aa + bb >= 16.0) break;\n"
     "        k = k + 1;\n"
     "    }\n"
-    "    return float(k) + 1 - log2(log(a * a + b * b) * 0.5);\n"
+    "    return float(k) + 1.0 - log2(log(a * a + b * b) * 0.5);\n"
     "}\n"
     "void main(void)\n"
     "{\n"

+ 1 - 1
FractalZoomWidget.cpp

@@ -475,5 +475,5 @@ void FractalZoomWidget::cellReady(int level, GridIndex i, GridIndex j, Bitmap<fl
     this->getGrid(level).setCell(i, j,
         std::make_unique<GridElement>(true, std::make_shared<ImageClip>(std::make_shared<ETVImage>(*this, *bmp))));
     delete bmp;
-    update();
+    emit update();
 }

+ 2 - 2
choosegenerators.cpp

@@ -401,9 +401,9 @@ void ChooseGenerators::on_buttonBox_accepted()
                 chosenGenerator->addGenerator(precision, *generator);
         }*/
         for (int i = 0; i < ui->table->rowCount(); i++) {
-            QLineEdit* precItem = dynamic_cast<QLineEdit*>(ui->table->cellWidget(i, 0));
+            QLineEdit* precItem = qobject_cast<QLineEdit*>(ui->table->cellWidget(i, 0));
             QWidget* genWidget = ui->table->cellWidget(i, 1);
-            QComboBox* genItem = dynamic_cast<QComboBox*>(genWidget);
+            QComboBox* genItem = qobject_cast<QComboBox*>(genWidget);
             if (precItem && genItem) {
                 QString precString = precItem->text();
                 QString genString = genItem->currentText();