version 3.3

VRS::PBufferManagerGL Class Reference

#include <vrs/opengl/pbuffermanagergl.h>

Inheritance diagram for VRS::PBufferManagerGL:

VRS::SharedObj VRS::Visitable

List of all members.

Public Types

enum  PBufferSizePolicy { CANVAS_SIZE, FIXED_SIZE }

Public Member Functions

 VRS_SERIALIZABLE_CLASS_ENUM (PBufferSizePolicy)
PBufferCanvasGLreserve (EngineGL *engine, PBufferManagerGL::PBufferSizePolicy=PBufferManagerGL::CANVAS_SIZE, unsigned int width=0, unsigned int height=0, GLCanvas::CanvasProperties=GLCanvas::RGBADS)
PBufferCanvasGLreserve (EngineGL *engine, SharedObj *const key, PBufferManagerGL::PBufferSizePolicy=PBufferManagerGL::CANVAS_SIZE, unsigned int width=0, unsigned int height=0, GLCanvas::CanvasProperties=GLCanvas::RGBADS)
PBufferCanvasGLget (SharedObj *const key) const
void free (PBufferCanvasGL *)
void free (SharedObj *const key)
void updateTextureArea (EngineGL *, PBufferCanvasGL *, Texture2DGL *, Area=Area(0, 0, 0, 0))
void setCleanUpAtTermination (bool)
bool getCleanUpAtTermination () const
void unconditionalCleanUp ()
 VRS_TYPEINFO (PBufferManagerGL, SharedObj)

Static Public Member Functions

static void prepareContext (EngineGL *, PBufferCanvasGL *)
static void releaseContext (EngineGL *, PBufferCanvasGL *)
static void cleanUp ()

Protected Member Functions

 PBufferManagerGL ()
 Only a SharedContextGL can create a PBufferManagerGL object.
 ~PBufferManagerGL ()
void perFrameCleanUp (const unsigned int framesBeforeDestruction=20)

Friends

class SharedContextGL


Detailed Description

The pbuffer manager provides an interface for opengl techniques and shaders, that need to use pbuffers. It holds a set of pbuffers; and when techniques and shaders ask for a pbuffer with certain properties, it returns the best matching pbuffer. When the pbuffer is no longer needed, it must be released, so it can be reserved by other techniqes or shaders again. To make this pbuffer management work for different techniques and shaders, the pbuffer manager is created by the shared context and shared among the techniques and shaders (with EngineGL::pbufferManager() ).

Member Enumeration Documentation

Enumerator:
CANVAS_SIZE 
FIXED_SIZE 


Constructor & Destructor Documentation

VRS::PBufferManagerGL::PBufferManagerGL (  )  [protected]

Only a SharedContextGL can create a PBufferManagerGL object.

VRS::PBufferManagerGL::~PBufferManagerGL (  )  [protected]


Member Function Documentation

VRS::PBufferManagerGL::VRS_SERIALIZABLE_CLASS_ENUM ( PBufferSizePolicy   ) 

PBufferCanvasGL* VRS::PBufferManagerGL::reserve ( EngineGL engine,
PBufferManagerGL::PBufferSizePolicy  = PBufferManagerGL::CANVAS_SIZE,
unsigned int  width = 0,
unsigned int  height = 0,
GLCanvas::CanvasProperties  = GLCanvas::RGBADS 
)

Returns a PBufferCanvasGL-object that has at least the given properties. If PBufferSizePolicy is CanvasSize, the pbuffer has at least the size of the current canvas, otherwise its size is at least width*heigth. The properties of the canvas also at least contain those indicated by CanvasProperties. A pbuffer with additional, non-requested properties might be returned also; e.g., if you reserve a pbuffer with CanvasProperties RGBDS, the actual pbuffer might have RGBADDS instead.

Note that when a new pbuffer is created, it is by default enabled for redisplay. Probably you don't want this, in case call the disableRedisplay()-method of the PBuffer.

PBufferCanvasGL* VRS::PBufferManagerGL::reserve ( EngineGL engine,
SharedObj *const   key,
PBufferManagerGL::PBufferSizePolicy  = PBufferManagerGL::CANVAS_SIZE,
unsigned int  width = 0,
unsigned int  height = 0,
GLCanvas::CanvasProperties  = GLCanvas::RGBADS 
)

