Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Types | Public Member Functions | Static Public Attributes | List of all members
vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type > Class Template Reference

The Array class is a template array used to conveniently manipulate data stored in a BufferObject. More...

#include <Array.hpp>

+ Inheritance diagram for vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >:

Public Types

typedef T_Scalar scalar_type
 
typedef T_VectorType vector_type
 

Public Member Functions

virtual size_t glSize () const
 Returns the number of scalar components for the array, ie 3 for ArrayFloat3, 1 for ArrayUInt1 etc. More...
 
virtual GLenum glType () const
 Returns the OpenGL type for the array, ie GL_FLOAT for ArrayFloat3, GL_UNSIGNED_INT for ArrayUInt1 etc. More...
 
virtual size_t bytesPerVector () const
 
void clear ()
 
void resize (size_t dim)
 
size_t size () const
 Returns the number of elements of an array. More...
 
size_t sizeBufferObject () const
 
size_t scalarCount () const
 
size_t scalarCountBufferObject () const
 
const T_VectorType * begin () const
 
T_VectorType * begin ()
 
const T_VectorType * end () const
 
T_VectorType * end ()
 
T_VectorType & at (size_t i)
 
const T_VectorType & at (size_t i) const
 
T_VectorType & operator[] (size_t i)
 
const T_VectorType & operator[] (size_t i) const
 
virtual ref< ArrayAbstractcreateArray () const
 
virtual ref< ArrayAbstractclone () const
 
Sphere computeBoundingSphere () const
 Computes the bounding sphere enclosing the vectors contained in the buffer. More...
 
AABB computeBoundingBox () const
 Computes the axis aligned bounding box enclosing the vectors contained in the buffer. More...
 
void transform (const mat4 &m)
 Transforms the vectors contained in the buffer. More...
 
void normalize ()
 Normalizes the vectors contained in the buffer. More...
 
vec4 getAsVec4 (size_t vector_index) const
 Returns a vector from the buffer as a vec4 value. More...
 
vec3 getAsVec3 (size_t vector_index) const
 Returns a vector from the buffer as a vec3 value. More...
 
vec2 getAsVec2 (size_t vector_index) const
 Returns a vector from the buffer as a vec2 value. More...
 
int compare (int a, int b) const
 Compares two vectors. More...
 
void initFrom (const std::vector< T_VectorType > &vector)
 
- Public Member Functions inherited from vl::ArrayAbstract
 ArrayAbstract ()
 Default constructor. More...
 
 ArrayAbstract (const ArrayAbstract &other)
 Copies only the local data and not the BufferObject related fields. More...
 
void operator= (const ArrayAbstract &other)
 Copies only the local data and not the BufferObject related fields. More...
 
const BufferObjectbufferObject () const
 
BufferObjectbufferObject ()
 
void clear ()
 
const unsigned char * ptr () const
 Returns the pointer to the first element of the local buffer. Equivalent to bufferObject()->ptr() More...
 
unsigned char * ptr ()
 Returns the pointer to the first element of the local buffer. Equivalent to bufferObject()->ptr() More...
 
virtual size_t bytesUsed () const
 Returns the amount of memory in bytes used by an array. Equivalent to bufferObject()->bytesUsed(). More...
 
bool isBufferObjectDirty () const
 Wether the BufferObject should be updated or not using the local storage. More...
 
void setBufferObjectDirty (bool dirty=true)
 Wether the BufferObject should be updated or not using the local storage. More...
 
EBufferObjectUsage usage () const
 BU_STATIC_DRAW by default. More...
 
void setUsage (EBufferObjectUsage usage)
 BU_STATIC_DRAW by default. More...
 
void updateBufferObject (EBufferObjectUpdateMode mode=BUM_KeepRamBuffer)
 Updates the BufferObject. More...
 
void setNormalize (bool normalize)
 The 'normalized' parameter as used with glVertexAttribPointer() More...
 
bool normalize () const
 The 'normalized' parameter as used with glVertexAttribPointer() More...
 
void setInterpretation (EVertexAttribInterpretation behavior)
 How the data is interpreted by the OpenGL, see EVertexAttribInterpretation. More...
 
EVertexAttribInterpretation interpretation () const
 How the data is interpreted by the OpenGL, see EVertexAttribInterpretation. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Static Public Attributes

static const size_t gl_size = T_GL_Size
 
static const GLenum gl_type = T_GL_Type
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 
- Protected Attributes inherited from vl::ArrayAbstract
ref< BufferObjectmBufferObject
 
EBufferObjectUsage mBufferObjectUsage
 
bool mBufferObjectDirty
 
EVertexAttribInterpretation mInterpretation
 
bool mNormalize
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Detailed Description

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
class vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >

The Array class is a template array used to conveniently manipulate data stored in a BufferObject.

See also

Definition at line 213 of file Array.hpp.

Member Typedef Documentation

◆ scalar_type

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
typedef T_Scalar vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::scalar_type

Definition at line 218 of file Array.hpp.

◆ vector_type

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
typedef T_VectorType vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::vector_type

Definition at line 219 of file Array.hpp.

Member Function Documentation

