Unofficial OpenGL Software Development Kit  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
List of all members | Classes | Public Member Functions
glmesh::StreamBuffer Class Reference

#include <StreamBuffer.h>

Inherits noncopyable.

A class for streaming vertex data to buffer objects on the GPU.

This class is specifically used for efficiently streaming vertex data to the GPU. It can map some part of the buffer, invalidate the buffer, and so forth. It also stores a convenient vertex array object, if VAO's are available.

The StreamBuffer has the concept of a current position within the buffer. Each time the buffer is finished being mapped, the current position is advanced by the space that was mapped; the assumption being that you have written to all of the data requested. The user can ask how much space is left in the StreamBuffer.

This method of streaming is one of the documented ones from the OpenGL wiki. This class can be used just as well for uniform buffers or other cases when streaming from the CPU to buffer objects.

Invalidating the buffer resets the current position.

StreamBuffer cannot be copied, as performing a deep-copy would not be a reasonably fast operation.

Classes

class  Map
 A RAII-style class for mapping a StreamBuffer. More...
 

Public Member Functions

 StreamBuffer (size_t bufferSize)
 Creates a StreamBuffer with the given size. The size cannot be changed later. More...
 
 ~StreamBuffer ()
 Destroys the stream buffer and the buffer object it stores.
 
GLuint GetVao ()
 Retrieve a communal VAO. If VAO is not defined, returns 0.
 
GLuint GetBuffer ()
 Retrieve the buffer object. More...
 
size_t GetBufferPosition () const
 Gets the current position within the buffer object.
 
size_t GetSpaceRemaining () const
 Return how much room there is between the current position and the end of the buffer.
 
size_t GetTotalBufferSize () const
 Retrieves the total size of the buffer.
 
void InvalidateBuffer ()
 Causes all data in the buffer to be lost; the current position is reset to 0. More...
 

Constructor & Destructor Documentation

glmesh::StreamBuffer::StreamBuffer ( size_t  bufferSize)

Creates a StreamBuffer with the given size. The size cannot be changed later.

When this function completes, the buffer bound to GL_ARRAY_BUFFER will be reset 0.

Member Function Documentation

GLuint glmesh::StreamBuffer::GetBuffer ( )
inline

Retrieve the buffer object.

Returns
The OpenGL buffer object. Do not destroy this; it is owned by this class.
void glmesh::StreamBuffer::InvalidateBuffer ( )

Causes all data in the buffer to be lost; the current position is reset to 0.

When this function completes, the binding state of GL_ARRAY_BUFFER will be 0.

Exceptions
StoreAlreadyMappedThrown if the StreamBuffer is already mapped.

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