|
Ream v0.1.0-1
C++ graphics library for Linux
|
OpenGL context data manager. More...
#include <RGLContext.h>
Inheritance diagram for RGLContextDataManager:Public Types | |
| using | AllocFunc = std::function< RGLContextData *(RGLDevice *device)> |
| Allocator function. | |
Public Member Functions | |
| RGLContextData * | getData (RGLDevice *device) noexcept |
| Retrieves or creates context-specific data for the given device on the current thread. | |
| void | freeData (RGLDevice *device) noexcept |
| Frees all RGLContextData instances associated with the specified device across all threads. | |
| ~RGLContextDataManager () noexcept | |
| Destroys the manager and all RGLContextData instances it owns. | |
Public Member Functions inherited from RObject | |
| RObject ()=default | |
| Constructs a default RObject. | |
Static Public Member Functions | |
| static std::shared_ptr< RGLContextDataManager > | Make (AllocFunc func) noexcept |
| Creates an RGLContextDataManager. | |
OpenGL context data manager.
In Ream, each device has a dedicated OpenGL context for every thread that uses it. Although these contexts are created as shared, they do not always share all OpenGL resources— such as framebuffers, shader programs, and others, making it difficult for users to allocate and manage their own graphics resources.
This class enables users to provide a custom allocator function that creates an instance of a subclass of RGLContextData, which can be populated with any required data members. The instance is automatically created if one does not already exist for the current device/context combination when getData() is called.
At allocation time, the EGL context for the corresponding device and thread is made current. The same applies when the destructor of the associated RGLContextData is invoked.
Each allocated RGLContextData instance is automatically destroyed under the following conditions:
| using AllocFunc = std::function<RGLContextData *(RGLDevice *device)> |
Allocator function.
This function is used to create instances of a subclass of RGLContextData associated with a specific device/thread.
| device | Pointer to the RGLDevice for which context-specific data is requested. |
nullptr is valid, in such cases, getData() will return nullptr for the corresponding thread/device pair.
|
noexcept |
Destroys the manager and all RGLContextData instances it owns.
Instances belonging to the current thread are destroyed immediately (with their context made current); those belonging to other threads are queued as garbage and released when those threads terminate or call RGLCore::clearGarbage().
|
staticnoexcept |
Creates an RGLContextDataManager.
| func | Allocator function. |
nullptr if the allocator is invalid.
|
noexcept |
Retrieves or creates context-specific data for the given device on the current thread.
If no data exists for the current device/context pair, a new instance is allocated using the registered allocator function. The associated EGL context is bound during allocation.
| device | Pointer to the target device. |
nullptr if the allocator functuin returned nullptr.
|
noexcept |
Frees all RGLContextData instances associated with the specified device across all threads.
This method releases the context-specific data allocated for the given device in every thread where it was used.
| device | Pointer to the target RGLDevice whose associated context data will be released. |