Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
G3D::IndexStream Class Reference


A stream of indices referencing into an AttributeBuffer More...

Inherits G3D::AttributeArray.

Public Member Functions

 IndexStream ()
 
template<class T >
 IndexStream (const Array< T > &source, const shared_ptr< VertexBuffer > &_area)
 
template<class T >
 IndexStream (const T *sourcePtr, int _numElements, const shared_ptr< VertexBuffer > &_area)
 
template<class T >
 IndexStream (const T &ignored, int _numElements, const shared_ptr< VertexBuffer > &dstPtr)
 
shared_ptr< VertexBufferarea ()
 
shared_ptr< VertexBufferarea () const
 
shared_ptr< VertexBufferbuffer ()
 The G3D::VertexBuffer containing this AttributeArray. More...
 
shared_ptr< VertexBufferbuffer () const
 The G3D::VertexBuffer containing this AttributeArray. More...
 
size_t elementSize () const
 Size of one element in bytes.
More...
 
uint64 generation () const
 
void * mapBuffer (GLenum permissions)
 Return a pointer to CPU-addressable memory for this AttributeArray. More...
 
size_t maxSize () const
 Maximum size that can be loaded via update into this AttributeArray. More...
 
bool normalizedFixedPoint ()
 True if this vertex is storing numbers in normalized fixed point format. More...
 
virtual GLenum openGLTarget () const
 Target argument for glBufferData and other raw OpenGL routines. More...
 
bool operator== (const AttributeArray &other) const
 
template<class T >
void set (int index, const T &value)
 Overwrites a single element of an existing array without changing the number of elements. More...
 
void setNormalizedFixedPoint (bool b)
 
int size () const
 Number of elements in this array (not byte size!) More...
 
void * startAddress () const
 For VBO_MEMORY, this is the offset. More...
 
size_t stride () const
 Space between subsequent elements in bytes, must be either zero or >= m_elementSize.
More...
 
GLenum underlyingRepresentation () const
 
void unmapBuffer ()
 Release CPU addressable memory previously returned by mapBuffer. More...
 
template<class T >
void update (const T *sourcePtr, int _numElements)
 
template<class T >
void update (const Array< T > &source)
 Overwrites existing data with data of the same size or smaller. More...
 
bool valid () const
 Returns true if this AttributeArray can be used for rendering (i.e., contains data and the parent VertexBuffer has not been reset). More...
 

Static Public Member Functions

template<class T1 , class T2 , class T3 , class T4 , class T5 >
static void createInterleaved (const Array< T1 > &src1, AttributeArray &var1, const Array< T2 > &src2, AttributeArray &var2, const Array< T3 > &src3, AttributeArray &var3, const Array< T4 > &src4, AttributeArray &var4, const Array< T5 > &src5, AttributeArray &var5, const shared_ptr< VertexBuffer > &area)
 Creates five interleaved AttributeArray arrays simultaneously. More...
 
template<class T1 , class T2 , class T3 , class T4 >
static void createInterleaved (const Array< T1 > &src1, AttributeArray &var1, const Array< T2 > &src2, AttributeArray &var2, const Array< T3 > &src3, AttributeArray &var3, const Array< T4 > &src4, AttributeArray &var4, const shared_ptr< VertexBuffer > &area)
 
template<class T1 , class T2 , class T3 , class T4 , class T5 >
static void updateInterleaved (const Array< T1 > &src1, AttributeArray &var1, const Array< T2 > &src2, AttributeArray &var2, const Array< T3 > &src3, AttributeArray &var3, const Array< T4 > &src4, AttributeArray &var4, const Array< T5 > &src5, AttributeArray &var5)
 Update a set of interleaved arrays. More...
 
template<class T1 , class T2 , class T3 , class T4 >
static void updateInterleaved (const Array< T1 > &src1, AttributeArray &var1, const Array< T2 > &src2, AttributeArray &var2, const Array< T3 > &src3, AttributeArray &var3, const Array< T4 > &src4, AttributeArray &var4)
 

Protected Member Functions

void init (AttributeArray &dstPtr, size_t dstOffset, GLenum glformat, size_t eltSize, int numElements, size_t stride, bool normalizedFixedPoint)
 For uploading interleaved arrays. More...
 
void init (const void *sourcePtr, int numElements, shared_ptr< VertexBuffer > area, GLenum glformat, size_t eltSize, bool normalizedFixedPoint)
 
void init (const void *srcPtr, int numElements, size_t srcStride, GLenum glformat, size_t eltSize, AttributeArray dstPtr, size_t dstOffset, size_t dstStride, bool normalizedFixedPoint)
 
