Przeglądaj źródła

Merge branch 'master' of https://git.winfor.ch/nicolas/Almond

Nicolas Winkler 5 lat temu
rodzic
commit
dc3394a2b7

+ 16 - 3
Almond.cpp

@@ -6,6 +6,8 @@
 #include <QGradient>
 #include "gradientchoosedialog.h"
 
+#include "GridFlowLayout.h"
+
 #include <cmath>
 
 Almond::Almond(QWidget* parent) :
@@ -34,9 +36,20 @@ Almond::Almond(QWidget* parent) :
     ui.backgroundProgress->setVisible(false);
 
     backgroundTasks.setMaxThreadCount(1);
-    this->setWindowIcon(QIcon(":/icons/icon"));
-    //ui.verticalLayout_left->addWidget(new MyGLWidget(ui.centralWidget));
-    //mw->show();
+    QIcon icon{ ":/icons/icon" };
+    icon.addFile(":/icons/icon@2x");
+    this->setWindowIcon(icon);
+
+    // replace vertical layout with gridflowlayout
+    /*GridFlowLayout* gfl = new GridFlowLayout(nullptr);
+    //ui.horizontalLayout_4->addItem(gfl);
+    for (int i = 0; i < ui.verticalLayout_right->count(); i++) {
+        printf("%d: \n", i);
+        gfl->addItem(ui.verticalLayout_right->takeAt(i));
+    }
+    ui.verticalLayout_right->setEnabled(false);
+    delete ui.dockWidgetContents_2->layout();
+    ui.dockWidgetContents_2->setLayout(gfl);*/
 }
 
 

+ 6 - 3
Almond.pro

@@ -37,6 +37,7 @@ SOURCES += \
         customgenerator.cpp \
         exportdialogs.cpp \
         gradientchoosedialog.cpp \
+        GridFlowLayout.cpp \
         main.cpp
 
 HEADERS += \
@@ -50,6 +51,7 @@ HEADERS += \
         choosegenerators.h \
         customgenerator.h \
         exportdialogs.h \
+        GridFlowLayout.h \
         gradientchoosedialog.h
 
 FORMS += \
@@ -79,7 +81,7 @@ unix:LIBS += -lm -latomic
 
 win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../libs/ffmpeg-20200216-8578433-win64-dev/lib/ -lavcodec
 else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../libs/ffmpeg-20200216-8578433-win64-dev/lib/ -lavcodec
-else:unix: LIBS += -L$$PWD/../libs/ffmpeg-4.1.1-win32-dev/lib/ -lavcodec
+else:unix: LIBS += -lavcodec
 
 win32:FFMPEGPATH = $$PWD/../libs/ffmpeg-20200216-8578433-win64-dev/lib/
 win32:INCLUDEPATH += $$PWD/../libs/ffmpeg-20200216-8578433-win64-dev/include
@@ -126,8 +128,9 @@ unix|win32: LIBS += -L$FFMPEGPATH -lswscale
 RESOURCES += Almond.qrc \
     splash.qrc
 
-unix|win32: LIBS += -L$$PWD/libmandel/ -L$$PWD/libalmond/ -lmandel -lqd -lasmjit -lalmond -llibpng16_static -lzlibstatic
-unix: LIBS += -lrt
+win32:LIBS += -llibpng16_static -lzlibstatic
+unix|win32: LIBS += -L$$PWD/libmandel/ -L$$PWD/libalmond/ -lmandel -lqd -lasmjit -lalmond
+unix: LIBS += -lrt -lpng -lavcodec -lavdevice -lavformat -lavutil -lswscale -lavfilter
 
 INCLUDEPATH += $$PWD/libmandel/include $$PWD/libmandel/qd-2.3.22/include $$PWD/libalmond/include
 DEPENDPATH += $$PWD/libmandel/include $$PWD/libmandel/qd-2.3.22/include $$PWD/libalmond/include

+ 1 - 0
Almond.qrc

