-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.h
56 lines (40 loc) · 1.22 KB
/
model.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
55
56
#ifndef MODEL_H
#define MODEL_H
#include <assimp/Importer.hpp>
#include <QOpenGLBuffer>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject>
#include <QString>
class Model : QOpenGLFunctions
{
public:
Model(
const QString& objectFilePath,
const QString& fragmentShaderFilePath);
~Model();
void draw(
const QMatrix4x4& projectionMatrix,
const QMatrix4x4& viewMatrix,
const QMatrix4x4& gimbalAngle,
const float scaleFactor);
private:
QOpenGLVertexArrayObject vao;
// Vertex- and index buffer objects
QOpenGLBuffer vbo;
QOpenGLBuffer ibo;
unsigned int iboLength = 0;
// Vertex and fragment shader program
QOpenGLShaderProgram* shaderProgram;
// Object owner
Assimp::Importer importer;
// Loads the contents of an object file into the importer
void loadObjectFromFile(const QString& objectFilePath);
// Generates a VBO/IBO from a loaded model
void generateVBO(GLfloat* const vbo) const;
void generateIBO(GLuint* const ibo) const;
// Calculates the length of the aggregated VBO/IBO
unsigned int lengthOfVBO() const;
unsigned int lengthOfIBO() const;
};
#endif // MODEL_H