const void * pointer () const
 May be an OpenGL video memory offset or a real memory pointer. More...
 
void set (int index, const void *value, GLenum glformat, size_t eltSize)
 
void update (const void *sourcePtr, int _numElements, GLenum glformat, size_t eltSize, bool normalizedFixedPoint)
 
void uploadToCard (const void *sourcePtr, size_t dstPtrOffsetElements, size_t size)
 Performs the actual memory transfer (like memcpy). More...
 
void uploadToCardStride (const void *sourcePtr, size_t srcElements, size_t srcSizeBytes, size_t srcStrideBytes, size_t dstPtrOffsetBytes, size_t dstStrideBytes)
 Used for creating interleaved arrays. More...
 
void vertexAttribPointer (unsigned int attribNum) const
 

Protected Attributes

shared_ptr< VertexBufferm_area
 
size_t m_elementSize
 Size of one element in bytes. More...
 
uint64 m_generation
 
size_t m_maxSize
 The initial size this AttributeArray was allocated with, in bytes. More...
 
bool m_normalizedFixedPoint
 
int m_numElements
 For a void array, this is m_maxSize. More...
 
void * m_pointer
 For VBO_MEMORY, this is the offset. More...
 
size_t m_stride
 Space between subsequent elements in bytes, must be either zero or >= m_elementSize. More...
 
GLenum m_underlyingRepresentation
 GL_NONE for a "void" array. More...
 

Detailed Description


A stream of indices referencing into an AttributeBuffer

See also
AttributeArray, VertexBuffer

(Do not take advantage of the fact that this is a subclass of AttributeArray.)

Constructor & Destructor Documentation

◆ IndexStream() [1/4]

G3D::IndexStream::IndexStream ( )
inline

◆ IndexStream() [2/4]

template<class T >
G3D::IndexStream::IndexStream ( const Array< T > &  source,
const shared_ptr< VertexBuffer > &  _area 
)
inline

◆ IndexStream() [3/4]

template<class T >
G3D::IndexStream::IndexStream ( const T *  sourcePtr,
int  _numElements,
const shared_ptr< VertexBuffer > &  _area 
)
inline

◆ IndexStream() [4/4]

template<class T >
G3D::IndexStream::IndexStream ( const T &  ignored,
int  _numElements,
const shared_ptr< VertexBuffer > &  dstPtr 
)
inline

Member Function Documentation

◆ area() [1/2]

shared_ptr<VertexBuffer> G3D::AttributeArray::area ( )
inlineinherited

◆ area() [2/2]

shared_ptr<VertexBuffer> G3D::AttributeArray::area ( ) const
inlineinherited

◆ buffer() [1/2]

shared_ptr<VertexBuffer> G3D::AttributeArray::buffer ( )
inlineinherited

The G3D::VertexBuffer containing this AttributeArray.

◆ buffer() [2/2]

shared_ptr<VertexBuffer> G3D::AttributeArray::buffer ( ) const
inlineinherited

The G3D::VertexBuffer containing this AttributeArray.

◆ createInterleaved() [1/2]

template<class T1 , class T2 , class T3 , class T4 , class T5 >
static void G3D::AttributeArray::createInterleaved ( const Array< T1 > &  src1,
AttributeArray var1,
const Array< T2 > &  src2,
AttributeArray var2,
const Array< T3 > &  src3,
AttributeArray var3,
const Array< T4 > &  src4,
AttributeArray var4,
const Array< T5 > &  src5,
AttributeArray var5,
const shared_ptr< VertexBuffer > &  area 
)
inlinestaticinherited

Creates five interleaved AttributeArray arrays simultaneously.

Creates five interleaved AttributeArray arrays simultaneously. This is convenient for uploading vertex, normal, texcoords, and tangent arrays although it can be used for any five arrays. This is substantially faster than creating a single "void AttributeArray" and uploading arrays within it using a stride.

The varn arguments are outputs only; they should not be initialized values.

All src arrays must have the same length or be empty. Empty arrays will return an uninitialized var.

See also
updateInterleaved

Referenced by G3D::AttributeArray::createInterleaved().

◆ createInterleaved() [2/2]

template<class T1 , class T2 , class T3 , class T4 >
static void G3D::AttributeArray::createInterleaved ( const Array< T1 > &  src1,
AttributeArray var1,
const Array< T2 > &  src2,
AttributeArray var2,
const Array< T3 > &  src3,
AttributeArray var3,
const Array< T4 > &  src4,
AttributeArray var4,
const shared_ptr< VertexBuffer > &  area 
)
inlinestaticinherited

◆ elementSize()

