Visualization Library 2.0.0-b3

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 | Protected Attributes | List of all members
vl::MultiDrawElements< arr_type > Class Template Reference

Wrapper for the OpenGL function glMultiDrawElements(). More...

#include <MultiDrawElements.hpp>

+ Inheritance diagram for vl::MultiDrawElements< arr_type >:

Public Types

typedef arr_type::scalar_type index_type
 

Public Member Functions

virtual unsigned int primitiveRestartIndex ()
 Returns the primitive restart index used by the draw call or 0 if primitive restart is not supported. More...
 
 MultiDrawElements (EPrimitiveType primitive=PT_TRIANGLES)
 
MultiDrawElementsoperator= (const MultiDrawElements &other)
 
virtual ref< DrawCallclone () const
 Returns a clone of the draw call. More...
 
void setIndexBuffer (arr_type *index_buffer)
 
arr_type * indexBuffer ()
 
const arr_type * indexBuffer () const
 
virtual void updateDirtyBufferObject (EBufferObjectUpdateMode mode)
 Updates the index buffer's BufferObject if marked as dirty. More...
 
virtual void deleteBufferObject ()
 Deletes the index buffer's BufferObject. More...
 
virtual void render (bool use_bo) const
 Executes the draw call. More...
 
TriangleIterator triangleIterator () const
 Returns a TriangleIterator used to iterate through the triangles of a DrawCall. More...
 
IndexIterator indexIterator () const
 Returns a IndexIterator used to iterate through the virtual indices of a DrawCall. More...
 
const std::vector< const index_type * > & pointerVector () const
 The pointer vector used as 'indices' parameter of glMultiDrawElements when NOT using BufferObjects. More...
 
std::vector< const index_type * > & pointerVector ()
 The pointer vector used as 'indices' parameter of glMultiDrawElements when NOT using BufferObjects. More...
 
const std::vector< const index_type * > & bufferObjectPointerVector () const
 The pointer vector used as 'indices' parameter of glMultiDrawElements when using BufferObjects. More...
 
std::vector< const index_type * > & bufferObjectPointerVector ()
 The pointer vector used as 'indices' parameter of glMultiDrawElements when using BufferObjects. More...
 
void computePointerVector ()
 Computes pointerVector() based on the values contained on countVector(). More...
 
void computeBufferObjectPointerVector ()
 Computes bufferObjectPointerVector() based on the values contained in pointerVector(). More...
 
- Public Member Functions inherited from vl::MultiDrawElementsBase
virtual bool primitiveRestartEnabled () const
 Returns whether the primitive-restart functionality is enabled or not. More...
 
void setPrimitiveRestartEnabled (bool enabled)
 Enables the primitive-restart functionality. More...
 
void finalizeSetup ()
 Calls computePointerVector(), computeBufferObjectPointerVector() and resizes the base vertex array to fit the count vector. More...
 
void setCountVector (const std::vector< GLsizei > &vcount)
 Sets the vector defining the length of each primitive and automatically computes the pointer vectors used to exectue glMultiDrawElements(). More...
 
void setCountVector (const GLsizei *vcount, size_t size)
 Sets the vector defining the length of each primitive and automatically computes the pointer vectors used to exectue glMultiDrawElements(). More...
 
const std::vector< GLsizei > & countVector () const
 The count vector used as 'count' parameter of glMultiDrawElements. More...
 
std::vector< GLsizei > & countVector ()
 The count vector used as 'count' parameter of glMultiDrawElements. More...
 
void setBaseVertices (const std::vector< GLint > &base_verts)
 Returns the list of base vertices, one for each primitive. More...
 
const std::vector< GLint > & baseVertices () const
 Returns the list of base vertices, one for each primitive. More...
 
std::vector< GLint > & baseVertices ()
 Returns the list of base vertices, one for each primitive. More...
 
- Public Member Functions inherited from vl::DrawCall
 DrawCall ()
 Constructor. More...
 
DrawCalloperator= (const DrawCall &other)
 Assignment operator. More...
 
void setPrimitiveType (EPrimitiveType type)
 Sets the draw call's primitive type. More...
 
EPrimitiveType primitiveType () const
 Returns the draw call's primitive type. More...
 
void setEnabled (bool enable)
 Enables/disables the draw call. More...
 
bool isEnabled () const
 True if the draw call is enabled. More...
 
u32 countIndices () const
 Counts the number of virtual indices of a DrawCall., i.e. More...
 
u32 countTriangles () const
 Counts the number of virtual triangles of a DrawCall., i.e. More...
 
virtual int instances () const
 Returns the number of instances for this set of primitives. More...
 
void setPatchParameter (PatchParameter *patch_param)
 Attach a PatchParameter to a DrawCall to be used when using primitive-type PT_PATCHES. More...
 
