VoxelBlur
Depth-of-field volume rendering
 All Classes Files Functions Variables Enumerations Enumerator
glwindow.h
Go to the documentation of this file.
1 #ifndef GLWINDOW_H
2 #define GLWINDOW_H
3 
4 #include <QWindow>
5 
23 class GLWindow : public QWindow, protected QOpenGLFunctions
24 {
25  Q_OBJECT
26 
27 public:
28  explicit GLWindow(QWindow *parent = nullptr);
29  ~GLWindow();
30 
39  QWidget* createWindowContainer(QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr);
40 
45  bool isAnimating() const { return m_animating; }
46 
50  QSurfaceFormat format() const override { return m_context ? m_context->format() : requestedFormat(); }
51 
52 signals:
58  void initializeFailed(const QString& error);
59 
60 public slots:
68  void setAnimating(bool animating) { m_animating = animating; if(animating) renderLater(); }
69 
74  void renderLater();
79  void renderNow();
80 
81 protected:
85  bool m_error;
86 
87  bool event(QEvent *event) override;
88  //the window draws when exposed
89  void exposeEvent(QExposeEvent *event) override;
90 
99  virtual bool initialize();
100 
106  virtual void render();
107 
112  QOpenGLContext* m_context;
113 
114 private:
115  bool m_update_pending,m_animating,m_initializing;
116 
117 };
118 
119 #endif // GLWINDOW_H
void initializeFailed(const QString &error)
This signal is sent when the context creation has failed, or the initialize function returned an erro...
QOpenGLContext * m_context
The OpenGL context used for this window.
Definition: glwindow.h:112
bool isAnimating() const
Gets if the window is currently in animation mode.
Definition: glwindow.h:45
void renderNow()
Makes sure everything is correctly initialized, calls render and does buffer-swapping afterwards...
Definition: glwindow.cpp:42
QWidget * createWindowContainer(QWidget *parent=nullptr, Qt::WindowFlags flags=nullptr)
Creates a window container from this GLWindow.
Definition: glwindow.cpp:124
void renderLater()
Queues a render request using the Qt event queue, to be executed at a later time. ...
Definition: glwindow.cpp:33
void setAnimating(bool animating)
Enables/disables animation mode.
Definition: glwindow.h:68
bool m_error
Set to true if error occured making rendering impossible.
Definition: glwindow.h:85
QSurfaceFormat format() const override
Returns the currently used surface format.
Definition: glwindow.h:50
virtual bool initialize()
Provides a convenient point for subclasses to initialize.
Definition: glwindow.cpp:20
virtual void render()
Subclasses should implement this to render the window content.
Definition: glwindow.cpp:26
A QWindow derivative capable of OpenGL drawing.
Definition: glwindow.h:23