Geogram Version 1.10.2
A programming library of geometric algorithms
Loading...
Searching...
No Matches
GLUP::BufferObject Class Reference

Wrapper class around the different type of buffers used by the GPU. More...

#include <geogram_gfx/GLUP/GLUP_buffer_object.h>

Public Types

enum  Type { UNINITIALIZED , TEXTURE_2D , TBO , SSBO }

Public Member Functions

 BufferObject ()
 BufferObject constructor.
 ~BufferObject ()
 BufferObject destructor.
Type type () const
 Gets the type of a BufferObject.
bool initialized () const
 Tests whether a BufferObject is initialized.
void reset ()
 Resets a BufferObject.
template<class T>
void create_or_update (index_t nb, const T *data, GLuint unit=0)
 Creates an uninitialized BufferObject or updates an initialized one with new data.
template<class T>
void create_or_update (const std::vector< T > &v, index_t unit=0)
 Creates an uninitialized BufferObject or updates an initialized one with new data.
template<class T>
void create_or_update (const GEO::vector< T > &v, index_t unit=0)
 Creates an uninitialized BufferObject or updates an initialized one with new data.
void bind (GLuint unit=0)
 Binds this buffer to a unit.

Static Public Member Functions

static void register_GLSL_sources ()
 Registers GLSL sources for using portable wrappers around buffers. \TODOC.
static void initialize_class ()
 Initializes static class variables.
static Type default_type ()
 Gets the default type for BufferObjects.
static void active_unit (GLuint unit)
 Active_Units a unit.
static void set_program_buffer_unit_by_name (GLuint program, const char *name, GLuint unit)
 Sets a program uniform buffer unit.

Protected Member Functions

void reset_TEXTURE_2D ()
GEO_TBO_FUNC void reset_TBO ()
GEO_SSBO_FUNC void reset_SSBO ()
void bind_TEXTURE_2D (GLuint unit)
GEO_TBO_FUNC void bind_TBO (GLuint unit)
GEO_SSBO_FUNC void bind_SSBO (GLuint unit)
template<class T>
void create_or_update_TEXTURE_2D (index_t nb, const T *data)
template<class T>
GEO_TBO_FUNC void create_or_update_TBO (index_t nb, const T *data)
template<class T>
GEO_SSBO_FUNC void create_or_update_SSBO (index_t nb, const T *data)

Static Protected Member Functions

static void active_unit_TEXTURE_2D (GLuint unit)
static GEO_TBO_FUNC void active_unit_TBO (GLuint unit)
static GEO_SSBO_FUNC void active_unit_SSBO (GLuint unit)
static GLuint internal_format (uint32_t)
static GLuint internal_format (int32_t)
static GLuint internal_format (vec2i)
static GLuint internal_format (vec3i)
static GLuint internal_format (vec4i)
static GLuint internal_format (float)
static GLuint internal_format (vec2f)
static GLuint internal_format (vec3f)
static GLuint internal_format (vec4f)
static GLuint format (uint32_t)
static GLuint format (int32_t)
static GLuint format (vec2i)
static GLuint format (vec3i)
static GLuint format (vec4i)
static GLuint format (float)
static GLuint format (vec2f)
static GLuint format (vec3f)
static GLuint format (vec4f)
static GLuint type (uint32_t)
static GLuint type (int32_t)
static GLuint type (vec2i)
static GLuint type (vec3i)
static GLuint type (vec4i)
static GLuint type (float)
static GLuint type (vec2f)
static GLuint type (vec3f)
static GLuint type (vec4f)

Detailed Description

Wrapper class around the different type of buffers used by the GPU.

Wraps either a 2D texture, a TBO (Texture Buffer Object) or an SSBO, depending on what is supported and on user-specified gfx:buffers command line argument.

Definition at line 102 of file GLUP_buffer_object.h.

Member Enumeration Documentation

◆ Type

enum GLUP::BufferObject::Type

Definition at line 104 of file GLUP_buffer_object.h.

Constructor & Destructor Documentation

◆ BufferObject()

GLUP::BufferObject::BufferObject ( )
inline

BufferObject constructor.

Constructs an uninitialized BufferObject

Definition at line 110 of file GLUP_buffer_object.h.

◆ ~BufferObject()

GLUP::BufferObject::~BufferObject ( )
inline

BufferObject destructor.

Definition at line 116 of file GLUP_buffer_object.h.

Member Function Documentation

◆ active_unit()