PatchParameterpatchParameter ()
 The PatchParameter attached to a DrawCall to be used when using primitive-type PT_PATCHES. More...
 
const PatchParameterpatchParameter () const
 The PatchParameter attached to a DrawCall to be used when using primitive-type PT_PATCHES. 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 index_type primitive_restart_index = index_type(~0)
 The special index which identifies a primitive restart. By default it is set to ~0 that is 0xFF, 0xFFFF, 0xFFFFFFFF respectively for GLubyte, GLushort, GLuint index types. */. More...
 

Protected Attributes

ref< arr_type > mIndexBuffer
 
std::vector< const index_type * > mPointerVector
 
std::vector< const index_type * > mBufferObjectPointerVector
 
- Protected Attributes inherited from vl::MultiDrawElementsBase
bool mPrimitiveRestartEnabled
 
std::vector< GLsizei > mCountVector
 
std::vector< GLint > mBaseVertices
 
- Protected Attributes inherited from vl::DrawCall
ref< PatchParametermPatchParameter
 
EPrimitiveType mType
 
bool mEnabled
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::DrawCall
void applyPatchParameters () const
 
- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

template<class arr_type>
class vl::MultiDrawElements< arr_type >

Wrapper for the OpenGL function glMultiDrawElements().

See vl::DrawCall for an overview of the different draw call methods.

This class wraps the following OpenGL functions:

Supports:

Use the functions setPrimitiveRestartIndex() and setPrimitiveRestartEnabled() to use the primitive restart functionality (requires OpenGL 3.1). For more information see http://www.opengl.org/sdk/docs/man3/xhtml/glPrimitiveRestartIndex.xml

Use the function setBaseVertices() to use the base vertex functionality. Requires OpenGL 3.2 or GL_ARB_draw_elements_base_vertex. For more information see http://www.opengl.org/sdk/docs/man3/xhtml/glMultiDrawElementsBaseVertex.xml

DrawElements, MultiDrawElements, DrawRangeElements, DrawArrays are used by Geometry to define a set of primitives to be rendered, see Geometry::drawCalls(). The indices are stored in a BufferObject and thus they can be stored locally or on the GPU. To gain direct access to the BufferObject use the indexBuffer() function.

DrawArrays, DrawElements, MultiDrawElements and DrawRangeElements are used by Geometry to define a set of primitives to be rendered.

See also
Geometry::drawCalls(), DrawCall, DrawElements, MultiDrawElements, DrawRangeElements, Geometry, Actor

Definition at line 151 of file MultiDrawElements.hpp.

Member Typedef Documentation

◆ index_type

template<class arr_type>
typedef arr_type::scalar_type vl::MultiDrawElements< arr_type >::index_type

Definition at line 156 of file MultiDrawElements.hpp.

Constructor & Destructor Documentation

◆ MultiDrawElements()

template<class arr_type>
vl::MultiDrawElements< arr_type >::MultiDrawElements ( EPrimitiveType  primitive = PT_TRIANGLES)
inline

Definition at line 162 of file MultiDrawElements.hpp.

Member Function Documentation

◆ bufferObjectPointerVector() [1/2]

template<class arr_type>
const std::vector<const index_type*>& vl::MultiDrawElements< arr_type >::bufferObjectPointerVector ( ) const
inline

The pointer vector used as 'indices' parameter of glMultiDrawElements when using BufferObjects.

Definition at line 283 of file MultiDrawElements.hpp.

◆ bufferObjectPointerVector() [2/2]

template<class arr_type>
std::vector<const index_type*>& vl::MultiDrawElements< arr_type >::bufferObjectPointerVector ( )
inline

The pointer vector used as 'indices' parameter of glMultiDrawElements when using BufferObjects.

Definition at line 286 of file MultiDrawElements.hpp.

◆ clone()

template<class arr_type>
virtual ref<DrawCall> vl::MultiDrawElements< arr_type >::clone ( ) const
inlinevirtual

Returns a clone of the draw call.

Implements vl::DrawCall.

Definition at line 179 of file MultiDrawElements.hpp.

◆ computeBufferObjectPointerVector()

template<class arr_type>
void vl::MultiDrawElements< arr_type >::computeBufferObjectPointerVector ( )
inlinevirtual

Computes bufferObjectPointerVector() based on the values contained in pointerVector().

Implements vl::MultiDrawElementsBase.

Definition at line 302 of file MultiDrawElements.hpp.

◆ computePointerVector()

template<class arr_type>
void vl::MultiDrawElements< arr_type >::computePointerVector ( )
inlinevirtual

Computes pointerVector() based on the values contained on countVector().

Implements vl::MultiDrawElementsBase.

Definition at line 289 of file MultiDrawElements.hpp.

◆ deleteBufferObject()

template<class arr_type>
virtual void vl::MultiDrawElements< arr_type >::deleteBufferObject ( )
inlinevirtual