@@ -1,6 +1,7 @@
 <RCC>
     <qresource prefix="/icons">
         <file alias="icon">icon.png</file>
+        <file alias="icon@2x">icon.png</file>
     </qresource>
     <qresource prefix="/gradients">
         <file alias="default">gradients/default.xml</file>

+ 51 - 55
Almond.ui

@@ -44,7 +44,50 @@
      <item>
       <layout class="QVBoxLayout" name="verticalLayout_right">
        <item>
-        <widget class="QGroupBox" name="groupBox_3">
+        <widget class="QGroupBox" name="grp_zoom">
+         <property name="title">
+          <string>Zoom</string>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_2">
+          <item row="1" column="0">
+           <widget class="QPushButton" name="zoom_in">
+            <property name="text">
+             <string>Zoom In</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1">
+           <widget class="QPushButton" name="zoom_out">
+            <property name="text">
+             <string>Zoom Out</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="0" colspan="2">
+           <widget class="QPushButton" name="resetZoom">
+            <property name="text">
+             <string>Reset Zoom</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>0</width>
+           <height>0</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QGroupBox" name="grp_display_opts">
          <property name="title">
           <string>Display/Calculation Options</string>
          </property>
@@ -129,67 +172,20 @@
         </widget>
        </item>
        <item>
-        <spacer name="verticalSpacer_3">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>13</width>
-           <height>13</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item>
-        <layout class="QGridLayout" name="gridLayout">
-         <item row="0" column="0">
-          <widget class="QGroupBox" name="groupBox_2">
-           <property name="title">
-            <string>Zoom</string>
-           </property>
-           <layout class="QGridLayout" name="gridLayout_2">
-            <item row="1" column="0">
-             <widget class="QPushButton" name="zoom_in">
-              <property name="text">
-               <string>Zoom In</string>
-              </property>
-             </widget>
-            </item>
-            <item row="1" column="1">
-             <widget class="QPushButton" name="zoom_out">
-              <property name="text">
-               <string>Zoom Out</string>
-              </property>
-             </widget>
-            </item>
-            <item row="0" column="0" colspan="2">
-             <widget class="QPushButton" name="resetZoom">
-              <property name="text">
-               <string>Reset Zoom</string>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </widget>
-         </item>
-        </layout>
-       </item>
-       <item>
         <spacer name="verticalSpacer_2">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
-           <width>13</width>
-           <height>13</height>
+           <width>0</width>
+           <height>0</height>
           </size>
          </property>
         </spacer>
        </item>
        <item>
-        <widget class="QGroupBox" name="groupBox">
+        <widget class="QGroupBox" name="grp_fractal">
          <property name="title">
           <string>Fractal</string>
          </property>
@@ -233,20 +229,20 @@
         </widget>
        </item>
        <item>
-        <spacer name="verticalSpacer">
+        <spacer name="verticalSpacer_3">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
-           <width>13</width>
-           <height>13</height>
+           <width>0</width>
+           <height>0</height>
           </size>
          </property>
         </spacer>
        </item>
        <item>
-        <widget class="QGroupBox" name="export_box">
+        <widget class="QGroupBox" name="grp_export_box">
          <property name="title">
           <string>Export</string>
          </property>

+ 0 - 2
CMakeLists.txt

@@ -10,7 +10,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules)
 
 find_package(Qt5 COMPONENTS Core Widgets OpenGL Xml Concurrent REQUIRED)
 find_package(OpenMP)
-find_package(OpenGL REQUIRED COMPONENTS OpenGL)
 set(Boost_USE_STATIC_LIBS ON)
 find_package(Boost 1.65 REQUIRED)
 
@@ -37,7 +36,6 @@ target_include_directories(Almond SYSTEM PUBLIC ${FFMPEG_INCLUDE_DIRS})
 target_link_libraries(Almond PUBLIC libalmond)
 target_link_libraries(Almond PUBLIC Qt5::Core Qt5::Widgets Qt5::OpenGL Qt5::Xml Qt5::Concurrent)
 target_link_libraries(Almond PUBLIC ${FFMPEG_LIBRARIES})
