ImFusion SDK 4.3
Context Class Referenceabstract

#include <ImFusion/Core/GL/Context.h>

Base class for low-level OpenGL context handling within the ImFusion SDK. More...

+ Inheritance diagram for Context:

Detailed Description

Base class for low-level OpenGL context handling within the ImFusion SDK.

The child classes implement the concrete platform-specific code (based on WGL, GLX, etc.).

For very barebone applications, you can use the static create() factory function to create a GL::Context instance matching your local platform:

createInfo.requestedVersion = {4, 2}; // request at least OpenGL 4.2
createInfo.useDebugContext = true; // request a debug context if available
// will create an offscreen context with the given specifications
static std::unique_ptr< Context > create(CreateInfo createInfo)
Factory function for creating a new offscreen OpenGL context.
Definition Context.h:59
Utils::Version requestedVersion
Requested OpenGL version, use 0 for the highest available.
Definition Context.h:60
bool useDebugContext
Flag whether to request a debug context.
Definition Context.h:62
See also
ContextManager for a more high-level interface to manage OpenGL contexts

Classes

struct  CreateInfo
 

Public Member Functions

virtual bool makeCurrent () const =0
 Make context current.
 
virtual bool doneCurrent () const =0
 Disable context.
 
virtual void * internalHandle () const =0
 Returns the native handle of this OpenGL context that can be used with CreateInfo::shareContext.
 
virtual std::unique_ptr< Contextclone ()=0
 Instantiates a new OpenGL context that is shared with this one.
 
virtual void detachFromCurrentThread ()
 Removes the binding of the OpenGL context to the current (i.e., calling) thread.
 
virtual void moveToCurrentThread ()
 Moves the OpenGL context to the current (i.e., calling) thread.
 

Static Public Member Functions

static std::unique_ptr< Contextcreate (CreateInfo createInfo)
 Factory function for creating a new offscreen OpenGL context.
 

Protected Member Functions

virtual void deinitialize ()
 Clean up internal resources attached to this context.
 

Static Protected Member Functions

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.
 

Member Function Documentation

◆ create()

static std::unique_ptr< Context > create ( CreateInfo createInfo)
static

Factory function for creating a new offscreen OpenGL context.

The freshly created context will be made current.

See also
There is ContextManager::createContext() as convenience function to automatically create an OpenGL context that is compatible and shared with the main OpenGL context used by the ImFusion SDK.

◆ makeCurrent()

virtual bool makeCurrent ( ) const
pure virtual

Make context current.

Implemented in ContextGLX, ContextWindows, and GlContextQt.

◆ doneCurrent()

virtual bool doneCurrent ( ) const
pure virtual

Disable context.

Implemented in ContextGLX, ContextWindows, and GlContextQt.

◆ internalHandle()

virtual void * internalHandle ( ) const
pure virtual

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

Implemented in ContextGLX, ContextWindows, and GlContextQt.

◆ clone()

virtual std::unique_ptr< Context > clone ( )
pure virtual

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.

Implemented in ContextGLX, ContextWindows, and GlContextQt.

◆ detachFromCurrentThread()

virtual void detachFromCurrentThread ( )
virtual

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 in GlContextQt.

◆ moveToCurrentThread()

virtual void moveToCurrentThread ( )
virtual

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 in GlContextQt.

◆ deinitialize()

virtual void deinitialize ( )
protectedvirtual

Clean up internal resources attached to this context.

Derived classes must call this function in their destructor before destroying the GL context.


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