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>
4
5namespace sf
6{
7
11class QDESIGNER_WIDGET_EXPORT OpenGLRenderer : public QObject
12{
13 public:
18 explicit OpenGLRenderer(OpenGLWidget* widget, QOpenGLShaderProgram* sp);
19
23 ~OpenGLRenderer() override = default;
24
28 static void initialize(OpenGLWidget* widget);
29
33 bool setup();
34
38 void render();
39
44
48 virtual void changedProperty() = 0;
49
55 virtual void setIndexValue(int index, QVariant value) = 0;
56
57 protected:
61 virtual void generate() = 0;
62
66 virtual void paint() = 0;
67
71 virtual void draw() = 0;
72
76 const QMatrix4x4& _projectionMatrix;
80 const QMatrix4x4& _cameraMatrix;
84 const QMatrix4x4& _lightPositionMatrix;
88 const QMatrix4x4& _lightDirectionMatrix;
92 const QMatrix4x4& _modelMatrix;
93
94 private:
98 QOpenGLShaderProgram* _shader;
102 OpenGLWidget* _widget;
107 bool _flagPaintOnly;
108};
109
110}// namespace sf
Pure virtual class to implement rendering separated from the widget and makes the sf::OpenGLWidget th...
Definition OpenGLRenderer.h:12
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:84
const QMatrix4x4 & _projectionMatrix
Easy of access reference to the projection matrix from the widget.
Definition OpenGLRenderer.h:76
virtual void changedProperty()=0
Called by sf::OpenGLWidget when a property has changed.
virtual void paint()=0
Called by from the render() method.
const QMatrix4x4 & _lightDirectionMatrix
Easy of access reference to the light direction matrix from the sf::OpenGLWidget.
Definition OpenGLRenderer.h:88
OpenGLWidget * getWidget() const
Gets the owning widget which is calling the shots.
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:92
void render()
Call overridden method render() after teh shader program has been linked.
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:80
virtual void generate()=0
Called by setup() and (re-)generates the vertices for the drawn 3D-objects.
bool setup()
Call overridden method generate() after teh shader program has been linked.
Widget for rendering a OpenGHL scene.
Definition OpenGLWidget.h:30
Definition Application.h:10