MeVisLab Resolution Independence API
Loading...
Searching...
No Matches
ml::GLResourceManager Class Reference

Manages OpenGL resources. More...

#include <mlGLResourceManager.h>

Classes

class  GLResourceList
 Dynamic list of GLResource objects. More...

Public Member Functions

 GLResourceManager ()
virtual ~GLResourceManager ()
bool isContextActive () const
 Checks whether the current context is active.
void destroyTextures (int num, GLuint *textures)
 Destroys the given texture IDs (destroys them later if no GL context is currently active).
void destroyFragmentProgramARB (GLuint program)
 Destroys the given fragment program ID (destroys it later if no GL context is currently active).
void destroyRenderBuffer (GLuint id)
 Destroys the given render buffer (destroys it later if no GL context is currently active).
void destroyFrameBuffer (GLuint id)
 Destroys the given render buffer (destroys it later if no GL context is currently active).
void destroyBuffer (GLuint id)
 Destroys the given vertex buffer (destroys it later if no GL context is currently active).
void destroyPixelBuffer (GLuint id)
 Destroys the given pixel buffer (destroys it later if no GL context is currently active).
void destroyVertexBuffer (GLuint id)
 Destroys the given pixel buffer (destroys it later if no GL context is currently active).
void destroyGLSLShader (GLuint id)
 Destroys the given shader (destroys it later if no GL context is currently active).
void destroyGLSLProgram (GLuint id)
 Destroys the given program (destroys it later if no GL context is currently active).
void destroyFTFont (FTFont *font)
 Destroys the given font (destroys it later if no GL context is currently active).
void detachGLSLShader (GLuint program, GLuint shader)
 Detaches the given shader from the program (this is done later of the GL context is not currently active).
void disableGLSLProgram ()
 Removes currently active program.
void unlockContext (unsigned int cacheContextId)
 Sets that the context is active.
void lockContext ()
 Sets that the context is locked.
unsigned int cacheContextID ()
 Returns the current cache context ID.
GLenum getGLError () const
 Checks for OpenGL error (returns GL_INVALID_OPERATION if there is no valid OpenGL context).

Static Public Member Functions

static void init ()
 Creates singleton.
static void cleanup ()
 Destroys singleton.
static GLResourceManager * self ()
 Returns singleton instance.

Protected Types

typedef std::pair< GLuint, GLuint > GLSLProgramShaderPair

Protected Member Functions

void addResource (GLResource *program)
 Adds the given resource.
void removeResource (GLResource *program)
 Removes the given resource.
void contextDestroyed ()
 Forgets about all resources; the shared context was destroyed.
void freeResources ()
 Frees resources that could not be destroyed earlier.
void add (GLResourceList &list, GLResource *resource)
void remove (GLResourceList &list, GLResource *resource)

Protected Attributes

bool _contextLocked
unsigned int _cacheContextID
GLResourceList _resources
std::vector< GLuint > _texturesToFree
std::vector< GLuint > _programsARBToFree
std::vector< GLuint > _frameBuffersToFree
std::vector< GLuint > _renderBuffersToFree
std::vector< GLuint > _buffersToFree
std::vector< GLuint > _GLSLProgramsToFree
std::vector< GLuint > _GLSLShadersToFree
std::vector< GLSLProgramShaderPair > _GLSLShadersToDetach
std::vector< FTFont * > _FTFontsToFree

Static Protected Attributes

static GLResourceManager * _self

Friends

class GLResource

Detailed Description

Manages OpenGL resources.

Definition at line 28 of file mlGLResourceManager.h.

Member Typedef Documentation

◆ GLSLProgramShaderPair

typedef std::pair<GLuint, GLuint> ml::GLResourceManager::GLSLProgramShaderPair
protected

Definition at line 139 of file mlGLResourceManager.h.

Constructor & Destructor Documentation

◆ GLResourceManager()

ml::GLResourceManager::GLResourceManager ( )

Referenced by self().

◆ ~GLResourceManager()

virtual ml::GLResourceManager::~GLResourceManager ( )
virtual

Member Function Documentation

◆ add()

void ml::GLResourceManager::add ( GLResourceList & list,
GLResource * resource )
protected

References GLResource.

◆ addResource()

void ml::GLResourceManager::addResource ( GLResource * program)
protected

Adds the given resource.

References GLResource.

◆ cacheContextID()

unsigned int ml::GLResourceManager::cacheContextID ( )
inline

Returns the current cache context ID.

Definition at line 93 of file mlGLResourceManager.h.

References _cacheContextID.

◆ cleanup()

void ml::GLResourceManager::cleanup ( )
static

Destroys singleton.

◆ contextDestroyed()

void ml::GLResourceManager::contextDestroyed ( )
protected

Forgets about all resources; the shared context was destroyed.

◆ destroyBuffer()

void ml::GLResourceManager::destroyBuffer ( GLuint id)

Destroys the given vertex buffer (destroys it later if no GL context is currently active).

Referenced by destroyPixelBuffer(), and destroyVertexBuffer().

◆ destroyFragmentProgramARB()

void ml::GLResourceManager::destroyFragmentProgramARB ( GLuint program)

Destroys the given fragment program ID (destroys it later if no GL context is currently active).

◆ destroyFrameBuffer()

void ml::GLResourceManager::destroyFrameBuffer ( GLuint id)

Destroys the given render buffer (destroys it later if no GL context is currently active).

◆ destroyFTFont()

void ml::GLResourceManager::destroyFTFont ( FTFont * font)

