Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
OpenGLRenderer.h
Go to the documentation of this file.
1#pragma once
2#include <QOpenGLShaderProgram>
5
6namespace sf
7{
8
12class QDESIGNER_WIDGET_EXPORT OpenGLRenderer : public QObject
13{
14 Q_OBJECT
15
16 public:
21 explicit OpenGLRenderer(OpenGLWidget* widget, QOpenGLShaderProgram* sp);
22
26 ~OpenGLRenderer() override = default;
27
31 static void initialize(OpenGLWidget* widget);
32
36 bool setup();
37
41 void render();
42
47
51 QOpenGLShaderProgram* getShaderProgram() const;
52
56 virtual void changedProperty() = 0;
57
65 virtual void addRenderObject(OpenGLRenderObject* ro, bool append = true);
66
72 virtual void setIndexValue(int index, QVariant value) = 0;
73
77 Q_SIGNAL void rendering();
78
79 protected:
83 virtual void generate() = 0;
84
88 virtual void paint() = 0;
89
93 virtual void draw() = 0;
94
102 const QMatrix4x4& _projectionMatrix;
106 const QMatrix4x4& _cameraMatrix;
110 const QMatrix4x4& _lightPositionMatrix;
114 const QMatrix4x4& _lightDirectionMatrix;
118 const QMatrix4x4& _modelMatrix;
119
120 private:
124 QOpenGLShaderProgram* _shader;
128 OpenGLWidget* _widget;
133 bool _flagPaintOnly;
134};
135
136}// namespace sf
Renders an OpenGL object (vertex-array) in a color and using a transformation/translation matrix.
Definition OpenGLRenderObject.h:17
QList< OpenGLRenderObject * > List
Type to hold a list of not-owned render objects.
Definition OpenGLRenderObject.h:24
Pure virtual class to implement rendering separated from the widget and makes the sf::OpenGLWidget th...
Definition OpenGLRenderer.h:13
virtual void setIndexValue(int index, QVariant value)=0
Sets an arbitrary value on the derived- or subclass.
const QMatrix4x4 & _lightPositionMatrix
Easy of access reference to the light position matrix from the sf::OpenGLWidget.
Definition OpenGLRenderer.h:110
const QMatrix4x4 & _projectionMatrix
Easy of access reference to the projection matrix from the widget.
Definition OpenGLRenderer.h:102
virtual void changedProperty()=0
Called by sf::OpenGLWidget when a property has changed.
virtual void paint()=0
Called by from the render() method.
OpenGLRenderObject::List _renderObjects
Holds the list of objects to render.
Definition OpenGLRenderer.h:98
const QMatrix4x4 & _lightDirectionMatrix
Easy of access reference to the light direction matrix from the sf::OpenGLWidget.
Definition OpenGLRenderer.h:114
OpenGLWidget * getWidget() const
Gets the owning widget which is calling the shots.
virtual void addRenderObject(OpenGLRenderObject *ro, bool append=true)
Adds an object to be rendered. The order of addition determines the outcome when transparency is invo...
OpenGLRenderer(OpenGLWidget *widget, QOpenGLShaderProgram *sp)
Constructor passing the widget which has the OpenGL context. The owner is the shader program object.
virtual void draw()=0
Called by from the render() method.
~OpenGLRenderer() override=default
Virtual destructor.
const QMatrix4x4 & _modelMatrix
Easy of access reference to the model matrix from the sf::OpenGLWidget.
Definition OpenGLRenderer.h:118
void render()
Call overridden method render() after the shader program has been linked.
Q_SIGNAL void rendering()
Signal emitted at the start of the render() method.
static void initialize(OpenGLWidget *widget)
Called by sf::OpenGLWidget::initializeGL to initialize the OpenGL context for derived classes.
const QMatrix4x4 & _cameraMatrix
Easy of access reference to the camera matrix from the sf::OpenGLWidget.
Definition OpenGLRenderer.h:106
QOpenGLShaderProgram * getShaderProgram() const
Gets shader program given in the constructor.
virtual void generate()=0
Called by setup() and (re-)generates the vertices for the drawn 3D-objects.
bool setup()
Call overridden method generate() after the shader program has been linked.
Widget for rendering an OpenGL scene.
Definition OpenGLWidget.h:30
Definition Application.h:10