size_t G3D::AttributeArray::elementSize ( ) const
inlineinherited

Size of one element in bytes.

For a void array, this is 1.

◆ generation()

uint64 G3D::AttributeArray::generation ( ) const
inlineinherited

◆ init() [1/3]

void G3D::AttributeArray::init ( AttributeArray dstPtr,
size_t  dstOffset,
GLenum  glformat,
size_t  eltSize,
int  numElements,
size_t  stride,
bool  normalizedFixedPoint 
)
protectedinherited

For uploading interleaved arrays.

Referenced by G3D::AttributeArray::AttributeArray(), and G3D::AttributeArray::createInterleaved().

◆ init() [2/3]

void G3D::AttributeArray::init ( const void *  sourcePtr,
int  numElements,
shared_ptr< VertexBuffer area,
GLenum  glformat,
size_t  eltSize,
bool  normalizedFixedPoint 
)
protectedinherited

◆ init() [3/3]

void G3D::AttributeArray::init ( const void *  srcPtr,
int  numElements,
size_t  srcStride,
GLenum  glformat,
size_t  eltSize,
AttributeArray  dstPtr,
size_t  dstOffset,
size_t  dstStride,
bool  normalizedFixedPoint 
)
protectedinherited

◆ mapBuffer()

void* G3D::AttributeArray::mapBuffer ( GLenum  permissions)
inherited

Return a pointer to CPU-addressable memory for this AttributeArray.

The buffer must be unmapped later before any rendering calls are made. This contains a glPushClientAttrib call that must be matched by unmapBuffer.

Works for both CPU memory and VBO memory AttributeArray.

This method of moving data is not typesafe and is not recommended.

Parameters
permissionsSame as the argument to glMapBufferARB: GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE.

Referenced by G3D::AttributeArray::updateInterleaved().

◆ maxSize()

size_t G3D::AttributeArray::maxSize ( ) const
inlineinherited

Maximum size that can be loaded via update into this AttributeArray.

◆ normalizedFixedPoint()

bool G3D::AttributeArray::normalizedFixedPoint ( )
inlineinherited

True if this vertex is storing numbers in normalized fixed point format.

◆ openGLTarget()

virtual GLenum G3D::IndexStream::openGLTarget ( ) const
inlinevirtual

Target argument for glBufferData and other raw OpenGL routines.

Reimplemented from G3D::AttributeArray.

◆ operator==()

bool G3D::AttributeArray::operator== ( const AttributeArray other) const
inlineinherited

◆ pointer()

const void* G3D::AttributeArray::pointer ( ) const
inlineprotectedinherited

May be an OpenGL video memory offset or a real memory pointer.

For use by RenderDevice only.

◆ set() [1/2]

void G3D::AttributeArray::set ( int  index,
const void *  value,
GLenum  glformat,
size_t  eltSize 
)
protectedinherited

◆ set() [2/2]

template<class T >
void G3D::AttributeArray::set ( int  index,
const T &  value 
)
inlineinherited

Overwrites a single element of an existing array without changing the number of elements.

This is faster than calling update for large arrays, but slow if many set calls are made. Typically used to change a few key vertices, e.g., the single dark cap point of a directional light's shadow volume.

◆ setNormalizedFixedPoint()

void G3D::AttributeArray::setNormalizedFixedPoint ( bool  b)
inlineinherited

◆ size()

int G3D::AttributeArray::size ( ) const
inlineinherited

◆ startAddress()

void* G3D::AttributeArray::startAddress ( ) const
inlineinherited

For VBO_MEMORY, this is the offset.

For MAIN_MEMORY, this is a pointer to the block of uploaded memory.

When there was a dstOffset as a constructor argument, it has already been applied here.

◆ stride()

size_t G3D::AttributeArray::stride ( ) const
inlineinherited

Space between subsequent elements in bytes, must be either zero or >= m_elementSize.

Referenced by G3D::AttributeArray::createInterleaved().

◆ underlyingRepresentation()

GLenum G3D::AttributeArray::underlyingRepresentation ( ) const
inlineinherited

◆ unmapBuffer()

void G3D::AttributeArray::unmapBuffer ( )
inherited

Release CPU addressable memory previously returned by mapBuffer.

This method of moving data is not typesafe and is not recommended.

Referenced by G3D::AttributeArray::updateInterleaved().

◆ update() [1/3]

void G3D::AttributeArray::update ( const void *  sourcePtr,
int  _numElements,
GLenum  glformat,
size_t  eltSize,
bool  normalizedFixedPoint 
)
protectedinherited

◆ update() [2/3]