Destroys the given font (destroys it later if no GL context is currently active).

◆ destroyGLSLProgram()

void ml::GLResourceManager::destroyGLSLProgram ( GLuint id)

Destroys the given program (destroys it later if no GL context is currently active).

◆ destroyGLSLShader()

void ml::GLResourceManager::destroyGLSLShader ( GLuint id)

Destroys the given shader (destroys it later if no GL context is currently active).

◆ destroyPixelBuffer()

void ml::GLResourceManager::destroyPixelBuffer ( GLuint id)
inline

Destroys the given pixel buffer (destroys it later if no GL context is currently active).

Definition at line 64 of file mlGLResourceManager.h.

References destroyBuffer().

◆ destroyRenderBuffer()

void ml::GLResourceManager::destroyRenderBuffer ( GLuint id)

Destroys the given render buffer (destroys it later if no GL context is currently active).

◆ destroyTextures()

void ml::GLResourceManager::destroyTextures ( int num,
GLuint * textures )

Destroys the given texture IDs (destroys them later if no GL context is currently active).

◆ destroyVertexBuffer()

void ml::GLResourceManager::destroyVertexBuffer ( GLuint id)
inline

Destroys the given pixel buffer (destroys it later if no GL context is currently active).

Definition at line 69 of file mlGLResourceManager.h.

References destroyBuffer().

◆ detachGLSLShader()

void ml::GLResourceManager::detachGLSLShader ( GLuint program,
GLuint shader )

Detaches the given shader from the program (this is done later of the GL context is not currently active).

◆ disableGLSLProgram()

void ml::GLResourceManager::disableGLSLProgram ( )

Removes currently active program.

◆ freeResources()

void ml::GLResourceManager::freeResources ( )
protected

Frees resources that could not be destroyed earlier.

◆ getGLError()

GLenum ml::GLResourceManager::getGLError ( ) const

Checks for OpenGL error (returns GL_INVALID_OPERATION if there is no valid OpenGL context).

◆ init()

void ml::GLResourceManager::init ( )
static

Creates singleton.

◆ isContextActive()

bool ml::GLResourceManager::isContextActive ( ) const
inline

Checks whether the current context is active.

Definition at line 48 of file mlGLResourceManager.h.

References _contextLocked.

◆ lockContext()

void ml::GLResourceManager::lockContext ( )

Sets that the context is locked.

◆ remove()

void ml::GLResourceManager::remove ( GLResourceList & list,
GLResource * resource )
protected

References GLResource.

◆ removeResource()

void ml::GLResourceManager::removeResource ( GLResource * program)
protected

Removes the given resource.

References GLResource.

◆ self()

GLResourceManager * ml::GLResourceManager::self ( )
inlinestatic

Returns singleton instance.

Definition at line 42 of file mlGLResourceManager.h.

References _self, and GLResourceManager().

◆ unlockContext()

void ml::GLResourceManager::unlockContext ( unsigned int cacheContextId)

Sets that the context is active.

◆ GLResource

friend class GLResource
friend

Definition at line 132 of file mlGLResourceManager.h.

References GLResource.

Referenced by add(), addResource(), GLResource, remove(), and removeResource().

Member Data Documentation

◆ _buffersToFree

std::vector<GLuint> ml::GLResourceManager::_buffersToFree
protected

Definition at line 145 of file mlGLResourceManager.h.

◆ _cacheContextID

unsigned int ml::GLResourceManager::_cacheContextID
protected

Definition at line 135 of file mlGLResourceManager.h.

Referenced by cacheContextID().

◆ _contextLocked

bool ml::GLResourceManager::_contextLocked
protected

Definition at line 134 of file mlGLResourceManager.h.

Referenced by isContextActive().

◆ _frameBuffersToFree

std::vector<GLuint> ml::GLResourceManager::_frameBuffersToFree
protected

Definition at line 143 of file mlGLResourceManager.h.

◆ _FTFontsToFree

std::vector<FTFont*> ml::GLResourceManager::_FTFontsToFree
protected

Definition at line 149 of file mlGLResourceManager.h.

◆ _GLSLProgramsToFree

std::vector<GLuint> ml::GLResourceManager::_GLSLProgramsToFree
protected

Definition at line 146 of file mlGLResourceManager.h.

◆ _GLSLShadersToDetach

std::vector<GLSLProgramShaderPair> ml::GLResourceManager::_GLSLShadersToDetach
protected

Definition at line 148 of file mlGLResourceManager.h.

◆ _GLSLShadersToFree

std::vector<GLuint> ml::GLResourceManager::_GLSLShadersToFree
protected

Definition at line 147 of file mlGLResourceManager.h.

◆ _programsARBToFree

std::vector<GLuint> ml::GLResourceManager::_programsARBToFree
protected

Definition at line 142 of file mlGLResourceManager.h.

◆ _renderBuffersToFree

std::vector<GLuint> ml::GLResourceManager::_renderBuffersToFree
protected

Definition at line 144 of file mlGLResourceManager.h.

◆ _resources

GLResourceList ml::GLResourceManager::_resources
protected

Definition at line 137 of file mlGLResourceManager.h.

◆ _self

GLResourceManager* ml::GLResourceManager::_self
staticprotected

Definition at line 151 of file mlGLResourceManager.h.

Referenced by self().

◆ _texturesToFree

std::vector<GLuint> ml::GLResourceManager::_texturesToFree
protected

Definition at line 141 of file mlGLResourceManager.h.


The documentation for this class was generated from the following file: