GeometryEngine.h 930 Bytes
Newer Older
Anakin's avatar
Anakin committed
1
#pragma once
Anakin's avatar
Anakin committed
2
#include <QObject>
3
4
5
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
Anakin's avatar
Anakin committed
6
#include <QVector>
7
8
#include "FileInterface.h"

9

Anakin's avatar
Anakin committed
10
11
12
13
14
15
16
struct DrawInformation {
	unsigned int offset;
	unsigned int size;
	unsigned int textureIndex;
	QMatrix4x4 modelMatrix;
};

Anakin's avatar
Anakin committed
17
class GeometryEngine : public QObject, protected QOpenGLFunctions
18
{
Anakin's avatar
Anakin committed
19
20
	Q_OBJECT

21
public:
22
	GeometryEngine(QObject *parent = Q_NULLPTR);
Anakin's avatar
Anakin committed
23
	virtual ~GeometryEngine();
24

25
// attributes
26
private:
Anakin's avatar
Anakin committed
27
28
	QOpenGLBuffer m_arrayBuf;
	QOpenGLBuffer m_indexBuf;
29
	QVector<Material>* m_materials = Q_NULLPTR;
Anakin's avatar
Anakin committed
30
	Material* m_defaultMaterial;
31
32
	BoundingBox m_boundings;
	QVector<DrawInformation> m_drawList;
Anakin's avatar
Anakin committed
33

34
35
// functions
private:
Anakin's avatar
Anakin committed
36
	void clearData();
37
	void setupPipeline(QOpenGLShaderProgram * program);
Anakin's avatar
Anakin committed
38

39
public:
Anakin's avatar
Anakin committed
40
	void drawGeometry(QOpenGLShaderProgram *program);
Anakin's avatar
Anakin committed
41
	void loadFile(QString filePath);
Anakin's avatar
Anakin committed
42

43
// signals
Anakin's avatar
Anakin committed
44
45
signals:
	void requestResetView();
46
	void requestUpdate();
47
48
};