-target_link_libraries(Almond PUBLIC OpenGL::GL)
 
 set_property(TARGET Almond PROPERTY AUTOMOC ON)
 set_property(TARGET Almond PROPERTY AUTORCC ON)

+ 157 - 0
GridFlowLayout.cpp

@@ -0,0 +1,157 @@
+#include "GridFlowLayout.h"
+#include <QWidget>
+#include <QStyle>
+
+GridFlowLayout::GridFlowLayout(QWidget* parent) :
+    QLayout{ parent }
+{
+}
+
+
+void GridFlowLayout::addItem(QLayoutItem* item)
+{
+    items.append(item);
+}
+
+
+QLayoutItem* GridFlowLayout::itemAt(int index) const
+{
+    return items.value(index);
+}
+
+
+QLayoutItem* GridFlowLayout::takeAt(int index)
+{
+    if (index >= 0 && index < items.size())
+        return items.takeAt(index);
+    return nullptr;
+}
+
+
+bool GridFlowLayout::hasHeightForWidth(void) const
+{
+    return true;
+}
+
+
+int GridFlowLayout::heightForWidth(int width) const
+{
+    return 300;
+}
+
+
+int GridFlowLayout::count(void) const
+{
+    return items.size();
+}
+
+
+Qt::Orientations GridFlowLayout::expandingDirections(void) const
+{
+    return 0;
+}
+
+
+QSize GridFlowLayout::minimumSize(void) const
+{
+    return QSize{ 400, 400 };
+}
+
+
+QSize GridFlowLayout::sizeHint(void) const
+{
+    return minimumSize();
+}
+
+
+void GridFlowLayout::setGeometry(const QRect& rect)
+{
+    QLayout::setGeometry(rect);
+    int mleft, mtop, mright, mbottom;
+    getContentsMargins(&mleft, &mtop, &mright, &mbottom);
+    QRect area = rect.adjusted(mleft, mtop, -mright, -mbottom);
+
+    QVector<QSize> sizeHints;
+    for (QLayoutItem* item : qAsConst(items)) {
+        sizeHints.append(item->sizeHint());
+    }
+
+    int rows;
+    for (rows = count(); rows > 1; rows--) {
+        if (checkRows(rows, rect, sizeHints)) {
+            break;
+        }
+    }
+    rows = 1;
+    applyLayout(rows, sizeHints, area);
+
+/*
+    int x = area.x();
+    int y = area.y();
+    for (QLayoutItem* item : qAsConst(items)) {
+        const QWidget* widget = item->widget();
+        int spaceX = 5;
+        int spaceY = 5;
+        int width = area.width();
+        int height = 200;//area.height();
+        item->setGeometry(QRect(x, y, width, height));
+        y += height;
+    }*/
+}
+
+
+void GridFlowLayout::applyLayout(int rows, const QVector<QSize>& sizeHints,
+                                 const QRect& area)
+{
+    calculateRows(rows, sizeHints);
+    int x = area.x();
+    for (int i = 0; i < rows; i++) {
+        int width = widths[i];
+        int y = area.y();
+        for (int j = 0; j <= count() / rows; j++) {
+            int index = i + j * rows;
+            if (index < count()) {
+                int height = heights[j];
+                QLayoutItem* item = items.value(index);
+                const QWidget* widget = item->widget();
+                item->setGeometry(QRect(x, y, width, height));
+                y += height;
+            }
+        }
+        x += width;
+    }
+}
+
+
+void GridFlowLayout::calculateRows(int rows, const QVector<QSize>& sizeHints)
+{
+    widths.clear();
+    heights.clear();
+    for (int i = 0; i < rows; i++) {
+        int maxWidth = 0;
+        for(int j = i; j < sizeHints.size(); j += rows) {
+            maxWidth = std::max(maxWidth, sizeHints[j].width());
+        }
+        widths.append(maxWidth);
+    }
+    for (int i = 0; i < sizeHints.size(); i += rows) {
+        int maxHeight = 0;
+        for(int j = i; j < i + rows && j < sizeHints.size(); j++) {
+            maxHeight = std::max(maxHeight, sizeHints[j].height());
+        }
+        heights.append(maxHeight);
+    }
+}
+
+
+bool GridFlowLayout::checkRows(int rows, const QRect& rect,
+                               const QVector<QSize>& sizeHints)
+{
+    calculateRows(rows, sizeHints);
+    int width = 0;
+    int height = 0;
+    for (int w : widths) width += w;
+    for (int h : heights) height += h;
+
+    return width <= rect.width() && height <= rect.height();
+}

