#include <ImFusion/GUI/GlContextQt.h>
OpenGL context using Qt as backend.
More...
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.
|
| 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::Context > | clone () 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 void * | internalHandleOf (const QOpenGLContext *context) |
| Returns the native handle of the given OpenGL context that can be used with CreateInfo::shareContext .
|
|
static std::unique_ptr< Context > | create (CreateInfo createInfo) |
| Factory function for creating a new offscreen OpenGL context.
|
|
|
virtual void | deinitialize () |
| Clean up internal resources attached to this 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.
|
|
◆ GlContextQt() [1/2]
Creates a new Qt-based OpenGL context.
If you want to pass a shared context, createInfo.shareContext
must be of type QOpenGLContext*
.
- Exceptions
-
◆ 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
-
majorVersion | Requested OpenGL major version, use 0 for default |
minorVersion | Requested OpenGL minor version, use 0 for default |
compatibilityProfile | Flag whether to request a compatibility profile for OpenGL 3.0 and above |
shareContext | Optional 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
-
◆ 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()
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:
- ImFusion/GUI/GlContextQt.h