-
Notifications
You must be signed in to change notification settings - Fork 1
/
glwidget.h
54 lines (46 loc) · 1.02 KB
/
glwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <QWidget>
#include <QMatrix4x4>
#include <QMessageBox>
#include <GL/glew.h>
#include <QOpenGLWidget>
#include <QTime>
#include "vec.h"
class GLWidget : public QOpenGLWidget
{
Q_OBJECT
public:
explicit GLWidget(QWidget *parent = nullptr);
~GLWidget();
private:
GLuint current_shader;
GLfloat time;
std::vector<vec3> verts;
std::vector<vec2> uvs;
std::vector<vec3> normals;
std::vector<unsigned> elems[3];
// element arrays for modelspace vertices, UVs and normals
GLuint vertexArray;
GLuint vertexBuffers[3];
GLuint elementBuffers[3];
GLuint texture;
bool hasUVs = false, hasNormals = false;
void initializeGL();
void paintGL();
void normalize();
// for testing:
QMatrix4x4 rotation;
public slots:
void compileShader(std::string, std::string);
void reset();
void loadTexture(QString);
void loadModel(QString);
signals:
void shaderError(QString);
};
#endif // GLWIDGET_H