ImFusion SDK 4.3
GlContextQt Class Referencefinal

#include <ImFusion/GUI/GlContextQt.h>

OpenGL context using Qt as backend. More...

+ Inheritance diagram for GlContextQt:

Detailed Description

OpenGL context using Qt as backend.

If you want to render onto a Qt surface (e.g. using DisplayWidget), you must make sure to use an instance of this class to initialize the ImFusion SDK.

Note
Due to a restriction of Qt, a GlContextQt must be instantiated from the main GUI thread. You can move the object to a different thread using the detachFromCurrentThread() and moveToCurrentThread() functions.
The clone() method of this class will not create a GlContextQt but an instance of the corresponding native type (e.g. GlContectWindows or GlContextGLX). Thus, a cloned GlContextQt can not be used to render onto a Qt surface. Use the constructor instead if you need this functionality. This behavior can be disabled by setting the IMFUSION_CLONE_QT_CONTEXT environment variable.

Public Member Functions

 GlContextQt (CreateInfo createInfo)
 Creates a new Qt-based OpenGL context.
 
 GlContextQt (int majorVersion=0, int minorVersion=0, bool compatibilityProfile=false, QOpenGLContext *shareContext=nullptr)
 Creates a new Qt-based OpenGL context.
 
QOpenGLContext * qglContext () const
 Returns the internal QOpenGLContext.
 
bool makeCurrent () const override
 Make context current.
 
bool doneCurrent () const override
 Disable context.
 
void * internalHandle () const override
 Returns the native handle of this OpenGL context that can be used with CreateInfo::shareContext.
 
std::unique_ptr< GL::Contextclone () override
 Instantiates a new OpenGL context that is shared with this one.
 
void detachFromCurrentThread () override
 Removes the binding of the OpenGL context to the current (i.e., calling) thread.
 
void moveToCurrentThread () override
 Moves the OpenGL context to the current (i.e., calling) thread.
 

Static Public Member Functions

static void * internalHandleOf (const QOpenGLContext *context)
 Returns the native handle of the given OpenGL context that can be used with CreateInfo::shareContext.
 
- Static Public Member Functions inherited from Context
static std::unique_ptr< Contextcreate (CreateInfo createInfo)
 Factory function for creating a new offscreen OpenGL context.
 

Additional Inherited Members

- Protected Member Functions inherited from Context
virtual void deinitialize ()
 Clean up internal resources attached to this context.
 
- Static Protected Member Functions inherited from Context
static int defaultPixelBufferSize ()
 Default width and height of the pixel buffer of newly created offscreen contexts.
 
static void installDefaultDebugMessageHandler ()
 Sets up the Debug::defaultMessageCallback handler.
 

Constructor & Destructor Documentation

◆ GlContextQt() [1/2]

GlContextQt ( CreateInfo createInfo)
explicit

Creates a new Qt-based OpenGL context.

If you want to pass a shared context, createInfo.shareContext must be of type QOpenGLContext*.

Exceptions
std::runtime_errorif the OpenGL context could not be created/initialized.
std::runtime_errorif createInfo.shareContext was given but context sharing could not be established.

◆ GlContextQt() [2/2]

GlContextQt ( int majorVersion = 0,
int minorVersion = 0,
bool compatibilityProfile = false,
QOpenGLContext * shareContext = nullptr )
explicit

Creates a new Qt-based OpenGL context.

Parameters
majorVersionRequested OpenGL major version, use 0 for default
minorVersionRequested OpenGL minor version, use 0 for default
compatibilityProfileFlag whether to request a compatibility profile for OpenGL 3.0 and above
shareContextOptional OpenGL context to share textures and other data with
Note
This function will request a debug context only for debug builds or if the IMFUSION_USE_OPENGL_DEBUG_CONTEXT environment variable is set.
Exceptions
std::runtime_errorif the OpenGL context could not be created/initialized.
std::runtime_errorif createInfo.shareContext was given but context sharing could not be established.

Member Function Documentation

◆ makeCurrent()

bool makeCurrent ( ) const
overridevirtual

Make context current.

Implements Context.

◆ doneCurrent()

bool doneCurrent ( ) const
overridevirtual

Disable context.

Implements Context.

◆ internalHandle()

void * internalHandle ( ) const
overridevirtual

Returns the native handle of this OpenGL context that can be used with CreateInfo::shareContext.

Implements Context.

◆ clone()

std::unique_ptr< GL::Context > clone ( )
overridevirtual

Instantiates a new OpenGL context that is shared with this one.

The freshly created context will be made current. This method will throw if the context could not be initialized.

Note
If you plan to use this context in a different thread, you will need to call moveToCurrentThread() on the returned context before.

Implements Context.

◆ detachFromCurrentThread()

void detachFromCurrentThread ( )
overridevirtual

Removes the binding of the OpenGL context to the current (i.e., calling) thread.

Note
Before calling this method, make sure to release the context from the source thread (i.e. call doneCurrent()). After calling this method, move the context to the new thread and make it current there.

Reimplemented from Context.

◆ moveToCurrentThread()

void moveToCurrentThread ( )
overridevirtual

Moves the OpenGL context to the current (i.e., calling) thread.

Note
Before calling this method, make sure to release the context from the source thread (i.e. call doneCurrent()). After calling this method, make the context current in the new thread.

Reimplemented from Context.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close