Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
VertexArrayBase.h
Go to the documentation of this file.
1#pragma once
2#include <QOpenGLShaderProgram>
3#include <QOpenGLVertexArrayObject>
4#include <misc/gen/TVector.h>
5#include <xgl/Color.h>
6#include <xgl/global.h>
7
8namespace sf::xgl
9{
10
14class _XGL_CLASS VertexArrayBase : public QOpenGLVertexArrayObject
15{
16 Q_OBJECT
17
18 public:
22 typedef unsigned VertexMember;
23
29 {
31 vmPosition = 1 << 0,
33 vmNormal = 1 << 1,
35 vmColor = 1 << 2,
37 vmTexCoord = 1 << 3,
38 };
39
44 {
48 dmDrawElements
49 };
50
54 enum ERenderOption : int
55 {
57 roNone = 0,
59 roWires = 1 << 0,
61 roNormals = 1 << 1
62 };
63 Q_DECLARE_FLAGS(RenderOptions, ERenderOption)
64
65
69 explicit VertexArrayBase(QOpenGLShaderProgram* parent);
70
75 virtual void draw() = 0;
76
80 virtual void paint() = 0;
81
86 virtual bool hasColor() const = 0;
87
92 virtual bool hasTexture() const = 0;
93
108 static const Color& getDefaultColor();
109
113 static void setDefaultColor(const QColor& color);
114
119
123 virtual NormalsDataType getNormalsData() const = 0;
124
128 void triggerGenerate();
129
133 void setRenderOptions(RenderOptions options);
134
138 RenderOptions getRenderOptions() const;
139
140 protected:
144 virtual bool setup() = 0;
145
149 virtual void clearData() = 0;
150
154 bool callGenerate();
155
160 virtual void generate() = 0;
161
168 virtual void modifyContext(bool before, bool draw, size_t mode_index);
169
175 bool isTriggered() const;
176
177 private:
181 bool _triggerGenerate;
182
186 RenderOptions _renderOptions;
187};
188
189}// namespace sf::xgl
Counted vector having additional methods and operators for ease of usage. This template class extends...
Definition TVector.h:19
Color class used in vertex arrays and a layout of 4 x GLfloat.
Definition Color.h:14
Base class for vertex-array derived classes.
Definition VertexArrayBase.h:15
EVertexMember
Possible member of a vertex structure. Where the position cannot be omitted as part of the vertex.
Definition VertexArrayBase.h:29
TVector< std::pair< vector3f, vector3f > > NormalsDataType
Type for extracting normals from all used vertices.
Definition VertexArrayBase.h:118
ERenderOption
Render options.
Definition VertexArrayBase.h:55
EDrawMode
Drawing mode of by the template.
Definition VertexArrayBase.h:44
@ dmDrawArrays
Definition VertexArrayBase.h:46
unsigned VertexMember
Type used to describe vertex structure members.
Definition VertexArrayBase.h:22
Definition DemoRenderer.h:6
std::array< GLfloat, 3 > vector3f
Type which corresponds with a GLSL type and used to implement Vertex structures.
Definition Types.h:21
#define _XGL_CLASS
Definition xgl/global.h:35