|
| AttributeArray () |
| Creates an invalid AttributeArray. More...
|
|
| AttributeArray (size_t numBytes, const shared_ptr< VertexBuffer > &_area) |
| Creates a AttributeArray that acts as a pointer to a block of memory. More...
|
|
template<class T > |
| AttributeArray (const T *sourcePtr, int _numElements, const shared_ptr< VertexBuffer > &_area) |
| Uploads memory from the CPU to the GPU. More...
|
|
template<class T > |
| AttributeArray (const Array< T > &source, const shared_ptr< VertexBuffer > &_area) |
|
template<class T > |
| AttributeArray (const T *srcPtr, size_t _numElements, size_t srcStride, AttributeArray dstPtr, size_t dstOffset, size_t dstStride) |
| Create an interleaved array within an existing AttributeArray and upload data to it. More...
|
|
template<class T > |
| AttributeArray (const T &ignored, int _numElements, AttributeArray dstPtr, size_t dstOffset, size_t dstStride) |
| Create an interleaved array within an existing AttributeArray, but do not upload data to it. More...
|
|
template<class T > |
| AttributeArray (const T &ignored, int _numElements, shared_ptr< VertexBuffer > dstPtr) |
| Allocate a vertex range within a vertex buffer with no offset, but do not upload data to it. More...
|
|
template<class T > |
| AttributeArray (const Array< T > &source, AttributeArray dstPtr, size_t dstOffset, size_t dstStride) |
|
virtual | ~AttributeArray () |
|
shared_ptr< VertexBuffer > | area () |
|
shared_ptr< VertexBuffer > | area () const |
|
shared_ptr< VertexBuffer > | buffer () |
| The G3D::VertexBuffer containing this AttributeArray. More...
|
|
shared_ptr< VertexBuffer > | buffer () 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...
|
|
|
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) |
|
|
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 |
|
A block of GPU memory storing a stream of vector data (e.g., vertices, normals, texture coordinates)
A pointer to a "Vertex Arrray" of data (e.g., vertices, colors, or normals) in video memory.
A AttributeArray is just a pointer, so it is safe to copy these (the pointer will be copied, not the video memory).
There is no destructor because the referenced memory is freed when the parent VertexBuffer is reset or freed.
A AttributeArray is normally a statically typed fixed-length array of a Vector or Color class, however it is possible to make a "void" array with the constructor that does not take an array, and then fill it with data to create interleaved or structure arrays. Interleaved arrays are 2x - 3x as fast as non-interleaved ones for vertex-limited programs.
template<class T >
G3D::AttributeArray::AttributeArray |
( |
const T & |
ignored, |
|
|
int |
_numElements, |
|
|
AttributeArray |
dstPtr, |
|
|
size_t |
dstOffset, |
|
|
size_t |
dstStride |
|
) |
| |
|
inline |
Create an interleaved array within an existing AttributeArray, but do not upload data to it.
Data can later be uploaded by update() or mapBuffer().
Example:
G3D_BEGIN_PACKED_CLASS
struct Packed {
Vector3 vertex;
Vector2 texcoord;
}
G3D_END_PACKED_CLASS
...
int stride = sizeof(Vector3) + sizeof(Vector2);
int totalSize = stride * N;
AttributeArray interleavedBlock(totalSize, area);
AttributeArray vertex(Vector3() N, interleavedBlock, 0, stride);
AttributeArray texcoord(Vector2(), N, interleavedBlock, sizeof(Vector3), stride);
Packed* ptr = (Packed*)interleavedBlock.mapBuffer(GL_WRITE_ONLY);
// ... write to elements of ptr ...
interleavedBlock.unmapBuffer();
- Parameters
-
dstStride | If non-zero, this is the spacing between sequential elements of T in dstPtr. e.g., to upload every other Vector3, use dstStride = sizeof(Vector3) * 2 . May not be negative. |
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 |
|
) |
| |
|
inlinestatic |
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 createInterleaved().