public

Inheritance Graph

graph BT
	BufferObject
	click BufferObject "classRendering_1_1BufferObject"

Description

Representation of an OpenGL buffer object (BO).

Author: Benjamin Eikel

Date: 2012-04-19

Public Types

   
   
enum AccessFlag {NO_ACCESS, READ_ONLY, WRITE_ONLY, READ_WRITE}

Public Static Attributes

   
   
const uint32_t TARGET_ARRAY_BUFFER
   
const uint32_t TARGET_ATOMIC_COUNTER_BUFFER
   
const uint32_t TARGET_COPY_READ_BUFFER
   
const uint32_t TARGET_COPY_WRITE_BUFFER
   
const uint32_t TARGET_DISPATCH_INDIRECT_BUFFER
   
const uint32_t TARGET_DRAW_INDIRECT_BUFFER
   
const uint32_t TARGET_ELEMENT_ARRAY_BUFFER
   
const uint32_t TARGET_PIXEL_PACK_BUFFER
   
const uint32_t TARGET_PIXEL_UNPACK_BUFFER
   
const uint32_t TARGET_QUERY_BUFFER
   
const uint32_t TARGET_SHADER_STORAGE_BUFFER
   
const uint32_t TARGET_TEXTURE_BUFFER
   
const uint32_t TARGET_TRANSFORM_FEEDBACK_BUFFER
   
const uint32_t TARGET_UNIFORM_BUFFER
   
const uint32_t USAGE_STREAM_DRAW
   
const uint32_t USAGE_STREAM_READ
   
const uint32_t USAGE_STREAM_COPY
   
const uint32_t USAGE_STATIC_DRAW
   
const uint32_t USAGE_STATIC_READ
   
const uint32_t USAGE_STATIC_COPY
   
const uint32_t USAGE_DYNAMIC_DRAW
   
const uint32_t USAGE_DYNAMIC_READ
   
const uint32_t USAGE_DYNAMIC_COPY

Public Functions

   
   
  BufferObject()
Create an invalid buffer object for the given target.
   
  BufferObject(const BufferObject & void)
Data of an buffer object should not be copied.
   
  BufferObject( BufferObject && other)
Take ownership of the data of the other buffer object.
   
  ~BufferObject()
Free the data of the buffer object.
   
BufferObject & operator=(const BufferObject & void)
Data of an buffer object should not be copied.
   
BufferObject & operator=( BufferObject && other)
Take ownership of the data of the other buffer object.
   
void swap( BufferObject & other)
Swap the gl buffer with another BufferObject .
   
void prepare()
Request a new handle from OpenGL for this buffer object.
   
void destroy()
Free the handle of this buffer object.
   
void bind(uint32_t bufferTarget) const
Bind the buffer object to the given target.
   
void bind(uint32_t bufferTarget, uint32_t location) const
   
void unbind(uint32_t bufferTarget) const
Remove any binding of the given target.
   
void unbind(uint32_t bufferTarget, uint32_t location) const
template< typename T >  
void allocateData(uint32_t bufferTarget, std::size_t numberOfElements, uint32_t usageHint)
Allocate buffer data.
template< typename T >  
void uploadData(uint32_t bufferTarget, const std::vector< T > & data, uint32_t usageHint)
Copy data to the buffer object.
   
void uploadData(uint32_t bufferTarget, const uint8_t * data, size_t numBytes, uint32_t usageHint)
template< typename T >  
void uploadSubData(uint32_t bufferTarget, const std::vector< T > & data, size_t offset)
Copy data to the buffer object.
   
void uploadSubData(uint32_t bufferTarget, const uint8_t * data, size_t numBytes, size_t offset)
template< typename T >  
std::vector< T > downloadData(uint32_t bufferTarget, size_t numberOfElements, size_t offset) const
Retrieve data from the buffer object.
   
bool isValid() const
trueif and only if prepare() was executed at least once without an execution of destroy() afterwards.
   
uint32_t getGLId() const
   
