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 public:
24 OpenGLRenderObject(QObject* parent = nullptr);
25
30 void render(const std::function<void()>& cb);
31
35 void setVertexArray(QOpenGLVertexArrayObject*);
36
40 QOpenGLVertexArrayObject* vertexArray();
41
45 QMatrix4x4& matrix();
46
50 QColor& color();
51
56 virtual bool isEnabled();
57
61 void setEnabled(bool flag);
62
66 Q_SIGNAL void rendering();
67
68 protected:
70 QOpenGLVertexArrayObject* _vertexArray;
72 QMatrix4x4 _matrix;
74 QColor _color;
77
78 Q_DISABLE_COPY(OpenGLRenderObject)
79};
80
81}// 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:74
QOpenGLVertexArrayObject * vertexArray()
Gets the assigned vertex array.
QOpenGLVertexArrayObject * _vertexArray
Holds the vertex array type derived object.
Definition OpenGLRenderObject.h:70
bool _enabled
Holds the flag weather it should be rendered or not.
Definition OpenGLRenderObject.h:76
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.
QMatrix4x4 & matrix()
Gets the reference to the matrix to be modified.
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:72
virtual bool isEnabled()
Gets the reference to the enable flag. Can be overridden to implement otherwise.
Definition Application.h:10