OglViewerWidget.h 1.04 KB
Newer Older
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
#pragma once

#include "geometryengine.h"

#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QMatrix4x4>
#include <QQuaternion>
#include <QVector2D>
#include <QBasicTimer>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>

class GeometryEngine;

class OglViewerWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
	Q_OBJECT

public:
	explicit OglViewerWidget(QWidget *parent = 0);
	~OglViewerWidget();

protected:
	void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
	void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
27
28
	void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
	void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
29
30
31
32
33
34
35
36
37

	void initializeGL() Q_DECL_OVERRIDE;
	void resizeGL(int w, int h) Q_DECL_OVERRIDE;
	void paintGL() Q_DECL_OVERRIDE;

	void initShaders();
	void initTextures();

private:
38
39
40
41
42
	struct {
		bool left = false;
		bool right = false;
		QVector2D position;
	} m_mouse;
43
44
45
46
47
	QOpenGLShaderProgram program;
	GeometryEngine *geometries;

	QOpenGLTexture *texture;

48
49
	QMatrix4x4 m_projection;
	QQuaternion m_rotation;
50
51
};