+ 38 - 0
GridFlowLayout.h

@@ -0,0 +1,38 @@
+#ifndef GRIDFLOWLAYOUT_H
+#define GRIDFLOWLAYOUT_H
+
+#include <QLayout>
+#include <QList>
+#include <QVector>
+
+class GridFlowLayout : 
+    public QLayout
+{
+    QList<QLayoutItem*> items;
+    QVector<int> widths;
+    QVector<int> heights;
+public:
+    GridFlowLayout(QWidget* parent);
+
+    void                addItem             (QLayoutItem* item) override;
+    QLayoutItem*        itemAt              (int index) const override;
+    QLayoutItem*        takeAt              (int index) override;
+    bool                hasHeightForWidth   (void) const override;
+    int                 heightForWidth      (int width) const override;
+    int                 count               (void) const override;
+    Qt::Orientations    expandingDirections (void) const override;
+    QSize               minimumSize         (void) const override;
+    QSize               sizeHint            (void) const override;
+    void                setGeometry         (const QRect& rect) override;
+private:
+    void                applyLayout         (int rows, const QVector<QSize>& sizeHints,
+                                             const QRect& area);
+    void                calculateRows       (int rows, const QVector<QSize>& sizeHints);
+    bool                checkRows           (int rows, const QRect& rect,
+                                             const QVector<QSize>& sizeHints);
+    
+};
+
+
+#endif // GRIDFLOWLAYOUT_H
+

+ 66 - 86
MandelWidget.cpp

@@ -7,10 +7,11 @@ using namespace mnd;
 #include <cstdio>
 
 
-Texture::Texture(const Bitmap<RGBColor>& bitmap, GLint param)
+Texture::Texture(QOpenGLFunctions_2_0& gl, const Bitmap<RGBColor>& bitmap, GLint param) :
+    gl{ gl }
 {
-    glGenTextures(1, &id);
-    glBindTexture(GL_TEXTURE_2D, id);
+    gl.glGenTextures(1, &id);
+    gl.glBindTexture(GL_TEXTURE_2D, id);
 
     //int lineLength = (bitmap.width * 3 + 3) & ~3;
 
@@ -24,23 +25,24 @@ Texture::Texture(const Bitmap<RGBColor>& bitmap, GLint param)
             pixels[index + 2] = c.b;
         }
     }*/
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, int(bitmap.width), int(bitmap.height), 0, GL_RGB, GL_UNSIGNED_BYTE, reinterpret_cast<char*> (bitmap.pixels.get()));
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, param);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, param);
+    gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, int(bitmap.width), int(bitmap.height), 0, GL_RGB, GL_UNSIGNED_BYTE, reinterpret_cast<char*> (bitmap.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);
+    gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, param);
+    gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, param);
 }
 
 
 Texture::~Texture(void)
 {
     if (id != 0)
-        glDeleteTextures(1, &id);
+        gl.glDeleteTextures(1, &id);
 }
 
 
 Texture::Texture(Texture&& other) :
-    id{ other.id }
+    id{ other.id },
+    gl{ other.gl }
 {
     other.id = 0;
 }