void clear(uint32_t bufferTarget, uint32_t internalFormat, uint32_t format, uint32_t type, const uint8_t * data)
   
void clear(uint32_t internalFormat, uint32_t format, uint32_t type, const uint8_t * data)
   
void clear()
   
void copy(const BufferObject & source, uint32_t sourceOffset, uint32_t targetOffset, uint32_t size)
   
uint8_t * map(uint32_t offset, uint32_t size, AccessFlag access)
   
void unmap()

Documentation

enum
Rendering::BufferObject::AccessFlag

public
 
 
enum AccessFlag
Enumerator   Description
Enumerator   Description
NO_ACCESS = 0  
READ_ONLY = 1  
WRITE_ONLY = 2  
READ_WRITE = 3  

Defined in Rendering/BufferObject.h:58


variable
Rendering::BufferObject::TARGET_ARRAY_BUFFER

public static
 
 
const uint32_t TARGET_ARRAY_BUFFER

Defined in Rendering/BufferObject.h:33


variable
Rendering::BufferObject::TARGET_ATOMIC_COUNTER_BUFFER

public static
 
 
const uint32_t TARGET_ATOMIC_COUNTER_BUFFER

Defined in Rendering/BufferObject.h:34


variable
Rendering::BufferObject::TARGET_COPY_READ_BUFFER

public static
 
 
const uint32_t TARGET_COPY_READ_BUFFER

Defined in Rendering/BufferObject.h:35


variable
Rendering::BufferObject::TARGET_COPY_WRITE_BUFFER

public static
 
 
const uint32_t TARGET_COPY_WRITE_BUFFER

Defined in Rendering/BufferObject.h:36


variable
Rendering::BufferObject::TARGET_DISPATCH_INDIRECT_BUFFER

public static
 
 
const uint32_t TARGET_DISPATCH_INDIRECT_BUFFER

Defined in Rendering/BufferObject.h:37


variable
Rendering::BufferObject::TARGET_DRAW_INDIRECT_BUFFER

public static
 
 
const uint32_t TARGET_DRAW_INDIRECT_BUFFER

Defined in Rendering/BufferObject.h:38


variable
Rendering::BufferObject::TARGET_ELEMENT_ARRAY_BUFFER

public static
 
 
const uint32_t TARGET_ELEMENT_ARRAY_BUFFER

Defined in Rendering/BufferObject.h:39


variable
Rendering::BufferObject::TARGET_PIXEL_PACK_BUFFER

public static
 
 
const uint32_t TARGET_PIXEL_PACK_BUFFER

Defined in Rendering/BufferObject.h:40


variable
Rendering::BufferObject::TARGET_PIXEL_UNPACK_BUFFER

public static
 
 
const uint32_t TARGET_PIXEL_UNPACK_BUFFER

Defined in Rendering/BufferObject.h:41


variable
Rendering::BufferObject::TARGET_QUERY_BUFFER

public static
 
 
const uint32_t TARGET_QUERY_BUFFER

Defined in Rendering/BufferObject.h:42


variable
Rendering::BufferObject::TARGET_SHADER_STORAGE_BUFFER

public static
 
 
const uint32_t TARGET_SHADER_STORAGE_BUFFER

Defined in Rendering/BufferObject.h:43


variable
Rendering::BufferObject::TARGET_TEXTURE_BUFFER

public static
 
 
const uint32_t TARGET_TEXTURE_BUFFER

Defined in Rendering/BufferObject.h:44


variable
Rendering::BufferObject::TARGET_TRANSFORM_FEEDBACK_BUFFER

public static
 
 
const uint32_t TARGET_TRANSFORM_FEEDBACK_BUFFER

Defined in Rendering/BufferObject.h:45


variable
Rendering::BufferObject::TARGET_UNIFORM_BUFFER

public static
 
 
const uint32_t TARGET_UNIFORM_BUFFER

Defined in Rendering/BufferObject.h:46


variable
Rendering::BufferObject::USAGE_STREAM_DRAW

public static
 
 
const uint32_t USAGE_STREAM_DRAW

Defined in Rendering/BufferObject.h:48