void GLUP::BufferObject::active_unit ( GLuint unit)
static

Active_Units a unit.

Parameters
[in]unita unit id (either a texture unit or a buffer unit, depending on default buffer type).

◆ bind()

void GLUP::BufferObject::bind ( GLuint unit = 0)

Binds this buffer to a unit.

Calls active_unit(unit).

Parameters
[in]unita unit id (either a texture unit or a buffer unit, depending on default buffer type). If 0, use currently active unit.

◆ create_or_update() [1/3]

template<class T>
void GLUP::BufferObject::create_or_update ( const GEO::vector< T > & v,
index_t unit = 0 )
inline

Creates an uninitialized BufferObject or updates an initialized one with new data.

Parameters
[in]va geogram vector with the data
[in]unita unit this buffer will be bound to, or 0 if currently active unit should be used instead
See also
active_unit()

Definition at line 222 of file GLUP_buffer_object.h.

◆ create_or_update() [2/3]

template<class T>
void GLUP::BufferObject::create_or_update ( const std::vector< T > & v,
index_t unit = 0 )
inline

Creates an uninitialized BufferObject or updates an initialized one with new data.

Parameters
[in]va STL vector with the data
[in]unita unit this buffer will be bound to, or 0 if currently active unit should be used instead
See also
active_unit()

Definition at line 208 of file GLUP_buffer_object.h.

◆ create_or_update() [3/3]

template<class T>
void GLUP::BufferObject::create_or_update ( index_t nb,
const T * data,
GLuint unit = 0 )
inline

Creates an uninitialized BufferObject or updates an initialized one with new data.

Parameters
[in]nbnumber of items
[in]dataa pointer to a contiguous array of nb items
[in]unita unit this buffer will be bound to, or 0 if currently active unit should be used instead
See also
active_unit()

Definition at line 174 of file GLUP_buffer_object.h.

◆ create_or_update_SSBO()

template<class T>
GEO_SSBO_FUNC void GLUP::BufferObject::create_or_update_SSBO ( index_t nb,
const T * data )
inlineprotected

Definition at line 358 of file GLUP_buffer_object.h.

◆ create_or_update_TBO()

template<class T>
GEO_TBO_FUNC void GLUP::BufferObject::create_or_update_TBO ( index_t nb,
const T * data )
inlineprotected

Definition at line 334 of file GLUP_buffer_object.h.

◆ create_or_update_TEXTURE_2D()

template<class T>
void GLUP::BufferObject::create_or_update_TEXTURE_2D ( index_t nb,
const T * data )
inlineprotected

Definition at line 268 of file GLUP_buffer_object.h.

◆ default_type()

Type GLUP::BufferObject::default_type ( )
static

Gets the default type for BufferObjects.

Returns
one of TEXTURE_2D, TBO, SSBO

◆ format() [1/9]

GLuint GLUP::BufferObject::format ( float )
inlinestaticprotected

Definition at line 394 of file GLUP_buffer_object.h.

◆ format() [2/9]

GLuint GLUP::BufferObject::format ( int32_t )
inlinestaticprotected

Definition at line 390 of file GLUP_buffer_object.h.

◆ format() [3/9]

GLuint GLUP::BufferObject::format ( uint32_t )
inlinestaticprotected

Definition at line 389 of file GLUP_buffer_object.h.

◆ format() [4/9]

GLuint GLUP::BufferObject::format ( vec2f )
inlinestaticprotected

Definition at line 395 of file GLUP_buffer_object.h.

◆ format() [5/9]

GLuint GLUP::BufferObject::format ( vec2i )
inlinestaticprotected

Definition at line 391 of file GLUP_buffer_object.h.

◆ format() [6/9]

GLuint GLUP::BufferObject::format ( vec3f )
inlinestaticprotected

Definition at line 396 of file GLUP_buffer_object.h.

◆ format() [7/9]

GLuint GLUP::BufferObject::format ( vec3i )
inlinestaticprotected

Definition at line 392 of file GLUP_buffer_object.h.

◆ format() [8/9]

GLuint GLUP::BufferObject::format ( vec4f )
inlinestaticprotected

Definition at line 397 of file GLUP_buffer_object.h.

◆ format() [9/9]

GLuint GLUP::BufferObject::format ( vec4i )
inlinestaticprotected

Definition at line 393 of file GLUP_buffer_object.h.

◆ initialize_class()

void GLUP::BufferObject::initialize_class ( )
static

Initializes static class variables.

