Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::BufferObject Class Reference
+ Inheritance diagram for inviwo::BufferObject:

Public Types

enum class  BindingType { Native , ForceFloat , ForceNormalizedFloat }
 
enum class  SizePolicy { GrowOnly , ResizeToFit }
 

Public Member Functions

 BufferObject (size_t sizeInBytes, const DataFormatBase *format, BufferUsage usage, BufferTarget target=BufferTarget::Data)
 
 BufferObject (size_t sizeInBytes, GLFormat format, GLenum usage, GLenum target)
 
 BufferObject (const BufferObject &rhs)
 
 BufferObject (BufferObject &&rhs)
 
BufferObjectoperator= (const BufferObject &other)
 
BufferObjectoperator= (BufferObject &&other)
 
virtual BufferObjectclone () const
 
GLenum getFormatType () const
 
GLenum getTarget () const
 
GLuint getId () const
 
GLFormat getGLFormat () const
 
const DataFormatBasegetDataFormat () const
 
void bind () const
 Calls glBindBuffer.
 
void unbind () const
 Calls glBindBuffer with buffer name 0.
 
void bindBase (GLuint index) const
 Calls glBindBufferBase. Binds the buffer at index of the array of targets specified by the associated target (.
 
void bindRange (GLuint index, GLintptr offset, GLsizeiptr size) const
 Calls glBindBufferRange. Binds the range (offset, offset + size) of the buffer at index of the array of targets specified by the associated target (.
 
void bindAndSetAttribPointer (GLuint location, BindingType bindingType=BindingType::Native) const
 bind the buffer object and set the vertex attribute pointer
 
void setSizeInBytes (GLsizeiptr sizeInBytes, SizePolicy policy=SizePolicy::GrowOnly)
 
GLsizeiptr getSizeInBytes () const
 
GLsizeiptr getCapacityInBytes () const
 
void upload (const void *data, GLsizeiptr sizeInBytes, SizePolicy policy=SizePolicy::GrowOnly)
 
template<typename T >
void upload (const std::vector< T > &cont, SizePolicy policy=SizePolicy::GrowOnly)
 
void download (void *data) const
 
- Public Member Functions inherited from inviwo::Observable< BufferObjectObserver >
 Observable (const Observable< BufferObjectObserver > &other)
 
 Observable (Observable< BufferObjectObserver > &&other) noexcept
 
Observable< BufferObjectObserver > & operator= (const Observable< BufferObjectObserver > &other)
 
Observable< BufferObjectObserver > & operator= (Observable< BufferObjectObserver > &&other) noexcept
 
void addObserver (BufferObjectObserver *observer)
 
void removeObserver (BufferObjectObserver *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 
- Public Member Functions inherited from inviwo::ObservableInterface

Static Public Member Functions

static std::string_view targetName (GLenum target)
 

Additional Inherited Members

- Protected Member Functions inherited from inviwo::Observable< BufferObjectObserver >
void forEachObserver (C callback)
 
- Protected Member Functions inherited from inviwo::ObservableInterface
void addObservationHelper (Observer *observer)
 
void removeObservationHelper (Observer *observer)
 

Member Enumeration Documentation

◆ BindingType

Type of binding when setting glVertexAttrib*Pointer.

See glVertexAttribPointer and Vertex Specification for details.

Enumerator
Native 

uses glVertexAttribIPointer for integral types, glVertexAttribDPointer for double, and glVertexAttribPointer otherwise

ForceFloat 

enforces the use of glVertexAttribPointer independent of the buffer type

ForceNormalizedFloat 

enforces the use of glVertexAttribPointer with normalization of integral types

◆ SizePolicy

Policy for managing the buffer size when uploading new data to the GPU.

See also
upload
Enumerator
GrowOnly 

the buffer only grows and will never be resized to a smaller size

ResizeToFit 

the buffer size is adjusted to fit the data exactly

Member Function Documentation

◆ bindAndSetAttribPointer()

void inviwo::BufferObject::bindAndSetAttribPointer ( GLuint location,
BindingType bindingType = BindingType::Native ) const

bind the buffer object and set the vertex attribute pointer

This will bind the buffer object and then set the respective glVertexAttrib*Pointer. By default, i.e. bindingType = BindingType::Native, glVertexAttribIPointer (note the 'I') is used for scalar types and glVertexAttribPointer will be used for floating point types. This behavior can be overwritten by bindingType. Then the buffer is only accessible using float in the shader.

See also
BindingType
Parameters
locationused to set the vertex attribute location
bindingTypedetermines which glVertexAttrib*Pointer is used

◆ bindBase()

void inviwo::BufferObject::bindBase ( GLuint index) const

Calls glBindBufferBase. Binds the buffer at index of the array of targets specified by the associated target (.

See also
getTarget ) Targets must be one of GL_ATOMIC_COUNTER_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER, GL_UNIFORM_BUFFER or GL_SHADER_STORAGE_BUFFER

◆ bindRange()

void inviwo::BufferObject::bindRange ( GLuint index,
GLintptr offset,
GLsizeiptr size ) const

Calls glBindBufferRange. Binds the range (offset, offset + size) of the buffer at index of the array of targets specified by the associated target (.

See also
getTarget ) Targets must be one of GL_ATOMIC_COUNTER_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER, GL_UNIFORM_BUFFER or GL_SHADER_STORAGE_BUFFER

◆ getCapacityInBytes()

GLsizeiptr inviwo::BufferObject::getCapacityInBytes ( ) const

Get the capacity of the buffer in bytes, which might be larger than the size returned by getSizeInBytes()

See also
SizePolicy

◆ getSizeInBytes()

GLsizeiptr inviwo::BufferObject::getSizeInBytes ( ) const

Get the size of the buffer in bytes.

◆ setSizeInBytes()

void inviwo::BufferObject::setSizeInBytes ( GLsizeiptr sizeInBytes,
SizePolicy policy = SizePolicy::GrowOnly )

Set the size of the buffer in bytes.

Parameters
sizeInBytesnew buffer size in bytes
policyresizing policy when sizeInBytes differs from the current size

◆ upload() [1/2]

template<typename T >
void inviwo::BufferObject::upload ( const std::vector< T > & cont,
SizePolicy policy = SizePolicy::GrowOnly )
inline

Upload data from a container cont into the buffer. This also binds the buffer.

Parameters
contdata to be uploaded. The underlying data must match the current GL format of the buffer.
policyresizing policy when sizeInBytes differs from the current size
See also
upload(const void*, GLsizeiptr, SizePolicy)

◆ upload() [2/2]

void inviwo::BufferObject::upload ( const void * data,
GLsizeiptr sizeInBytes,
SizePolicy policy = SizePolicy::GrowOnly )

Upload data into the buffer. This also binds the buffer. Depending on the grow policy policy, the buffer is re-initialized with sizeInBytes if it is different from the current size of the buffer.

Parameters
datadata to be uploaded. The underlying data must match the current GL format of the buffer.
sizeInBytessize of the uploaded data
policyresizing policy when sizeInBytes differs from the current size
See also
getGLFormat,getSizeInBytes,SizePolicy

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