variable
Rendering::BufferObject::USAGE_STREAM_READ

public static
 
 
const uint32_t USAGE_STREAM_READ

Defined in Rendering/BufferObject.h:49


variable
Rendering::BufferObject::USAGE_STREAM_COPY

public static
 
 
const uint32_t USAGE_STREAM_COPY

Defined in Rendering/BufferObject.h:50


variable
Rendering::BufferObject::USAGE_STATIC_DRAW

public static
 
 
const uint32_t USAGE_STATIC_DRAW

Defined in Rendering/BufferObject.h:51


variable
Rendering::BufferObject::USAGE_STATIC_READ

public static
 
 
const uint32_t USAGE_STATIC_READ

Defined in Rendering/BufferObject.h:52


variable
Rendering::BufferObject::USAGE_STATIC_COPY

public static
 
 
const uint32_t USAGE_STATIC_COPY

Defined in Rendering/BufferObject.h:53


variable
Rendering::BufferObject::USAGE_DYNAMIC_DRAW

public static
 
 
const uint32_t USAGE_DYNAMIC_DRAW

Defined in Rendering/BufferObject.h:54


variable
Rendering::BufferObject::USAGE_DYNAMIC_READ

public static
 
 
const uint32_t USAGE_DYNAMIC_READ

Defined in Rendering/BufferObject.h:55


variable
Rendering::BufferObject::USAGE_DYNAMIC_COPY

public static
 
 
const uint32_t USAGE_DYNAMIC_COPY

Defined in Rendering/BufferObject.h:56


function
Rendering::BufferObject::BufferObject

public
   
   
BufferObject( )

Create an invalid buffer object for the given target.

Defined in Rendering/BufferObject.h:71


function
Rendering::BufferObject::BufferObject

public
     
     
BufferObject( const BufferObject & void )

Data of an buffer object should not be copied.

Defined in Rendering/BufferObject.h:74


function
Rendering::BufferObject::BufferObject

public
     
     
BufferObject( BufferObject && other )

Take ownership of the data of the other buffer object.

Defined in Rendering/BufferObject.h:77


function
Rendering::BufferObject::~BufferObject

public
   
   
~BufferObject( )

Free the data of the buffer object.

Defined in Rendering/BufferObject.h:80


function
Rendering::BufferObject::operator=

public
     
     
BufferObject & operator=( const BufferObject & void )

Data of an buffer object should not be copied.

Defined in Rendering/BufferObject.h:83


function
Rendering::BufferObject::operator=

public
     
     
BufferObject & operator=( BufferObject && other )

Take ownership of the data of the other buffer object.

Defined in Rendering/BufferObject.h:86


function
Rendering::BufferObject::swap

public
     
     
void swap( BufferObject & other )

Swap the gl buffer with another BufferObject .

Defined in Rendering/BufferObject.h:89


function
Rendering::BufferObject::prepare

public
   
   
void prepare( )

Request a new handle from OpenGL for this buffer object.

Defined in Rendering/BufferObject.h:92


function
Rendering::BufferObject::destroy

public
   
   
void destroy( )

Free the handle of this buffer object.

Defined in Rendering/BufferObject.h:95


function
Rendering::BufferObject::bind

public const
     
     
void bind( uint32_t bufferTarget ) const

Bind the buffer object to the given target.

Defined in Rendering/BufferObject.h:98


function
Rendering::BufferObject::bind

public const
     
     
void bind( uint32_t bufferTarget,
  uint32_t location
) const    

Defined in Rendering/BufferObject.h:99


function
Rendering::BufferObject::unbind

public const
     
     
void unbind( uint32_t bufferTarget ) const

Remove any binding of the given target.

Defined in Rendering/BufferObject.h:102


function
Rendering::BufferObject::unbind

public const
     
     
void unbind( uint32_t bufferTarget,
  uint32_t location
) const    

Defined in Rendering/BufferObject.h:103


function
Rendering::BufferObject::allocateData

public
     
