Author: eilemann@gmail.com
State:
- Default window object manager in 0.5
- Textures, buffers and minor improvements implemented in 0.4
- Base class and display lists implemented in 0.3
Overview
The purpose of the object manager is to facilitate the management of OpenGL objects, e.g., texture IDs and display lists, in a multipipe application. Objects are allocated and queried using a key. Windows sharing the same OpenGL context will use the same object manager.
Objects
The API will be created as needed. Possible object types are: display lists, textures, GLSL shaders, VBO's, etc. See the header file (src/lib/util/objectManager.h) for the currently implemented types.
eq::Window Object Manager
Each window has an object manager with the key type const void*
for as long as it has an OpenGL context. The OM is shared between all windows
of a pipe, if the windows are created using the
default configInit
functions. If the window is created by the
application, the OM is not shared since no assumption can be made about OpenGL
context sharing.
API
For each type of object, the following functions are available:
- supportsObjects returns true if the usage for this particular type of objects is supported. For basic objects, which are supported on all OpenGL implementations, this function is not implemented.
- getObject returns the object associated with the key, or FAILED. Increases the reference count of existing objects.
- newObject allocates a new object for a key. Returns FAILED if the object already exists or if the allocation failed. Sets the reference count of a newly created object to one.
- obtainObject convenience function which gets or obtains the object associated with the key. Returns FAILED only if the object allocation failed.
- releaseObject decreases the reference count and deletes the object if the reference count reaches 0.
- deleteObject forcibly deletes the object. To be used if reference counting is not desired.
Example API for display list management:
template< typename T > class ObjectManager : public eq::base::NonCopyable { public: GLuint getList( const T& key ); GLuint newList( const T& key ); GLuint obtainList( const T& key ); void releaseList( const T& key ); void releaseList( const GLuint id ); void deleteList( const T& key ); void deleteList( const GLuint list ); } typedef ObjectManager< const char* > ObjectManagerS; ObjectManagerS& eq::Window::getObjectManager();