Castor3D  ..
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Castor3D::FrameVariableBuffer Class Referenceabstract

Shader variables buffer. More...

+ Inheritance diagram for Castor3D::FrameVariableBuffer:
+ Collaboration diagram for Castor3D::FrameVariableBuffer:

Public Member Functions

C3D_API FrameVariableBuffer (Castor::String const &p_name, RenderSystem &p_renderSystem)
 Constructor. More...
 
virtual C3D_API ~FrameVariableBuffer ()
 Destructor. More...
 
C3D_API bool Initialise (ShaderProgram &p_program)
 Initialises all the variables and the GPU buffer associated. More...
 
C3D_API void Cleanup ()
 Cleans all the variables up and the GPU buffer associated. More...
 
C3D_API bool Bind (uint32_t p_index)
 Binds all the variables, through the GPU buffer if supported (OpenGL UBO, Direct3D Constants buffers) More...
 
C3D_API void Unbind (uint32_t p_index)
 Unbinds all variables. More...
 
C3D_API FrameVariableSPtr CreateVariable (ShaderProgram &p_program, eFRAME_VARIABLE_TYPE p_type, Castor::String const &p_name, uint32_t p_occurences=1)
 Creates a variable of the wanted type. More...
 
C3D_API void RemoveVariable (Castor::String const &p_name)
 Removes a variable from this buffer. More...
 
template<typename T >
std::shared_ptr< OneFrameVariable< T > > GetVariable (Castor::String const &p_name, std::shared_ptr< OneFrameVariable< T > > &p_variable) const
 Retrieves a variable by name. More...
 
template<typename T , uint32_t Count>
std::shared_ptr< PointFrameVariable< T, Count > > GetVariable (Castor::String const &p_name, std::shared_ptr< PointFrameVariable< T, Count > > &p_variable) const
 Retrieves a variable by name. More...
 
template<typename T , uint32_t Rows, uint32_t Columns>
std::shared_ptr< MatrixFrameVariable< T, Rows, Columns > > GetVariable (Castor::String const &p_name, std::shared_ptr< MatrixFrameVariable< T, Rows, Columns > > &p_variable) const
 Retrieves a variable by name. More...
 
Castor::String const & GetName () const
 Retrieves the variables buffer name. More...
 
FrameVariablePtrList::iterator begin ()
 Retrieves an iterator to the beginnning of the variables list. More...
 
FrameVariablePtrList::const_iterator begin () const
 Retrieves an iterator to the beginnning of the variables list. More...
 
FrameVariablePtrList::iterator end ()
 Retrieves an iterator to the end of the variables list. More...
 
FrameVariablePtrList::const_iterator end () const
 Retrieves an iterator to the end of the variables list. More...
 

Protected Member Functions

virtual C3D_API FrameVariableSPtr DoCreateVariable (ShaderProgram *p_program, eFRAME_VARIABLE_TYPE p_type, Castor::String const &p_name, uint32_t p_occurences=1)=0
 Creates a variable of the wanted type. More...
 
virtual C3D_API bool DoInitialise (ShaderProgram *p_program)=0
 Initialises all the variables and the GPU buffer associated. More...
 
virtual C3D_API void DoCleanup ()=0
 Cleans all the variables up and the GPU buffer associated. More...
 
virtual C3D_API bool DoBind (uint32_t p_index)=0
 Binds all the variables, through the GPU buffer if supported (OpenGL UBO, Direct3D Constants buffers) More...
 
virtual C3D_API void DoUnbind (uint32_t p_index)=0
 Unbinds all variables. More...
 

Protected Attributes

uint32_t m_index
 The buffer's index. More...
 
FrameVariablePtrList m_listVariables
 The variables list. More...
 
FrameVariablePtrList m_listInitialised
 The initialised variables list. More...
 
FrameVariablePtrStrMap m_mapVariables
 The variables ordered by name. More...
 
Castor::String m_name
 The buffer name. More...
 
