![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/GL/InstanceManager.h>
Concrete CRTP class for context-aware caching of OpenGL object instances. More...
Concrete CRTP class for context-aware caching of OpenGL object instances.
Inherit from this class if you want your class to support instance caching. It provides the static function cachedInstance() that will manage a single global instance of this object for each OpenGL context. Instances are lazy-instantiated, which means they do not exist until the first time they are requested for a concrete context.
This powerful interface enables you to avoid constant reallocation of your class while making sure to avoid race conditions (given that there is a 1-to-1 mapping between OpenGL contexts and threads) or issues if an OpenGL object is not shareable between contexts (such as VAOs).
Requesting cached instances is thread-safe. However, the returned objects are not. A cached instance will remain valid until the OpenGL context in which it was requested is destroyed.
Example for providing a global per-context GL::Framebuffer instance:
Static Public Member Functions | |
static T & | cachedInstance () |
Returns the cached instance of type T for the currently active OpenGL context. | |
|
inlinestatic |
Returns the cached instance of type T for the currently active OpenGL context.