template<class T >
void G3D::AttributeArray::update ( const T *  sourcePtr,
int  _numElements 
)
inlineinherited

◆ update() [3/3]

template<class T >
void G3D::AttributeArray::update ( const Array< T > &  source)
inlineinherited

Overwrites existing data with data of the same size or smaller.

Convenient for changing part of a G3D::VertexBuffer without reseting the area (and thereby deallocating the other G3D::AttributeArray arrays in it).

◆ updateInterleaved() [1/2]

template<class T1 , class T2 , class T3 , class T4 , class T5 >
static void G3D::AttributeArray::updateInterleaved ( const Array< T1 > &  src1,
AttributeArray var1,
const Array< T2 > &  src2,
AttributeArray var2,
const Array< T3 > &  src3,
AttributeArray var3,
const Array< T4 > &  src4,
AttributeArray var4,
const Array< T5 > &  src5,
AttributeArray var5 
)
inlinestaticinherited

Update a set of interleaved arrays.

Update a set of interleaved arrays. None may change size from the original.

Referenced by G3D::AttributeArray::createInterleaved(), and G3D::AttributeArray::updateInterleaved().

◆ updateInterleaved() [2/2]

template<class T1 , class T2 , class T3 , class T4 >
static void G3D::AttributeArray::updateInterleaved ( const Array< T1 > &  src1,
AttributeArray var1,
const Array< T2 > &  src2,
AttributeArray var2,
const Array< T3 > &  src3,
AttributeArray var3,
const Array< T4 > &  src4,
AttributeArray var4 
)
inlinestaticinherited

◆ uploadToCard()

void G3D::AttributeArray::uploadToCard ( const void *  sourcePtr,
size_t  dstPtrOffsetElements,
size_t  size 
)
protectedinherited

Performs the actual memory transfer (like memcpy).

The dstPtrOffset is the number of bytes to add to m_pointer when performing the transfer.

◆ uploadToCardStride()

void G3D::AttributeArray::uploadToCardStride ( const void *  sourcePtr,
size_t  srcElements,
size_t  srcSizeBytes,
size_t  srcStrideBytes,
size_t  dstPtrOffsetBytes,
size_t  dstStrideBytes 
)
protectedinherited

Used for creating interleaved arrays.

◆ valid()

bool G3D::AttributeArray::valid ( ) const
inherited

Returns true if this AttributeArray can be used for rendering (i.e., contains data and the parent VertexBuffer has not been reset).

Referenced by G3D::UniversalSurface::GPUGeom::hasBones(), G3D::Args::hasGPUIndexStream(), and G3D::AttributeArray::maxSize().

◆ vertexAttribPointer()

void G3D::AttributeArray::vertexAttribPointer ( unsigned int  attribNum) const
protectedinherited

Member Data Documentation

◆ m_area

shared_ptr<VertexBuffer> G3D::AttributeArray::m_area
protectedinherited

◆ m_elementSize

size_t G3D::AttributeArray::m_elementSize
protectedinherited

Size of one element in bytes.

For a void array, this is 1.

Referenced by G3D::AttributeArray::elementSize(), and G3D::AttributeArray::operator==().

◆ m_generation

uint64 G3D::AttributeArray::m_generation
protectedinherited

◆ m_maxSize

size_t G3D::AttributeArray::m_maxSize
protectedinherited

The initial size this AttributeArray was allocated with, in bytes.

Referenced by G3D::AttributeArray::maxSize(), and G3D::AttributeArray::operator==().

◆ m_normalizedFixedPoint

bool G3D::AttributeArray::m_normalizedFixedPoint
protectedinherited

◆ m_numElements

int G3D::AttributeArray::m_numElements
protectedinherited

◆ m_pointer

void* G3D::AttributeArray::m_pointer
protectedinherited

For VBO_MEMORY, this is the offset.

For MAIN_MEMORY, this is a pointer to the block of uploaded memory.

When there was a dstOffset as an init() argument, it has already been applied here.

Referenced by G3D::AttributeArray::operator==(), G3D::AttributeArray::pointer(), G3D::AttributeArray::startAddress(), and G3D::AttributeArray::updateInterleaved().

◆ m_stride

size_t G3D::AttributeArray::m_stride
protectedinherited

Space between subsequent elements in bytes, must be either zero or >= m_elementSize.

Referenced by G3D::AttributeArray::operator==(), and G3D::AttributeArray::stride().

◆ m_underlyingRepresentation

GLenum G3D::AttributeArray::m_underlyingRepresentation
protectedinherited

documentation generated on Wed Nov 24 2021 08:01:57 using doxygen 1.8.15