VoxelBlur
Depth-of-field volume rendering
 All Classes Files Functions Variables Enumerations Enumerator
Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
GLWindow Class Reference

A QWindow derivative capable of OpenGL drawing. More...

#include <glwindow.h>

Inheritance diagram for GLWindow:
Inheritance graph
[legend]
Collaboration diagram for GLWindow:
Collaboration graph
[legend]

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
 

Detailed Description

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.

See Also
http://www.khronos.org/opengles/2_X/

Member Function Documentation

QWidget * GLWindow::createWindowContainer ( QWidget *  parent = nullptr,
Qt::WindowFlags  flags = nullptr 
)

Creates a window container from this GLWindow.

Just calls QWidget::createWindowContainer with the specified parameters.

Parameters
parentthe parent of the returned widget.
flagsthe window flags to be used
Returns
a new widget which is a container for this GLWindow
QSurfaceFormat GLWindow::format ( ) const
inlineoverride

Returns the currently used surface format.

This is the format of the QOpenGLContext if it exists, otherwise the requestedFormat is returned.

bool GLWindow::initialize ( )
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.

Here is the caller graph for this function:

void GLWindow::initializeFailed ( const QString &  error)
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.

Parameters
erroran error string suitable for user display

Here is the caller graph for this function:

bool GLWindow::isAnimating ( ) const
inline

Gets if the window is currently in animation mode.

See Also
setAnimating
void GLWindow::render ( )
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.

Here is the caller graph for this function:

void GLWindow::renderLater ( )
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.

Here is the caller graph for this function:

void GLWindow::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.

Here is the call graph for this function:

void GLWindow::setAnimating ( bool  animating)
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.

Here is the call graph for this function:

Member Data Documentation

QOpenGLContext* GLWindow::m_context
protected

The OpenGL context used for this window.

Not available until first call to renderNow.


The documentation for this class was generated from the following files: