Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Gui::WindowQt Class Reference

Base class for OpenGL widgets, compatble with Qt and globjects/glbindings. More...

#include <Gui/Viewer/WindowQt.hpp>

+ Inheritance diagram for Ra::Gui::WindowQt:
+ Collaboration diagram for Ra::Gui::WindowQt:

Public Slots

void cleanupGL ()
 call deinitializeGL if needed, with context activated
 
void screenChanged ()
 

Signals

void dpiChanged ()
 Emitted when physical device changes. Useful for tracking devicePixelRatio() change.
 

Public Member Functions

 WindowQt (QScreen *screen)
 
void resizeEvent (QResizeEvent *event) override
 
void showEvent (QShowEvent *event) override
 
void exposeEvent (QExposeEvent *event) override
 
virtual void enterEvent (QEvent *event)
 paintgl is done by main rendering loop
 
virtual void leaveEvent (QEvent *event)
 
void makeCurrent ()
 
void doneCurrent ()
 
ScopedGLContext activateScopedContext ()
 
QOpenGLContext * context ()
 
bool isOpenGlInitialized () const
 

Protected Member Functions

void initialize ()
 
void resizeInternal (QResizeEvent *event)
 
virtual bool initializeGL ()
 Initialize the openGL related part of the Window.
 
virtual void deinitializeGL ()
 DeInitialize the OpenGL.
 
virtual void resizeGL (QResizeEvent *event)
 Resize the OpenGL related part of the Window.
 

Static Protected Member Functions

static glbinding::ProcAddress getProcAddress (const char *name)
 

Protected Attributes

std::unique_ptr< QOpenGLContext > m_context
 
bool m_updatePending
 
std::atomic_bool m_glInitialized
 

Detailed Description

Base class for OpenGL widgets, compatble with Qt and globjects/glbindings.

Note
This class has been extracted from globjects example https://github.com/cginternals/globjects/blob/master/source/examples/qtexample/WindowQt.h

Definition at line 27 of file WindowQt.hpp.

Constructor & Destructor Documentation

◆ WindowQt()

Ra::Gui::WindowQt::WindowQt ( QScreen * screen)
explicit

Definition at line 28 of file WindowQt.cpp.

◆ ~WindowQt()

Ra::Gui::WindowQt::~WindowQt ( )
virtual

Definition at line 52 of file WindowQt.cpp.

Member Function Documentation

◆ activateScopedContext()

WindowQt::ScopedGLContext Ra::Gui::WindowQt::activateScopedContext ( )
inline

Make this->context() the current context for current block. The context is released when the return variable is destroyed. The "context object" uses this->makeCurrent() and this->doneCurrent(), hence it's compatible with enclosed scopes, and only the first created context object dtor eventually release OpenGL context.

Example

if(test){
auto context = viewer->activateScopedContext();
// here OpenGL context is bound
Texture tex;
// [...] do tex setup
tex->initializeGL();
// [...] use tex ...
} // block exit will first call tex dtor (with active context) then context dtor.
QOpenGLContext * context()
Definition WindowQt.cpp:76

Definition at line 154 of file WindowQt.hpp.

◆ cleanupGL

void Ra::Gui::WindowQt::cleanupGL ( )
slot

call deinitializeGL if needed, with context activated

Definition at line 160 of file WindowQt.cpp.

◆ context()

QOpenGLContext * Ra::Gui::WindowQt::context ( )
See also
https://doc.qt.io/qt-5/qglwidget.html#context

Definition at line 76 of file WindowQt.cpp.

◆ deinitializeGL()

void Ra::Gui::WindowQt::deinitializeGL ( )
protectedvirtual

DeInitialize the OpenGL.

Definition at line 170 of file WindowQt.cpp.

◆ doneCurrent()

void Ra::Gui::WindowQt::doneCurrent ( )

Release this->context(). This results in no context being current in the current thread. In case a context has been made current multiple times, this function just deacrease the internal counter by one.

See also
makeCurrent()
activateScopedContext() as an alternative

Definition at line 89 of file WindowQt.cpp.

◆ enterEvent()

void Ra::Gui::WindowQt::enterEvent ( QEvent * event)
virtual

paintgl is done by main rendering loop

Definition at line 176 of file WindowQt.cpp.

◆ exposeEvent()

void Ra::Gui::WindowQt::exposeEvent ( QExposeEvent * event)
override

Definition at line 98 of file WindowQt.cpp.

◆ getProcAddress()

glbinding::ProcAddress Ra::Gui::WindowQt::getProcAddress ( const char * name)
staticprotected

Definition at line 180 of file WindowQt.cpp.

◆ initialize()

void Ra::Gui::WindowQt::initialize ( )
protected

Definition at line 102 of file WindowQt.cpp.

◆ initializeGL()

bool Ra::Gui::WindowQt::initializeGL ( )
protectedvirtual

Initialize the openGL related part of the Window.

paint is done by main rendering loop, initialize instead

Reimplemented in Ra::Gui::Viewer.

Definition at line 154 of file WindowQt.cpp.

◆ isOpenGlInitialized()

bool Ra::Gui::WindowQt::isOpenGlInitialized ( ) const
inline

Definition at line 90 of file WindowQt.hpp.

◆ leaveEvent()

void Ra::Gui::WindowQt::leaveEvent ( QEvent * event)
virtual

Definition at line 178 of file WindowQt.cpp.

◆ makeCurrent()

void Ra::Gui::WindowQt::makeCurrent ( )

Make this->context() the current context. This function is made reentrant thanks to an internal counter that count how many time the context has been asked to be activated. If the context have already been made current with a previous call to makeCurrent, this function increase an internal counter by one so that doneCurrent do not release the context.

See also
activateScopedContext() as an alternative

Definition at line 80 of file WindowQt.cpp.

◆ resizeEvent()

void Ra::Gui::WindowQt::resizeEvent ( QResizeEvent * event)
override

Definition at line 94 of file WindowQt.cpp.

◆ resizeGL()

void Ra::Gui::WindowQt::resizeGL ( QResizeEvent * event)
protectedvirtual

Resize the OpenGL related part of the Window.

Reimplemented in Ra::Gui::Viewer.

Definition at line 172 of file WindowQt.cpp.

◆ resizeInternal()

void Ra::Gui::WindowQt::resizeInternal ( QResizeEvent * event)
protected

Definition at line 114 of file WindowQt.cpp.

◆ screenChanged

void Ra::Gui::WindowQt::screenChanged ( )
slot

Definition at line 56 of file WindowQt.cpp.

◆ showEvent()

void Ra::Gui::WindowQt::showEvent ( QShowEvent * event)
override

Definition at line 110 of file WindowQt.cpp.

Member Data Documentation

◆ m_context

std::unique_ptr<QOpenGLContext> Ra::Gui::WindowQt::m_context
protected

Definition at line 106 of file WindowQt.hpp.

◆ m_glInitialized

std::atomic_bool Ra::Gui::WindowQt::m_glInitialized
protected

Definition at line 109 of file WindowQt.hpp.

◆ m_updatePending

bool Ra::Gui::WindowQt::m_updatePending
protected

Definition at line 108 of file WindowQt.hpp.


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