blob: 92597841a31496e350ae7ae4e6eb1278f287f261 (
plain)
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
|
#ifndef OPENGL_WIDGET_HH
#define OPENGL_WIDGET_HH
#include "opengl_mesh.hh"
#include <QOpenGLWidget>
#include <QMatrix4x4>
#include <QOpenGLFunctions_4_4_Core>
#include <QOpenGLShaderProgram>
#define FOV 70
class OpenGLWidget : public QOpenGLWidget, public QOpenGLFunctions_4_4_Core {
Q_OBJECT
GLuint pos_attr, proj_attr, view_attr, model_attr;
QMatrix4x4 rot, rot_start;
GLfloat cam_dist = 1;
QPoint mouse_pos;
protected:
virtual void mousePressEvent(QMouseEvent *e);
virtual void mouseReleaseEvent(QMouseEvent *e);
virtual void mouseMoveEvent(QMouseEvent *e);
virtual void wheelEvent(QWheelEvent *e);
public:
static OpenGLWidget *instance;
QVector<OpenGLMesh> meshes;
OpenGLWidget(QWidget *parent=nullptr);
~OpenGLWidget();
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
signals:
void initialized();
};
#endif
|