GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
Glip::CoreGL::HdlDynamicData Class Referenceabstract

Dynamic allocator for GL types (run-time resolution of type). More...

#include <HdlDynamicData.hpp>

Inherited by Glip::CoreGL::HdlDynamicDataSpecial< T >.

Public Member Functions

const GLenum & getGLType (void) const
 Get the type of the current data as the GL identifier. More...
 
const GLenum & getGLSupportingType (void) const
 Get the supporting type of the current data as the GL identifier. More...
 
const bool & isFloatingPointType (void) const
 Test if the content is of floating point type. More...
 
const bool & isIntegerType (void) const
 Test if the content is of integer type. More...
 
const bool & isBooleanType (void) const
 Test if the content is of boolean type. More...
 
const bool & isUnsignedType (void) const
 Test if the content is of unsigned type. More...
 
const int & getNumRows (void) const
 Get the number of rows of the data. More...
 
const int & getNumColumns (void) const
 Get the number of columns of the data. More...
 
int getNumElements (void) const
 Get the number of elements of the matrix (rows times columns). More...
 
bool isInside (const int &i, const int &j) const
 Test if the coordinates are for a valid element inside the matrix. More...
 
int getIndex (const int &i, const int &j) const
 Get the linear index corresponding to these coordinates. More...
 
void getCoordinates (const int &index, int &i, int &j) const
 Get the coordinates from the linear index. More...
 
virtual float getf (const int &i=0, const int &j=0) const =0
 Get the value at coordinates (i, j) casted to float. More...
 
virtual void setf (const float &value, const int &i=0, const int &j=0)=0
 Set the value at coordinates (i, j) from a float value. More...
 
virtual double get (const int &i=0, const int &j=0) const =0
 Get the value at coordinates (i, j) casted to double. More...
 
virtual void set (const double &value, const int &i=0, const int &j=0)=0
 Set the value at coordinates (i, j) from a double value. More...
 
virtual const void * getPtr (void) const =0
 Get the pointer to the data (const). More...
 
virtual void * getPtr (void)=0
 Get the pointer to the data. More...
 
virtual const HdlDynamicDataoperator= (const HdlDynamicData &cpy)=0
 Copy the value from another HdlDynamicData object. Type MUST match, will raise an exception otherwise. More...
 

Static Public Member Functions

static HdlDynamicDatabuild (const GLenum &type)
 Build dynamic data from a GL data identifier (see supported types in main description of HdlDynamicData). More...
 
static HdlDynamicDatacopy (const HdlDynamicData &cpy)
 Copy dynamic data. More...
 

Detailed Description

Dynamic allocator for GL types (run-time resolution of type).

Supported types : GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT; GL_FLOAT, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4, GL_DOUBLE, GL_DOUBLE_VEC2, GL_DOUBLE_VEC3, GL_DOUBLE_VEC4, GL_INT, GL_INT_VEC2, GL_INT_VEC3, GL_INT_VEC4, GL_UNSIGNED_INT, GL_UNSIGNED_INT_VEC2, GL_UNSIGNED_INT_VEC3, GL_UNSIGNED_INT_VEC4, GL_BOOL, GL_BOOL_VEC2, GL_BOOL_VEC3, GL_BOOL_VEC4, GL_FLOAT_MAT2, GL_FLOAT_MAT3, GL_FLOAT_MAT4. The indexing is column major (matrix-like).

Example :

// Get a GL_INT_VEC2 buffer :
HdlDynamicData* data = HdlDynamicData::build(GL_INT_VEC2);
// Set some data :
data->set(17, 0);
data->set(23, 1);
// Print :
std::cout << "Vector of 2 integers : " << std::endl;
std::cout << (*data);
// Delete :
delete data;

Member Function Documentation

HdlDynamicData * HdlDynamicData::build ( const GLenum &  type)
static

Build dynamic data from a GL data identifier (see supported types in main description of HdlDynamicData).

Parameters
typeThe required GL type.
Returns
A data object allocated on the stack, that the user will have to delete once used. Raise an exception if any error occurs.
HdlDynamicData * HdlDynamicData::copy ( const HdlDynamicData cpy)
static

Copy dynamic data.

