-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrendermesh.h
77 lines (58 loc) · 1.64 KB
/
rendermesh.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef RENDERMESH_H
#define RENDERMESH_H
#include "mesh.h"
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QOpenGLBuffer>
using namespace std;
struct RenderVertex{
QVec3 position;
QVec3 normal;
QVec2 texcoord;
};
class RenderMesh: protected QOpenGLFunctions
{
public:
RenderMesh(Mesh * mesh);
virtual ~RenderMesh();
virtual void update() = 0;
virtual void draw(QMat4 view, QMat4 projection, bool depth = 0) = 0;
protected:
void initialize();
void DepthMode(bool depth_mode_);
virtual void initColorShader() = 0;
virtual void initDepthShader() = 0;
protected:
Mesh * mesh_;
std::vector<RenderVertex> vertices_;
QOpenGLBuffer arrayBuffer;
QOpenGLBuffer indexBuffer;
unique_ptr<QOpenGLShaderProgram> shader_;
};
class TextureRenderMesh : public RenderMesh
{
public:
TextureRenderMesh(Mesh * mesh, QString textrue_path);
virtual ~TextureRenderMesh();
void initTexture(QString textrue_path);
virtual void update() override;
virtual void initColorShader() override;
virtual void initDepthShader() override;
virtual void draw(QMat4 view, QMat4 projection, bool depth = 0) override;
private:
unique_ptr<QOpenGLTexture> texture_;
};
class SimpleRenderMesh : public RenderMesh
{
public:
SimpleRenderMesh(Mesh * mesh, QColor color);
virtual ~SimpleRenderMesh();
virtual void update() override;
virtual void initColorShader() override;
virtual void initDepthShader() override;
virtual void draw(QMat4 view, QMat4 projection, bool depth = 0) override;
private:
QColor color_;
};
#endif // RENDERMESH_H