VVISF & VVGL
VVGL::GLBufferPool Class Reference

Buffer pools create and manage GL resources which, on deletion, are either destroyed or returned to the pool for re-use. More...

#include <GLBufferPool.hpp>

Public Member Functions

GLBufferRef createBufferRef (const GLBuffer::Descriptor &desc, const Size &size={640, 480}, const void *backingPtr=nullptr, const Size &backingSize={640, 480}, const bool &createInCurrentContext=false)
 This member function is how the pool creates buffers. You probably shouldn't call this function directly- instead use one of the functions in (VVGL- GLBuffer create functions) directly or as a prototype. They're in GLBufferPool.hpp/GLBufferPool.cpp.
 
void housekeeping ()
 You must call this periodically (once per render loop after you finish drawing is usually a good time to call this). This function frees any buffers that have been sitting unused in the pool for "too long".
 
void purge ()
 If needed you can call this to release all inactive buffers in the pool.
 
Timestamp getTimestamp () const
 Returns a timestamp generated for the current time.
 
void timestampThisBuffer (const GLBufferRef &n) const
 Timestamps the passed buffer with the current time.
 
GLContextRef & context ()
 Returns the GLContextRef used by the buffer pool to create and destroy its GL resources.
 

Related Functions

(Note that these are not member functions.)

using GLBufferPoolRef = shared_ptr< GLBufferPool >
 A GLBufferPoolRef is a shared pointer around a GLBufferPool.
 
GLBufferPoolRef CreateGlobalBufferPool (const GLContextRef &inPoolCtx=nullptr)
 This is how you create the global buffer pool. More...
 
const GLBufferPoolRefGetGlobalBufferPool ()
 This is how you retrieve the global buffer pool.
 
void SetGlobalBufferPool (const GLBufferPoolRef &inPoolRef=nullptr)
 This is another way to set a global buffer pool, but I mostly use it for deleting the global buffer pool.
 

Detailed Description

Buffer pools create and manage GL resources which, on deletion, are either destroyed or returned to the pool for re-use.

Notes on use:

  • GLBufferPool creates GLBuffer/GLBufferRef instances. You need a GLBufferPool to create a GLBuffer. If you're using VVGL you're almost certainly going to want to create a buffer pool.
  • For convenience, VVGL defines a singleton global buffer pool that you should create while your app is launching and setting up its OpenGL environment using CreateGlobalBufferPool(). The pool can be retrieved later using GetGlobalBufferPool(). It is STRONGLY RECOMMENDED that you create this global buffer pool- if you don't then you'll need to explicitly pass the pool you want to use to the various buffer creation functions.
  • GLBufferPool has a member function that creates buffers- but you probably shouldn't use it directly. Instead, you should use one of the buffer creation functions in (VVGL- GLBuffer create functions).
  • Don't forget to call the housekeeping() member function on your buffer pools periodically!
  • GLBufferPool requires a GL context on creation- the pool maintains a strong ref to this context, and will use it to create/destroy GL resources unless instructed otherwise via the "createInCurrentContext" variable in the various buffer creation functions.

Friends And Related Function Documentation

◆ CreateGlobalBufferPool()

GLBufferPoolRef CreateGlobalBufferPool ( const GLContextRef &  inPoolCtx = nullptr)
related

This is how you create the global buffer pool.

Parameters
inPoolCtxThe buffer pool that is created will share this context (textures and buffers created by the buffer pool will be compatible with all other GL contexts in the same sharegroup).

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