Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
OpenGLRenderObject.h
Go to the documentation of this file.
1#pragma once
2#include <QColor>
3#include <QMatrix4x4>
4#include <QOpenGLVertexArrayObject>
5#include <QtUiPlugin/QDesignerExportWidget>
6
7namespace sf
8{
9
10// Forward definition.
11class OpenGLRenderer;
12
16class QDESIGNER_WIDGET_EXPORT OpenGLRenderObject : public QObject
17{
18 Q_OBJECT
19
20 public:
24 typedef QList<OpenGLRenderObject*> List;
25
30 explicit OpenGLRenderObject(QObject* parent = nullptr);
31
36 void render(const std::function<void()>& cb);
37
41 void setVertexArray(QOpenGLVertexArrayObject*);
42
46 QOpenGLVertexArrayObject* vertexArray() const;
47
52 const QMatrix4x4& getMatrix(bool offset) const;
53
59 void setMatrix(const QMatrix4x4& mtx, bool is_offset);
60
64 QColor& color();
65
70 virtual bool isEnabled();
71
75 void setEnabled(bool flag);
76
80 Q_SIGNAL void rendering();
81
82 protected:
84 QOpenGLVertexArrayObject* _vertexArray;
86 QMatrix4x4 _matrix;
88 QMatrix4x4 _offset;
90 QColor _color;
93
94 Q_DISABLE_COPY(OpenGLRenderObject)
95};
96
97}// namespace sf
Renders an OpenGL object (vertex-array) in a color and using a transformation/translation matrix.
Definition OpenGLRenderObject.h:17
QColor _color
Holds the color to render when the object has no color of itself.
Definition OpenGLRenderObject.h:90
void setMatrix(const QMatrix4x4 &mtx, bool is_offset)
Sets the given matrix as transform or offset.
QOpenGLVertexArrayObject * _vertexArray
Holds the vertex array type derived object.
Definition OpenGLRenderObject.h:84
bool _enabled
Holds the flag weather it should be rendered or not.
Definition OpenGLRenderObject.h:92
OpenGLRenderObject(QObject *parent=nullptr)
Qt constructor.
void setEnabled(bool flag)
Sets the enable flag for this instance.
void render(const std::function< void()> &cb)
Render the object using a callback lambda function.
QOpenGLVertexArrayObject * vertexArray() const
Gets the assigned vertex array.
QList< OpenGLRenderObject * > List
Type to hold a list of not-owned render objects.
Definition OpenGLRenderObject.h:24
QMatrix4x4 _offset
Holds the additional matrix to offset the resulting matrix.
Definition OpenGLRenderObject.h:88
void setVertexArray(QOpenGLVertexArrayObject *)
Sets the assigned vertex array.
Q_SIGNAL void rendering()
Signal emitted just before the render() method is called.
QColor & color()
Gets the reference to the color to be modified.
QMatrix4x4 _matrix
Holds the matrix to transform and/or translate and defaults to a unit or identity matrix.
Definition OpenGLRenderObject.h:86
const QMatrix4x4 & getMatrix(bool offset) const
Gets the reference to the matrix.
virtual bool isEnabled()
Gets the reference to the enable flag. Can be overridden to implement otherwise.
Definition Application.h:10