master
Benjamin Kraft 3 years ago
parent 7486e1f3bf
commit 2d8b0edb4a
  1. 2
      headers/MainWindow.h
  2. 17
      headers/Mandelbrot.h
  3. 7
      headers/OutputWidget.h
  4. 14
      src/Mandelbrot.cpp
  5. 14
      src/OutputWidget.cpp

@ -12,7 +12,7 @@ private slots:
private:
void buildUI();
OutputWidget* outputWidget = new OutputWidget;
OutputWidget* outputWidget = new OutputWidget(this);
};

@ -0,0 +1,17 @@
#pragma once
#include <QVector2D>
#include <QOpenGLFunctions>
class Mandelbrot : protected QOpenGLFunctions {
public:
Mandelbrot();
void draw();
void zoom(double);
private:
double scale;
QVector2D translation;
};

@ -5,9 +5,12 @@
#include <QWidget>
#include <QOpenGLFunctions>
#include <QOpenGLWidget>
#include "Mandelbrot.h"
class OutputWidget : public QOpenGLWidget, public QOpenGLFunctions {
class OutputWidget : public QOpenGLWidget, protected QOpenGLFunctions {
Q_OBJECT
public:
explicit OutputWidget(QWidget* parent): QOpenGLWidget(parent) {};
private:
void initializeGL() override;
void paintGL() override;
@ -18,6 +21,8 @@ private:
void mousePressEvent(QMouseEvent*) override;
void mouseReleaseEvent(QMouseEvent*) override;
void keyPressEvent(QKeyEvent*) override;
Mandelbrot mandelbrot;
};

@ -0,0 +1,14 @@
#include "../headers/Mandelbrot.h"
Mandelbrot::Mandelbrot() {
initializeOpenGLFunctions();
}
void Mandelbrot::draw() {
}
void Mandelbrot::zoom(double delta) {
}

@ -2,19 +2,23 @@
#include <iostream>
#include "../headers/OutputWidget.h"
using std::cout, std::endl;
void OutputWidget::initializeGL() {
cout << "Initialize OpenGL" << endl;
initializeOpenGLFunctions();
std::cout << "Initialize GL" << std::endl;
auto format = this->format();
std::cout << "OpenGL version: " <<
cout << "OpenGL version: " <<
format.majorVersion() << "." << format.minorVersion()
<< std::endl;
<< endl;
::glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
}
void OutputWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT);
mandelbrot.draw();
}
void OutputWidget::resizeGL(int w, int h) {

Loading…
Cancel
Save