template< typename T >    
void allocateData( uint32_t bufferTarget,
  std::size_t numberOfElements,
  uint32_t usageHint
)    

Allocate buffer data.

Bind the buffer object to the given target, allocatenumberOfElementstimessizeof(T)bytes, and unbind the buffer object.

Defined in Rendering/BufferObject.h:113


function
Rendering::BufferObject::uploadData

public
     
template< typename T >    
void uploadData( uint32_t bufferTarget,
  const std::vector< T > & data,
  uint32_t usageHint
)    

Copy data to the buffer object.

Bind the buffer object to the given target, copydata.size()timessizeof(T)bytes from the vector to the buffer object, and unbind the buffer object.

Defined in Rendering/BufferObject.h:123


function
Rendering::BufferObject::uploadData

public
     
     
void uploadData( uint32_t bufferTarget,
  const uint8_t * data,
  size_t numBytes,
  uint32_t usageHint
)    

Defined in Rendering/BufferObject.h:124


function
Rendering::BufferObject::uploadSubData

public
     
template< typename T >    
void uploadSubData( uint32_t bufferTarget,
  const std::vector< T > & data,
  size_t offset
)    

Copy data to the buffer object.

Bind the buffer object to the given target, copydata.size()timessizeof(T)bytes from the vector to the buffer object, and unbind the buffer object.

Defined in Rendering/BufferObject.h:134


function
Rendering::BufferObject::uploadSubData

public
     
     
void uploadSubData( uint32_t bufferTarget,
  const uint8_t * data,
  size_t numBytes,
  size_t offset
)    

Defined in Rendering/BufferObject.h:135


function
Rendering::BufferObject::downloadData

public const
     
template< typename T >    
std::vector< T > downloadData( uint32_t bufferTarget,
  size_t numberOfElements,
  size_t offset
) const    

Retrieve data from the buffer object.

Bind the buffer object to the given target, copynumberOfElementstimessizeof(T)bytes from the buffer object to the vector, and unbind the buffer object.

Defined in Rendering/BufferObject.h:145


function
Rendering::BufferObject::isValid

public const inline
   
   
bool isValid( ) const

trueif and only if prepare() was executed at least once without an execution of destroy() afterwards.

Defined in Rendering/BufferObject.h:148


function
Rendering::BufferObject::getGLId

public const inline
   
   
uint32_t getGLId( ) const

Defined in Rendering/BufferObject.h:151


function
Rendering::BufferObject::clear

public
     
     
void clear( uint32_t bufferTarget,
  uint32_t internalFormat,
  uint32_t format,
  uint32_t type,
  const uint8_t * data
)    

Defined in Rendering/BufferObject.h:153


function
Rendering::BufferObject::clear

public
     
     
void clear( uint32_t internalFormat,
  uint32_t format,
  uint32_t type,
  const uint8_t * data
)    

Defined in Rendering/BufferObject.h:154


function
Rendering::BufferObject::clear

public
   
   
void clear( )

Defined in Rendering/BufferObject.h:155


function
Rendering::BufferObject::copy

public
     
     
void copy( const BufferObject & source,
  uint32_t sourceOffset,
  uint32_t targetOffset,
  uint32_t size
)    

Defined in Rendering/BufferObject.h:157


function
Rendering::BufferObject::map

public
     
     
uint8_t * map( uint32_t offset,
  uint32_t size,
  AccessFlag access
)    

Map all or part of a buffer object’s data store into the client’s address space

Note: The buffer has to be unmapped before using it for rendering.

Parameters

offset
The offset into the buffer in bytes.
size
The size of the buffer range in bytes to map. Whensizeis 0, the entire buffer is mapped.
allowWrite
Indicates that the returned pointer may be used to modify buffer object data.
allowRead
Indicates that the returned pointer may be used to read buffer object data.

Returns

The mapped data pointer, ornullptrif the mapping failed.

Defined in Rendering/BufferObject.h:169


function
Rendering::BufferObject::unmap

public
   
   
void unmap( )

Unmaps a previously mapped buffer.

Defined in Rendering/BufferObject.h:174