@@ -49,6 +51,7 @@ Texture::Texture(Texture&& other) :
 Texture& Texture::operator=(Texture&& other)
 {
     this->id = other.id;
+    this->gl = other.gl;
     other.id = 0;
     return *this;
 }
@@ -56,26 +59,26 @@ Texture& Texture::operator=(Texture&& other)
 
 void Texture::bind(void) const
 {
-    glBindTexture(GL_TEXTURE_2D, id);
+    gl.glBindTexture(GL_TEXTURE_2D, id);
 }
 
 
 void Texture::drawRect(float x, float y, float width, float height)
 {
-    glColor3ub(255, 255, 255);
-    glEnable(GL_TEXTURE_2D);
+    gl.glColor3ub(255, 255, 255);
+    gl.glEnable(GL_TEXTURE_2D);
     bind();
-    glBegin(GL_TRIANGLE_STRIP);
-    glTexCoord2f(0, 0);
-    glVertex2f(x, y);
-    glTexCoord2f(1, 0);
-    glVertex2f(x + width, y);
-    glTexCoord2f(0, 1);
-    glVertex2f(x, y + height);
-    glTexCoord2f(1, 1);
-    glVertex2f(x + width, y + height);
-    glEnd();
-    glDisable(GL_TEXTURE_2D);
+    gl.glBegin(GL_TRIANGLE_STRIP);
+    gl.glTexCoord2f(0, 0);
+    gl.glVertex2f(x, y);
+    gl.glTexCoord2f(1, 0);
+    gl.glVertex2f(x + width, y);
+    gl.glTexCoord2f(0, 1);
+    gl.glVertex2f(x, y + height);
+    gl.glTexCoord2f(1, 1);
+    gl.glVertex2f(x + width, y + height);
+    gl.glEnd();
+    gl.glDisable(GL_TEXTURE_2D);
 }
 
 
@@ -91,20 +94,21 @@ TextureClip::~TextureClip(void)
 
 void TextureClip::drawRect(float x, float y, float width, float height)
 {
-    glColor3ub(255, 255, 255);
-    glEnable(GL_TEXTURE_2D);
-    glBindTexture(GL_TEXTURE_2D, texture->getId());
-    glBegin(GL_TRIANGLE_STRIP);
-    glTexCoord2f(tx, ty);
-    glVertex2f(x, y);
-    glTexCoord2f(tx + tw, ty);
-    glVertex2f(x + width, y);
-    glTexCoord2f(tx, ty + th);
-    glVertex2f(x, y + height);
-    glTexCoord2f(tx + tw, ty + th);
-    glVertex2f(x + width, y + height);
-    glEnd();
-    glDisable(GL_TEXTURE_2D);
+    auto& gl = texture->gl;
+    gl.glColor3ub(255, 255, 255);
+    gl.glEnable(GL_TEXTURE_2D);
+    gl.glBindTexture(GL_TEXTURE_2D, texture->getId());
+    gl.glBegin(GL_TRIANGLE_STRIP);
+    gl.glTexCoord2f(tx, ty);
+    gl.glVertex2f(x, y);
+    gl.glTexCoord2f(tx + tw, ty);
+    gl.glVertex2f(x + width, y);
+    gl.glTexCoord2f(tx, ty + th);
+    gl.glVertex2f(x, y + height);
+    gl.glTexCoord2f(tx + tw, ty + th);
+    gl.glVertex2f(x + width, y + height);
+    gl.glEnd();
+    gl.glDisable(GL_TEXTURE_2D);
 }
 
 
@@ -337,7 +341,8 @@ MandelView::MandelView(mnd::MandelGenerator* generator, MandelWidget& owner) :
     }*/
     Bitmap<RGBColor> emp(1, 1);
     emp.get(0, 0) = RGBColor{ 0, 0, 0 };
