src/gl/vertexprogram.h

Sun, 26 Jun 2022 21:00:06 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 26 Jun 2022 21:00:06 +0300
changeset 263
59b6027b9843
parent 214
8e1fe64ce4e3
permissions
-rw-r--r--

Move render layer files to new src/layers/ directory

118
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #ifndef VERTEXPROGRAM_H
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 #define VERTEXPROGRAM_H
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3 #include "basicshaderprogram.h"
214
8e1fe64ce4e3 begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 200
diff changeset
4 class VertexMap;
118
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 class VertexProgram : public AbstractBasicShaderProgram
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 {
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 public:
119
Teemu Piippo <teemu@hecknology.net>
parents: 118
diff changeset
9 enum FragmentStyle
Teemu Piippo <teemu@hecknology.net>
parents: 118
diff changeset
10 {
Teemu Piippo <teemu@hecknology.net>
parents: 118
diff changeset
11 Normal,
Teemu Piippo <teemu@hecknology.net>
parents: 118
diff changeset
12 Id
Teemu Piippo <teemu@hecknology.net>
parents: 118
diff changeset
13 };
118
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 struct Vertex
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 {
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 glm::vec3 position;
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 glm::vec3 color;
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18 };
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 VertexProgram(QObject* parent = nullptr);
214
8e1fe64ce4e3 begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 200
diff changeset
20 void build(const VertexMap* document);
118
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 protected:
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22 const char* vertexShaderSource() const override;
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 const char* fragmentShaderSource() const override;
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 const void* vertexData() const override;
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
25 int vertexSize() const override;
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
26 int vertexCount() const override;
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
27 void setupVertexArrays() override;
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 GLenum drawMode() const override;
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 QOpenGLBuffer::UsagePattern usagePattern() const override;
119
Teemu Piippo <teemu@hecknology.net>
parents: 118
diff changeset
30 void setFragmentStyle(FragmentStyle newFragmentStyle);
118
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31 private:
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32 std::vector<Vertex> data;
119
Teemu Piippo <teemu@hecknology.net>
parents: 118
diff changeset
33 FragmentStyle fragmentStyle = Normal;
118
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34 };
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
35
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
36 #endif // VERTEXPROGRAM_H

mercurial