Parameters
cpyThe original element to be copied.
Returns
A data object allocated on the stack, that the user will have to delete once used. Raise an exception if any error occurs.
double Glip::CoreGL::HdlDynamicData::get ( const int &  i = 0,
const int &  j = 0 
) const
pure virtual

Get the value at coordinates (i, j) casted to double.

Parameters
iThe index of the row.
jThe index of the column.
Returns
The value at the requested coordinates converted to double. Raise an exception if any error occurs.
void HdlDynamicData::getCoordinates ( const int &  index,
int &  i,
int &  j 
) const

Get the coordinates from the linear index.

Parameters
indexThe linear index.
iThe index of the row (as output).
jThe index of the column (as output).
float Glip::CoreGL::HdlDynamicData::getf ( const int &  i = 0,
const int &  j = 0 
) const
pure virtual

Get the value at coordinates (i, j) casted to float.

Parameters
iThe index of the row.
jThe index of the column.
Returns
The value at the requested coordinates converted to float. Raise an exception if any error occurs.
const GLenum & HdlDynamicData::getGLSupportingType ( void  ) const

Get the supporting type of the current data as the GL identifier.

Returns
The GLenum corresponding to the supporting type (ex. with GL_FLOAT type, the supporting will also be GL_FLOAT, and for GL_INT_VEC2 it will be GL_INT).
const GLenum & HdlDynamicData::getGLType ( void  ) const

Get the type of the current data as the GL identifier.

Returns
The GLenum corresponding to the type.
int HdlDynamicData::getIndex ( const int &  i,
const int &  j 
) const

Get the linear index corresponding to these coordinates.

Parameters
iThe index of the row.
jThe index of the column.
Returns
The linear index.
const int & HdlDynamicData::getNumColumns ( void  ) const

Get the number of columns of the data.

Returns
The number of columns of the matrix.
int HdlDynamicData::getNumElements ( void  ) const

Get the number of elements of the matrix (rows times columns).

Returns
The number of elements in the matrix.
const int & HdlDynamicData::getNumRows ( void  ) const

Get the number of rows of the data.

Returns
The number of rows of the matrix.
const void * Glip::CoreGL::HdlDynamicData::getPtr ( void  ) const
pure virtual

Get the pointer to the data (const).

Returns
The pointer to the data casted to const void*.
void * Glip::CoreGL::HdlDynamicData::getPtr ( void  )
pure virtual

Get the pointer to the data.

Returns
The pointer to the data casted to void*.
const bool & HdlDynamicData::isBooleanType ( void  ) const

Test if the content is of boolean type.

Returns
True if the content is of boolean type.
const bool & HdlDynamicData::isFloatingPointType ( void  ) const

Test if the content is of floating point type.

Returns
True if the content is of floating point type.
bool HdlDynamicData::isInside ( const int &  i,
const int &  j 
) const

Test if the coordinates are for a valid element inside the matrix.

Parameters
iThe index of the row.
jThe index of the column.
Returns
True if the coordinates are valid, false otherwise.
const bool & HdlDynamicData::isIntegerType ( void  ) const

Test if the content is of integer type.

Returns
True if the content is of integer type.
const bool & HdlDynamicData::isUnsignedType ( void  ) const

Test if the content is of unsigned type.

Returns
True if the content is of unsigned type.
const HdlynamicData & Glip::CoreGL::HdlDynamicData::operator= ( const HdlDynamicData cpy)
pure virtual

Copy the value from another HdlDynamicData object. Type MUST match, will raise an exception otherwise.

Parameters
cpyThe object to be copied.
Returns
Reference to this object.
void Glip::CoreGL::HdlDynamicData::set ( const double &  value,
const int &  i = 0,
const int &  j = 0 
)
pure virtual

Set the value at coordinates (i, j) from a double value.

Parameters
valueThe new value.
iThe index of the row.
jThe index of the column.
void Glip::CoreGL::HdlDynamicData::setf ( const float &  value,
const int &  i = 0,
const int &  j = 0 
)
pure virtual

Set the value at coordinates (i, j) from a float value.

Parameters
valueThe new value.
iThe index of the row.
jThe index of the column.

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