ImFusion C++ SDK 4.4.0
ImFusion::GL::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 ImFusion::GL::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
bool useDebugContext
Flag whether to request a debug context.
Definition Context.h:62
Utils::Version requestedVersion
Requested OpenGL version, use 0 for the highest available.
Definition Context.h:60
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< Context > clone ()=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< Context > create (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()

std::unique_ptr< Context > ImFusion::GL::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 ImFusion::GL::Context::makeCurrent ( ) const
pure virtual

◆ doneCurrent()

virtual bool ImFusion::GL::Context::doneCurrent ( ) const
pure virtual

◆ internalHandle()

virtual void * ImFusion::GL::Context::internalHandle ( ) const
pure virtual

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

Implemented in ImFusion::GL::ContextGLX, ImFusion::GL::ContextWindows, and ImFusion::GlContextQt.

◆ clone()

virtual std::unique_ptr< Context > ImFusion::GL::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 ImFusion::GL::ContextGLX, ImFusion::GL::ContextWindows, and ImFusion::GlContextQt.

◆ detachFromCurrentThread()

virtual void ImFusion::GL::Context::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 ImFusion::GlContextQt.

◆ moveToCurrentThread()

virtual void ImFusion::GL::Context::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 ImFusion::GlContextQt.

◆ deinitialize()

virtual void ImFusion::GL::Context::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:
  • ImFusion/Core/GL/Context.h
Search Tab / S to search, Esc to close