VoxelBlur
Depth-of-field volume rendering
|
A QWindow derivative capable of OpenGL drawing. More...
#include <glwindow.h>
Public Slots | |
void | setAnimating (bool animating) |
Enables/disables animation mode. More... | |
void | renderLater () |
Queues a render request using the Qt event queue, to be executed at a later time. More... | |
void | renderNow () |
Makes sure everything is correctly initialized, calls render and does buffer-swapping afterwards. More... | |
Signals | |
void | initializeFailed (const QString &error) |
This signal is sent when the context creation has failed, or the initialize function returned an error. More... | |
Public Member Functions | |
GLWindow (QWindow *parent=nullptr) | |
QWidget * | createWindowContainer (QWidget *parent=nullptr, Qt::WindowFlags flags=nullptr) |
Creates a window container from this GLWindow . More... | |
bool | isAnimating () const |
Gets if the window is currently in animation mode. More... | |
QSurfaceFormat | format () const override |
Returns the currently used surface format. More... | |
Protected Member Functions | |
bool | event (QEvent *event) override |
void | exposeEvent (QExposeEvent *event) override |
virtual bool | initialize () |
Provides a convenient point for subclasses to initialize. More... | |
virtual void | render () |
Subclasses should implement this to render the window content. More... | |
Protected Attributes | |
bool | m_error |
Set to true if error occured making rendering impossible. | |
QOpenGLContext * | m_context |
The OpenGL context used for this window. More... | |
Private Attributes | |
bool | m_update_pending |
bool | m_animating |
bool | m_initializing |
A QWindow derivative capable of OpenGL drawing.
Modeled after http://qt-project.org/doc/qt-5/qtgui-openglwindow-example.html with some changes.
Before the window is first shown (before create
is called), make sure to set a good surface format by calling setFormat
. The window uses its own OpenGL rendering context, which uses the specified format. The window owns the context, so it is no longer available after the window is destroyed.
Can be used as a widget by using createWindowContainer. All subclasses get automatic access to OpenGL ES 2.0 functions.
QWidget * GLWindow::createWindowContainer | ( | QWidget * | parent = nullptr , |
Qt::WindowFlags | flags = nullptr |
||
) |
|
inlineoverride |
Returns the currently used surface format.
This is the format of the QOpenGLContext
if it exists, otherwise the requestedFormat is returned.
|
protectedvirtual |
Provides a convenient point for subclasses to initialize.
Is guaranteed to be called before the window is first rendered. The default implementation does nothing. Subclasses should return false on error, and also emit initializeFailed with a user-readable message. /return false if error occurred during initialization
Reimplemented in VolumeRenderWindow.
|
signal |
This signal is sent when the context creation has failed, or the initialize function returned an error.
The window is unusable in this case.
error | an error string suitable for user display |
|
inline |
Gets if the window is currently in animation mode.
|
protectedvirtual |
Subclasses should implement this to render the window content.
The caller has to assure that the GL context is bound and everything is initialized, an easy way to do this is to call renderNow. The default implementation just draws a red background.
Reimplemented in VolumeRenderWindow.
|
slot |
Queues a render request using the Qt event queue, to be executed at a later time.
Call this after updating drawing parameters. The request will call renderNow.
|
slot |
Makes sure everything is correctly initialized, calls render and does buffer-swapping afterwards.
This method has no effect if the window is not exposed. Additionally, if an error occured during initialization, nothing will be done.
|
inlineslot |
Enables/disables animation mode.
In animation mode, the window is continually rendering. This is done by calling renderLater after each renderNow call has finished, causing continuous rendering requests until setAnimating(false)
is called. Note that this method is unsuitable for high-performance, low-delay animations like games.
|
protected |
The OpenGL context used for this window.
Not available until first call to renderNow.