Castor::ByteArray m_buffer
 The data buffer. More...
 

Static Protected Attributes

static uint32_t sm_uiCount
 The buffers count. More...
 

Detailed Description

Shader variables buffer.

Author
Sylvain DOREMUS
Version
0.7.0.0
Date
19/04/2013
Remarks
It stores all variables held by a ShaderProgram or a ShaderObject
It is also in charge of the creation of the variables
Uses GPU buffers if supported (OpenGL Uniform Buffer Objects, Direct3D Constants buffers)

Constructor & Destructor Documentation

◆ FrameVariableBuffer()

C3D_API Castor3D::FrameVariableBuffer::FrameVariableBuffer ( Castor::String const &  p_name,
RenderSystem p_renderSystem 
)

Constructor.

Parameters
[in]p_nameThe buffer name
[in]p_renderSystemThe render system

◆ ~FrameVariableBuffer()

virtual C3D_API Castor3D::FrameVariableBuffer::~FrameVariableBuffer ( )
virtual

Destructor.

Member Function Documentation

◆ begin() [1/2]

FrameVariablePtrList::iterator Castor3D::FrameVariableBuffer::begin ( )
inline

Retrieves an iterator to the beginnning of the variables list.

Returns
The iterator

References m_listVariables.

◆ begin() [2/2]

FrameVariablePtrList::const_iterator Castor3D::FrameVariableBuffer::begin ( ) const
inline

Retrieves an iterator to the beginnning of the variables list.

Returns
The iterator

References m_listVariables.

◆ Bind()

C3D_API bool Castor3D::FrameVariableBuffer::Bind ( uint32_t  p_index)

Binds all the variables, through the GPU buffer if supported (OpenGL UBO, Direct3D Constants buffers)

Parameters
[in]p_indexThe buffer index
Returns
false if any problem occured

◆ Cleanup()

C3D_API void Castor3D::FrameVariableBuffer::Cleanup ( )

Cleans all the variables up and the GPU buffer associated.

◆ CreateVariable()

C3D_API FrameVariableSPtr Castor3D::FrameVariableBuffer::CreateVariable ( ShaderProgram p_program,
eFRAME_VARIABLE_TYPE  p_type,
Castor::String const &  p_name,
uint32_t  p_occurences = 1 
)

Creates a variable of the wanted type.

Parameters
[in]p_programThe program
[in]p_typeThe wanted type
[in]p_nameThe variable name
[in]p_occurencesThe array dimension
Returns
The created variable, nullptr if failed

◆ DoBind()

virtual C3D_API bool Castor3D::FrameVariableBuffer::DoBind ( uint32_t  p_index)
protectedpure virtual

Binds all the variables, through the GPU buffer if supported (OpenGL UBO, Direct3D Constants buffers)

Parameters
[in]p_indexThe buffer index
Returns
false if any problem occured

◆ DoCleanup()

virtual C3D_API void Castor3D::FrameVariableBuffer::DoCleanup ( )
protectedpure virtual

Cleans all the variables up and the GPU buffer associated.

◆ DoCreateVariable()

virtual C3D_API FrameVariableSPtr Castor3D::FrameVariableBuffer::DoCreateVariable ( ShaderProgram p_program,
eFRAME_VARIABLE_TYPE  p_type,
Castor::String const &  p_name,
uint32_t  p_occurences = 1 
)
protectedpure virtual

Creates a variable of the wanted type.

Parameters
[in]p_programThe program
[in]p_typeThe wanted type
[in]p_nameThe variable name
[in]p_occurencesThe array dimension
Returns
The created variable, nullptr if failed

◆ DoInitialise()

virtual C3D_API bool Castor3D::FrameVariableBuffer::DoInitialise ( ShaderProgram p_program)
protectedpure virtual

Initialises all the variables and the GPU buffer associated.

Parameters
[in]p_programThe program
Returns
false if any problem occured

◆ DoUnbind()

