src/gl/vertexprogram.h

Wed, 22 Sep 2021 00:25:13 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 22 Sep 2021 00:25:13 +0300
changeset 134
f77d2230e87c
parent 119
24275a4064f4
child 200
ca23936b455b
permissions
-rw-r--r--

Add remaining serialize methods

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"
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 class Document;
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);
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 void build(const Document* document);
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