Needs to be called after OpenGL is initialized and before any BufferObject is created.

◆ initialized()

bool GLUP::BufferObject::initialized ( ) const
inline

Tests whether a BufferObject is initialized.

Return values
trueif this BufferObject is initialized, that is, has associated data in GPU memory
falseotherwise

Definition at line 134 of file GLUP_buffer_object.h.

◆ internal_format() [1/9]

GLuint GLUP::BufferObject::internal_format ( float )
inlinestaticprotected

Definition at line 384 of file GLUP_buffer_object.h.

◆ internal_format() [2/9]

GLuint GLUP::BufferObject::internal_format ( int32_t )
inlinestaticprotected

Definition at line 380 of file GLUP_buffer_object.h.

◆ internal_format() [3/9]

GLuint GLUP::BufferObject::internal_format ( uint32_t )
inlinestaticprotected

Definition at line 379 of file GLUP_buffer_object.h.

◆ internal_format() [4/9]

GLuint GLUP::BufferObject::internal_format ( vec2f )
inlinestaticprotected

Definition at line 385 of file GLUP_buffer_object.h.

◆ internal_format() [5/9]

GLuint GLUP::BufferObject::internal_format ( vec2i )
inlinestaticprotected

Definition at line 381 of file GLUP_buffer_object.h.

◆ internal_format() [6/9]

GLuint GLUP::BufferObject::internal_format ( vec3f )
inlinestaticprotected

Definition at line 386 of file GLUP_buffer_object.h.

◆ internal_format() [7/9]

GLuint GLUP::BufferObject::internal_format ( vec3i )
inlinestaticprotected

Definition at line 382 of file GLUP_buffer_object.h.

◆ internal_format() [8/9]

GLuint GLUP::BufferObject::internal_format ( vec4f )
inlinestaticprotected

Definition at line 387 of file GLUP_buffer_object.h.

◆ internal_format() [9/9]

GLuint GLUP::BufferObject::internal_format ( vec4i )
inlinestaticprotected

Definition at line 383 of file GLUP_buffer_object.h.

◆ reset()

void GLUP::BufferObject::reset ( )

Resets a BufferObject.

Releases all memory and objects allocated on the GPU by this BufferObject.

◆ set_program_buffer_unit_by_name()

void GLUP::BufferObject::set_program_buffer_unit_by_name ( GLuint program,
const char * name,
GLuint unit )
static

Sets a program uniform buffer unit.

unit is interpreted either as a texture unit or a SSBO binding point, depending on default_type().

Parameters
[in]programthe OpenGL program id
[in]namea string with the name of the uniform variable
[in]unitthe unit

◆ type() [1/10]

Type GLUP::BufferObject::type ( ) const
inline

Gets the type of a BufferObject.

Returns
one of UNINITIALIZED, TEXTURE_2D, TBO, SSBO

Definition at line 124 of file GLUP_buffer_object.h.

◆ type() [2/10]

GLuint GLUP::BufferObject::type ( float )
inlinestaticprotected

Definition at line 404 of file GLUP_buffer_object.h.

◆ type() [3/10]

GLuint GLUP::BufferObject::type ( int32_t )
inlinestaticprotected

Definition at line 400 of file GLUP_buffer_object.h.

◆ type() [4/10]

GLuint GLUP::BufferObject::type ( uint32_t )
inlinestaticprotected

Definition at line 399 of file GLUP_buffer_object.h.

◆ type() [5/10]

GLuint GLUP::BufferObject::type ( vec2f )
inlinestaticprotected

Definition at line 405 of file GLUP_buffer_object.h.

◆ type() [6/10]

GLuint GLUP::BufferObject::type ( vec2i )
inlinestaticprotected

Definition at line 401 of file GLUP_buffer_object.h.

◆ type() [7/10]

GLuint GLUP::BufferObject::type ( vec3f )
inlinestaticprotected

Definition at line 406 of file GLUP_buffer_object.h.

◆ type() [8/10]

GLuint GLUP::BufferObject::type ( vec3i )
inlinestaticprotected

Definition at line 402 of file GLUP_buffer_object.h.

◆ type() [9/10]

GLuint GLUP::BufferObject::type ( vec4f )
inlinestaticprotected

Definition at line 407 of file GLUP_buffer_object.h.

◆ type() [10/10]

GLuint GLUP::BufferObject::type ( vec4i )
inlinestaticprotected

Definition at line 403 of file GLUP_buffer_object.h.


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