When reserving a pbuffer, this method additionally allows to assign a key, that can be later used to retrieve the pbuffer again with get(key). Several pbuffers can be stacked; you will be only able to retrieve the latest reserved pbuffer for the key. Use free(key) instead of free(PBufferCanvasGL*) when reserving a pbuffer with this method.

You must not use a pbuffer as a key, since you won't be able to free such a buffer later (free is overloaded twice). Also be sure not to use a temporary object as key.

keys are valuable for shaders / handlers which need to create an own pbuffer for each attribute they evaluate. Normally they would have to maintain their own stack of pbuffers. This is avoided when using the evaluating shader-object as key.

PBufferCanvasGL* VRS::PBufferManagerGL::get ( SharedObj *const   key  )  const

returns a pbuffer that previously has been reserved with a key (and not yet been freed). Asserts if no pbuffer is stored for the key.

void VRS::PBufferManagerGL::free ( PBufferCanvasGL  ) 

Indicated that the pbuffer is no longer used and may be reserved by other techniques again. You can only release PBufferCanvasGL-objects, that you formerly have reserved (Otherwise, an assertion will occur).

void VRS::PBufferManagerGL::free ( SharedObj *const   key  ) 

Indicates that the pbuffer that previously has been reserved with a key is now no longer used. If previously another pbuffer has been assigned to that key, get will now return that pbuffer for the key (e.g., the pbuffers for a key form a stack)

static void VRS::PBufferManagerGL::prepareContext ( EngineGL ,
PBufferCanvasGL  
) [static]

Convenience method: provides a safe way to activate rendering to the PBuffer without exchanging the underlying rendering engine. This is needed in techniques and shaders. the method disables the old rendering context, switches to the pbuffer context and sets the proper viewport attribute. Further Viewport attributes are disregarded.

static void VRS::PBufferManagerGL::releaseContext ( EngineGL ,
PBufferCanvasGL  
) [static]

Convenience method: deactivate rendering to the PBuffer. Simply undoes all changes made by releaseContext.

void VRS::PBufferManagerGL::updateTextureArea ( EngineGL ,
PBufferCanvasGL ,
Texture2DGL ,
Area  = Area(0, 0, 0, 0) 
)

Copies the area in the pbuffer to the corresponding area of the texture. If no area is given, the extends of the main rendering canvas are taken as area. It is in the users responsabality that the area is smaller than the p-buffer extent (that can be ensured with choosing CameraSize when reserving the pbuffer and omiting the area parameter)

The method also sets the texture matrix such that the texturearea that ranges from texels (0,0) to (canvassize.x, canvassize.y) has texture coordinates [0,1]x[0,1].

void VRS::PBufferManagerGL::setCleanUpAtTermination ( bool   ) 

For some user interfaces (i.E., glut) during termination of a program a proper destruction of pbuffers seems to be not possible. In such cases, the destruction of pbuffers can be hindered.

bool VRS::PBufferManagerGL::getCleanUpAtTermination (  )  const

Returns whether pbuffers of a PBufferManagerGL-object are destroyed during termination of a program or not.

void VRS::PBufferManagerGL::unconditionalCleanUp (  ) 

Removes all references from all pbuffers created the PBufferManagerGL- objects, even those that are currently in use. Use with care.

static void VRS::PBufferManagerGL::cleanUp (  )  [static]

Removes all references from all pbuffers created by PBufferManagerGL- objects, even those that are currently in use. Can be invoked by an application, but is also called by an atexit-callback during program termination.

VRS::PBufferManagerGL::VRS_TYPEINFO ( PBufferManagerGL  ,
SharedObj   
)

void VRS::PBufferManagerGL::perFrameCleanUp ( const unsigned int  framesBeforeDestruction = 20  )  [protected]

Should be called by the engine at the beginning of every frame. Ensures that old pbuffers that have not been used for somes frames are destructed. Also resets the context in case it changes.


Friends And Related Function Documentation

friend class SharedContextGL [friend]


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

Generated on Tue May 22 06:00:24 2012 by Doxygen 1.5.6
© 2001-2010 Hasso-Plattner-Institut | Impressum | Contact