Main Page   Modules   Class Hierarchy   Compound List   Compound Members  

GAUGE3D::GStridedArray Class Template Reference

Represents a strided or interleaved array. More...

#include <gauge3d/array.h>

List of all members.

Public Methods

 GStridedArray ()
 Create NULL array.

 GStridedArray (tType *ptr,int stride)
 Create array that starts at ptr with given stride.

 GStridedArray (tType *ptr)
 Create array using non-strided data.

const tType& operator[] (int index)const
 Array access.

tType& operator[] (int index)
 Array access.

int Stride ()
 Get the stride.

 operator tType * ()const
 Cast to type.

bool operator== (const void *other)
 Test for equality with pointer.


Detailed Description

template<class tType> class GAUGE3D::GStridedArray

Represents a strided or interleaved array.

This class allows you to create an array with space between the elements. This is useful for interleaved data, where you have two types of interleaved into one big array.

The stride of the array is the distance in bytes between the beginning of one array element and the beginning of the next. For example, say you wanted to interleave a set of vertex positions and normals. So, you have an array: GVector* data = new GVector[numVertices * 2]; In that array, the even-numbered elements are vertex positions while the odd-numbered elements are vertex normals (starting at zero). Then, you could create two strided arrays like so: GStridedArray<GVector> vertices(data, sizeof(GVector)*2); GStridedArray<GVector> normals(data + 1, sizeof(GVector)*2); Then, you could access "vertices" and "normals" as if they were regular arrays.

Note that GStridedArray is NOT reference-counted, unlike GArray.


The documentation for this class was generated from the following file:
Generated at Tue Jan 30 17:07:34 2001 for gauge3d by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000