Deletes the index buffer's BufferObject.

Implements vl::DrawCall.

Definition at line 198 of file MultiDrawElements.hpp.

◆ indexBuffer() [1/2]

template<class arr_type>
arr_type* vl::MultiDrawElements< arr_type >::indexBuffer ( )
inline

◆ indexBuffer() [2/2]

template<class arr_type>
const arr_type* vl::MultiDrawElements< arr_type >::indexBuffer ( ) const
inline

Definition at line 190 of file MultiDrawElements.hpp.

◆ indexIterator()

template<class arr_type>
IndexIterator vl::MultiDrawElements< arr_type >::indexIterator ( ) const
inlinevirtual

Returns a IndexIterator used to iterate through the virtual indices of a DrawCall.

This

Note
The returned indices already take into account primitive restart and base vertex.

Implements vl::DrawCall.

Definition at line 266 of file MultiDrawElements.hpp.

◆ operator=()

template<class arr_type>
MultiDrawElements& vl::MultiDrawElements< arr_type >::operator= ( const MultiDrawElements< arr_type > &  other)
inline

Definition at line 170 of file MultiDrawElements.hpp.

◆ pointerVector() [1/2]

template<class arr_type>
const std::vector<const index_type*>& vl::MultiDrawElements< arr_type >::pointerVector ( ) const
inline

The pointer vector used as 'indices' parameter of glMultiDrawElements when NOT using BufferObjects.

Automatically computed when calling setCountVector(). If you need to modify this manually then you also have to modify the bufferObjectPointerVector.

Definition at line 277 of file MultiDrawElements.hpp.

◆ pointerVector() [2/2]

template<class arr_type>
std::vector<const index_type*>& vl::MultiDrawElements< arr_type >::pointerVector ( )
inline

The pointer vector used as 'indices' parameter of glMultiDrawElements when NOT using BufferObjects.

Definition at line 280 of file MultiDrawElements.hpp.

◆ primitiveRestartIndex()

template<class arr_type>
virtual unsigned int vl::MultiDrawElements< arr_type >::primitiveRestartIndex ( )
inlinevirtual

Returns the primitive restart index used by the draw call or 0 if primitive restart is not supported.

Reimplemented from vl::DrawCall.

Definition at line 159 of file MultiDrawElements.hpp.

◆ render()

template<class arr_type>
virtual void vl::MultiDrawElements< arr_type >::render ( bool  use_bo) const
inlinevirtual

Executes the draw call.

Implements vl::DrawCall.

Definition at line 203 of file MultiDrawElements.hpp.

◆ setIndexBuffer()

template<class arr_type>
void vl::MultiDrawElements< arr_type >::setIndexBuffer ( arr_type *  index_buffer)
inline

Definition at line 186 of file MultiDrawElements.hpp.

Referenced by vl::DaeLoader::generateGeometry().

◆ triangleIterator()

template<class arr_type >
TriangleIterator vl::MultiDrawElements< arr_type >::triangleIterator ( ) const
virtual

Returns a TriangleIterator used to iterate through the triangles of a DrawCall.

Basically the iterator tesselates in triangles any DrawCall of type: PT_TRIANGLES, PT_TRIANGLE_STRIP PT_TRIANGLE_FAN, PT_POLYGON, PT_QUADS, PT_QUAD_STRIP.

Implements vl::DrawCall.

Definition at line 363 of file MultiDrawElements.hpp.

◆ updateDirtyBufferObject()

template<class arr_type>
virtual void vl::MultiDrawElements< arr_type >::updateDirtyBufferObject ( EBufferObjectUpdateMode  )
inlinevirtual

Updates the index buffer's BufferObject if marked as dirty.

Implements vl::DrawCall.

Definition at line 192 of file MultiDrawElements.hpp.

Member Data Documentation

◆ mBufferObjectPointerVector

template<class arr_type>
std::vector<const index_type*> vl::MultiDrawElements< arr_type >::mBufferObjectPointerVector
protected

Definition at line 318 of file MultiDrawElements.hpp.

◆ mIndexBuffer

template<class arr_type>
ref< arr_type > vl::MultiDrawElements< arr_type >::mIndexBuffer
protected

Definition at line 316 of file MultiDrawElements.hpp.

◆ mPointerVector

template<class arr_type>
std::vector<const index_type*> vl::MultiDrawElements< arr_type >::mPointerVector
protected

Definition at line 317 of file MultiDrawElements.hpp.

◆ primitive_restart_index

template<class arr_type>
const index_type vl::MultiDrawElements< arr_type >::primitive_restart_index = index_type(~0)
static

The special index which identifies a primitive restart. By default it is set to ~0 that is 0xFF, 0xFFFF, 0xFFFFFFFF respectively for GLubyte, GLushort, GLuint index types. */.

Definition at line 158 of file MultiDrawElements.hpp.


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