-    empty = std::make_unique<Texture>(emp, GL_NEAREST);
+    auto& gl = *QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
+    empty = std::make_unique<Texture>(gl, emp, GL_NEAREST);
     connect(&calcer, &Calcer::done, this, &MandelView::cellReady);
 }
 
@@ -550,9 +555,9 @@ void MandelView::paint(const mnd::MandelViewport& mvp, QPainter& qp)
 
 void MandelView::cellReady(int level, GridIndex i, GridIndex j, Bitmap<RGBColor>* bmp)
 {
-
+    auto& gl = *QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
     this->getGrid(level).setCell(i, j,
-        std::make_unique<GridElement>(true, std::make_shared<TextureClip>(std::make_shared<Texture>(*bmp))));
+        std::make_unique<GridElement>(true, std::make_shared<TextureClip>(std::make_shared<Texture>(gl, *bmp))));
     delete bmp;
     emit redrawRequested();
 }
@@ -569,16 +574,6 @@ MandelWidget::MandelWidget(mnd::MandelContext& ctxt, mnd::MandelGenerator* gener
         QSizePolicy::Expanding);
     qRegisterMetaType<GridIndex>("GridIndex");
     this->format().setSwapInterval(1);
-
-    /*gradient = Gradient {
-        {
-            { RGBColor{ 0, 0, 0 }, 0 },
-            { RGBColor{ 180, 20, 10 }, 30 },
-            { RGBColor{ 210, 180, 15 }, 70 },
-            { RGBColor{ 160, 220, 45 }, 170 },
-            { RGBColor{ 50, 150, 170 }, 300 },
-        }
-    };*/
 }
 
 