virtual C3D_API void Castor3D::FrameVariableBuffer::DoUnbind ( uint32_t  p_index)
protectedpure virtual

Unbinds all variables.

Parameters
[in]p_indexThe buffer index

◆ end() [1/2]

FrameVariablePtrList::iterator Castor3D::FrameVariableBuffer::end ( )
inline

Retrieves an iterator to the end of the variables list.

Returns
The iterator

References m_listVariables.

◆ end() [2/2]

FrameVariablePtrList::const_iterator Castor3D::FrameVariableBuffer::end ( ) const
inline

Retrieves an iterator to the end of the variables list.

Returns
The iterator

References m_listVariables.

◆ GetName()

Castor::String const& Castor3D::FrameVariableBuffer::GetName ( ) const
inline

Retrieves the variables buffer name.

Returns
The name

References m_name.

◆ GetVariable() [1/3]

template<typename T >
std::shared_ptr< OneFrameVariable< T > > Castor3D::FrameVariableBuffer::GetVariable ( Castor::String const &  p_name,
std::shared_ptr< OneFrameVariable< T > > &  p_variable 
) const

Retrieves a variable by name.

Parameters
[in]p_nameThe variable name
[out]p_variableReceives the found variable, nullptr if failed
Returns
false if failed

◆ GetVariable() [2/3]

template<typename T , uint32_t Count>
std::shared_ptr< PointFrameVariable< T, Count > > Castor3D::FrameVariableBuffer::GetVariable ( Castor::String const &  p_name,
std::shared_ptr< PointFrameVariable< T, Count > > &  p_variable 
) const

Retrieves a variable by name.

Parameters
[in]p_nameThe variable name
[out]p_variableReceives the found variable, nullptr if failed
Returns
false if failed

◆ GetVariable() [3/3]

template<typename T , uint32_t Rows, uint32_t Columns>
std::shared_ptr< MatrixFrameVariable< T, Rows, Columns > > Castor3D::FrameVariableBuffer::GetVariable ( Castor::String const &  p_name,
std::shared_ptr< MatrixFrameVariable< T, Rows, Columns > > &  p_variable 
) const

Retrieves a variable by name.

Parameters
[in]p_nameThe variable name
[out]p_variableReceives the found variable, nullptr if failed
Returns
false if failed

◆ Initialise()

C3D_API bool Castor3D::FrameVariableBuffer::Initialise ( ShaderProgram p_program)

Initialises all the variables and the GPU buffer associated.

Parameters
[in]p_programThe program
Returns
false if any problem occured

◆ RemoveVariable()

C3D_API void Castor3D::FrameVariableBuffer::RemoveVariable ( Castor::String const &  p_name)

Removes a variable from this buffer.

Parameters
[in]p_nameThe variable name

◆ Unbind()

C3D_API void Castor3D::FrameVariableBuffer::Unbind ( uint32_t  p_index)

Unbinds all variables.

Parameters
[in]p_indexThe buffer index

Member Data Documentation

◆ m_buffer

Castor::ByteArray Castor3D::FrameVariableBuffer::m_buffer
protected

The data buffer.

◆ m_index

uint32_t Castor3D::FrameVariableBuffer::m_index
protected

The buffer's index.

◆ m_listInitialised

FrameVariablePtrList Castor3D::FrameVariableBuffer::m_listInitialised
protected

The initialised variables list.

◆ m_listVariables

FrameVariablePtrList Castor3D::FrameVariableBuffer::m_listVariables
protected

The variables list.

Referenced by begin(), and end().

◆ m_mapVariables

FrameVariablePtrStrMap Castor3D::FrameVariableBuffer::m_mapVariables
protected

The variables ordered by name.

◆ m_name

Castor::String Castor3D::FrameVariableBuffer::m_name
protected

The buffer name.

Referenced by GetName().

◆ sm_uiCount

uint32_t Castor3D::FrameVariableBuffer::sm_uiCount
staticprotected

The buffers count.


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