Interactive Mandelbrot viewer with Qt and OpenGL.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
875 B

3 years ago
#include "../headers/Mandelbrot.h"
3 years ago
void Mandelbrot::init() {
3 years ago
initializeOpenGLFunctions();
3 years ago
3 years ago
vao = createVAO();
3 years ago
}
void Mandelbrot::draw() {
}
void Mandelbrot::zoom(double delta) {
3 years ago
scale *= delta;
}
3 years ago
3 years ago
void Mandelbrot::setIterations(int value) {
iterations = value;
3 years ago
}
3 years ago
3 years ago
GLuint Mandelbrot::createVAO() {
GLuint vboId;
glGenBuffers(1, &vboId);
glBindBuffer(GL_ARRAY_BUFFER, vboId);
float* vertices = genVertices();
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
GLuint vaoId;
glGenVertexArrays(1, &vaoId);
glBindVertexArray(vaoId);
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*) nullptr);
glEnableVertexAttribArray(0);
glBindVertexArray(0);
return vaoId;
}
float* Mandelbrot::genVertices() {
return new float[8]{
-1, -1,
1, -1,
1, 1,
-1, 1
};
}
3 years ago