◆ at() [1/2]

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
T_VectorType& vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::at ( size_t  i)
inline

◆ at() [2/2]

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
const T_VectorType& vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::at ( size_t  i) const
inline

Definition at line 257 of file Array.hpp.

◆ begin() [1/2]

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
const T_VectorType* vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::begin ( ) const
inline

◆ begin() [2/2]

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
T_VectorType* vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::begin ( )
inline

Definition at line 247 of file Array.hpp.

◆ bytesPerVector()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
virtual size_t vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::bytesPerVector ( ) const
inlinevirtual

Definition at line 227 of file Array.hpp.

◆ clear()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
void vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::clear ( )
inline

Definition at line 231 of file Array.hpp.

◆ clone()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
virtual ref<ArrayAbstract> vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::clone ( ) const
inlinevirtual

Implements vl::ArrayAbstract.

Definition at line 267 of file Array.hpp.

◆ compare()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
int vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::compare ( int  a,
int  b 
) const
inlinevirtual

Compares two vectors.

Implements vl::ArrayAbstract.

Definition at line 385 of file Array.hpp.

◆ computeBoundingBox()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
AABB vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::computeBoundingBox ( ) const
inlinevirtual

Computes the axis aligned bounding box enclosing the vectors contained in the buffer.

Implements vl::ArrayAbstract.

Definition at line 307 of file Array.hpp.

◆ computeBoundingSphere()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
Sphere vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::computeBoundingSphere ( ) const
inlinevirtual

Computes the bounding sphere enclosing the vectors contained in the buffer.

Implements vl::ArrayAbstract.

Definition at line 280 of file Array.hpp.

◆ createArray()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
virtual ref<ArrayAbstract> vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::createArray ( ) const
inlinevirtual

Definition at line 265 of file Array.hpp.

◆ end() [1/2]

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
const T_VectorType* vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::end ( ) const
inline

◆ end() [2/2]

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
T_VectorType* vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::end ( )
inline

Definition at line 251 of file Array.hpp.

◆ getAsVec2()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
vec2 vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::getAsVec2 ( size_t  vector_index) const
inlinevirtual

Returns a vector from the buffer as a vec2 value.

Implements vl::ArrayAbstract.

Definition at line 375 of file Array.hpp.

◆ getAsVec3()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
vec3 vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::getAsVec3 ( size_t  vector_index) const
inlinevirtual

Returns a vector from the buffer as a vec3 value.

Implements vl::ArrayAbstract.

Definition at line 365 of file Array.hpp.

◆ getAsVec4()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
vec4 vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::getAsVec4 ( size_t  vector_index) const
inlinevirtual

Returns a vector from the buffer as a vec4 value.

Implements vl::ArrayAbstract.

Definition at line 356 of file Array.hpp.

◆ glSize()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
virtual size_t vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::glSize ( ) const
inlinevirtual

Returns the number of scalar components for the array, ie 3 for ArrayFloat3, 1 for ArrayUInt1 etc.

Implements vl::ArrayAbstract.

Definition at line 223 of file Array.hpp.

◆ glType()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
virtual GLenum vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::glType ( ) const
inlinevirtual

Returns the OpenGL type for the array, ie GL_FLOAT for ArrayFloat3, GL_UNSIGNED_INT for ArrayUInt1 etc.

Implements vl::ArrayAbstract.

Definition at line 225 of file Array.hpp.

◆ initFrom()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
void vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::initFrom ( const std::vector< T_VectorType > &  vector)
inline

◆ normalize()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
void vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::normalize ( )
inlinevirtual

Normalizes the vectors contained in the buffer.

Implements vl::ArrayAbstract.

Definition at line 339 of file Array.hpp.

◆ operator[]() [1/2]

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
T_VectorType& vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::operator[] ( size_t  i)
inline

Definition at line 259 of file Array.hpp.

◆ operator[]() [2/2]

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
const T_VectorType& vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::operator[] ( size_t  i) const
inline

Definition at line 261 of file Array.hpp.

◆ resize()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
void vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::resize ( size_t  dim)
inline

◆ scalarCount()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
size_t vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::scalarCount ( ) const
inline

Definition at line 239 of file Array.hpp.

◆ scalarCountBufferObject()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
size_t vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::scalarCountBufferObject ( ) const
inline

Definition at line 241 of file Array.hpp.

◆ size()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
size_t vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::size ( ) const
inlinevirtual

◆ sizeBufferObject()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
size_t vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::sizeBufferObject ( ) const
inline

Definition at line 237 of file Array.hpp.

◆ transform()

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
void vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::transform ( const mat4 m)
inlinevirtual

Transforms the vectors contained in the buffer.

Implements vl::ArrayAbstract.

Definition at line 322 of file Array.hpp.

Referenced by makeScales().

Member Data Documentation

◆ gl_size

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
const size_t vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::gl_size = T_GL_Size
static

Definition at line 220 of file Array.hpp.

◆ gl_type

template<typename T_VectorType, typename T_Scalar, size_t T_GL_Size, GLenum T_GL_Type>
const GLenum vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::gl_type = T_GL_Type
static

Definition at line 221 of file Array.hpp.


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