@@ -662,13 +657,14 @@ void MandelWidget::clearAll(void)
 
 void MandelWidget::initializeGL(void)
 {
-    this->context()->functions()->glClearColor(0, 0, 0, 0);
+    auto& gl = *this->context()->functions();
+    gl.glClearColor(0, 0, 0, 0);
     this->context()->makeCurrent(nullptr);
 
-    glDisable(GL_DEPTH_TEST);
+    gl.glDisable(GL_DEPTH_TEST);
 
     // looks not even better
-    glEnable(GL_FRAMEBUFFER_SRGB);
+    gl.glEnable(GL_FRAMEBUFFER_SRGB);
 
     //glShadeModel(GL_SMOOTH);
 
@@ -678,12 +674,13 @@ void MandelWidget::initializeGL(void)
 
 void MandelWidget::resizeGL(int w, int h)
 {
+    auto& gl = *this->context()->functions();
     double aspect = double(w) / h;
 
     currentViewport.height = currentViewport.width / aspect;
     targetViewport = currentViewport;
-    float x = this->devicePixelRatioF();
-    glViewport(0, 0, w * x, h * x);
+    float pixelRatio = this->devicePixelRatioF();
+    gl.glViewport(0, 0, w * pixelRatio, h * pixelRatio);
 
     if (mandelView.get() != nullptr) {
         mandelView->width = w;
@@ -694,6 +691,7 @@ void MandelWidget::resizeGL(int w, int h)
 
 void MandelWidget::paintGL(void)
 {
+    auto& gl = *QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
     if (mandelView == nullptr) {
         mandelView = std::make_unique<MandelView>(generator, *this);
         QObject::connect(mandelView.get(), &MandelView::redrawRequested, this, static_cast<void(QOpenGLWidget::*)(void)>(&QOpenGLWidget::update));
@@ -701,22 +699,22 @@ void MandelWidget::paintGL(void)
 
     int width = this->width();
     int height = this->height();
-    float x = this->devicePixelRatioF();
-    mandelView->width = width * x;
-    mandelView->height = height * x;
+    float pixelRatio = this->devicePixelRatioF();
+    mandelView->width = width * pixelRatio;
+    mandelView->height = height * pixelRatio;
     //glViewport(0, 0, width, height);
 
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
+    gl.glMatrixMode(GL_PROJECTION);
+    gl.glLoadIdentity();
 #ifdef QT_OPENGL_ES_1
-    glOrthof(0, width * x, height * x, 0, -1.0, 1.0);
+    gl.glOrthof(0, width * pixelRatio, height * pixelRatio, 0, -1.0, 1.0);
 #else
-    glOrtho(0, width * x, height * x, 0, -1.0, 1.0);
+    gl.glOrtho(0, width * pixelRatio, height * pixelRatio, 0, -1.0, 1.0);
 #endif
-    glMatrixMode(GL_MODELVIEW);
-    glLoadIdentity();
+    gl.glMatrixMode(GL_MODELVIEW);
+    gl.glLoadIdentity();
 
-    glClear(GL_COLOR_BUFFER_BIT);
+    gl.glClear(GL_COLOR_BUFFER_BIT);
 
     updateAnimations();
 
@@ -761,31 +759,13 @@ void MandelWidget::updateAnimations(void)
 void MandelWidget::drawRubberband(void)
 {
     QPainter rubberbandPainter{ this };
-    rubberbandPainter.fillRect(rubberband, QColor{ 25, 225, 25, 50 });
+    rubberbandPainter.fillRect(rubberband, QColor{ 125, 140, 225, 120 });
 
-    QPen pen{ QColor{ 10, 200, 10 } };
+    QPen pen{ QColor{ 100, 115, 200 } };
     pen.setWidth(2);
     rubberbandPainter.setPen(pen);
 
     rubberbandPainter.drawRect(rubberband);
-    /*glColor3ub(10, 200, 10);
-    glBegin(GL_LINE_LOOP);
-    glVertex2d(rubberband.x(), rubberband.y());
-    glVertex2d(rubberband.right(), rubberband.y());
-    glVertex2d(rubberband.right(), rubberband.bottom());
-    glVertex2d(rubberband.x(), rubberband.bottom());
-    glEnd();
-
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    glColor4f(0.1f, 0.9f, 0.1f, 0.2f);
-    glBegin(GL_TRIANGLE_FAN);
-    glVertex2d(rubberband.x(), rubberband.y());
-    glVertex2d(rubberband.right(), rubberband.y());
-    glVertex2d(rubberband.right(), rubberband.bottom());
-    glVertex2d(rubberband.x(), rubberband.bottom());
-    glEnd();
-    glDisable(GL_BLEND);*/
 }
 
 

+ 3 - 1
MandelWidget.h

@@ -6,6 +6,7 @@
 #include <QMouseEvent>
 #include <QOpenGLContext>
 #include <QOpenGLFunctions>
+#include <QOpenGLFunctions_2_0>
 #include <QMutex>
 #include <QPainter>
 //#include <qopengl.h>
@@ -36,7 +37,8 @@ class Texture
 {
     GLuint id;
 public:
-    Texture(const Bitmap<RGBColor>& pict, GLint param = GL_LINEAR);
+    QOpenGLFunctions_2_0& gl;
+    Texture(QOpenGLFunctions_2_0& gl, const Bitmap<RGBColor>& pict, GLint param = GL_LINEAR);
     ~Texture(void);
 
     Texture(const Texture& other) = delete;

+ 1 - 1
libalmond/include/MandelVideoGenerator.h

@@ -47,7 +47,7 @@ public:
 private:
     const ExportVideoInfo evi;
     std::vector<ProgressCallback> progressCallbacks;
-    public:
+public:
     MandelVideoGenerator(const ExportVideoInfo& evi);
 
     void generate(mnd::MandelGenerator& gen);

+ 2 - 2
libalmond/src/ImageExport.cpp

@@ -56,8 +56,8 @@ void exportPng(const ImageExportInfo& iei, std::function<void(float)> progressCa
     long chunkHeight = height / 20;
     if (chunkHeight < 1)
         chunkHeight = 1;
-    if (width >= 4096 && chunkHeight > 64)
-        chunkHeight = 64;
+    while (width * chunkHeight > 512 * 512)
+        chunkHeight /= 2;
 
     auto rowPointers = std::make_unique<png_byte*[]>(chunkHeight);
     for (long chunkY = 0; chunkY < height; chunkY += chunkHeight) {

+ 1 - 3
libalmond/src/MandelVideoGenerator.cpp

@@ -179,10 +179,8 @@ Bitmap<RGBColor> MandelVideoGenerator::overlay(const Bitmap<RGBColor>& outer,
     double innerWidth = outer.width * scale / oversizeFactor;
     double innerHeight = outer.height * scale / oversizeFactor;
 
-            double lerpVal = ::log(1.0 / scale) / ::log(oversizeFactor);
-            printf("lerpval: %f\n", lerpVal);
     auto before = std::chrono::high_resolution_clock::now();
-#pragma omp parallel for schedule(static, 1)
+#pragma omp parallel for schedule(static, 32)
     for (int i = 0; i < ret.height; i++) {
         for (int j = 0; j < ret.width; j++) {
             double newJ = outerLeft + outerWidth * j / ret.width;

+ 18 - 10
mandelvid/src/main.cpp

@@ -6,38 +6,45 @@
 
 
 int main() {
-    //mnd::MandelContext mndCtxt = mnd::initializeContext();
+    mnd::MandelContext mndCtxt = mnd::initializeContext();
 
 
     ExportVideoInfo evi;
     
     evi.start = mnd::MandelViewport::standardView();
-    evi.end = mnd::MandelViewport {
+    /*evi.end = mnd::MandelViewport {
         mnd::Real("-1.5016327722130767973008541252724123393337183519056236025189105693015282429244791506194548898968185999262221668435271537932672968559900159142085320685031"),
         mnd::Real("9.1949171527697821768939276268368163504538591789778359909730511642378316080598664365235178721745031546786105261407973733873085119833457073054327967448264e-06"),
         mnd::Real("1.6236294899543021550377844129369984149698872979955210084321757728274664401182171658849308001321609757279087031477100527629814577654596624031152718524352e-10"),
         mnd::Real("1.2246019034401093377903721086780361028058704962292211685926779200766324399350798858672587301860274703389823933260119617558370004128301410779021141722617e-10")
+    };*/
+    evi.end = mnd::MandelViewport {
+        mnd::Real("-2.0"),
+        mnd::Real("-1.0"),
+        mnd::Real("1.0e-3"),
+        mnd::Real("1.0e-3")
     };
     //evi.end.zoomCenter(1.0e+27);
     evi.gradient = Gradient::defaultGradient();
 
-    evi.width = 64;
-    evi.height = 64;
-    evi.maxIterations = 5000;
-    evi.fps = 30;
-    evi.zoomSpeed = 1.3;
+    evi.mi.bWidth = 1280;
+    evi.mi.bHeight = 720;
+    evi.mi.maxIter = 1000;
+    evi.fps = 60;
+    evi.zoomSpeed = 1.0;
     evi.path = "video.avi";
     evi.bitrate = 1500;
     evi.preset = "veryfast";
 
-    evi.start.adjustAspectRatio(evi.width, evi.height);
+    evi.start.adjustAspectRatio(evi.mi.bWidth, evi.mi.bHeight);
 
-    //MandelVideoGenerator mvg(evi);
+    MandelVideoGenerator mvg(evi);
 
-    //mvg.generate();
+    mvg.generate(mndCtxt.getDefaultGenerator());
     //
     
 
+/*
     mnd::MandelContext mc = mnd::initializeContext();
     mnd::MandelInfo mi;
     mi.view = evi.start;
@@ -50,6 +57,7 @@ int main() {
     iei.gradient = &evi.gradient;
     iei.generator = &mc.getDefaultGenerator();
     alm::exportPng("file.png", iei);
+*/
 
     return 0;
 }