A block of GPU memory storing a stream of vector data (e.g., vertices, normals, texture coordinates)
More...
|
| | VertexRange () |
| | Creates an invalid VertexRange.
|
| |
| | VertexRange (size_t numBytes, VertexBufferRef _area) |
| | Creates a VertexRange that acts as a pointer to a block of memory.
|
| |
| template<class T > |
| | VertexRange (const T *sourcePtr, int _numElements, VertexBufferRef _area) |
| | Uploads memory from the CPU to the GPU.
|
| |
| template<class T > |
| | VertexRange (const Array< T > &source, VertexBufferRef _area) |
| |
| template<class T > |
| | VertexRange (const T *srcPtr, size_t _numElements, size_t srcStride, VertexRange dstPtr, size_t dstOffset, size_t dstStride) |
| | Create an interleaved array within an existing VertexRange and upload data to it.
|
| |
| template<class T > |
| | VertexRange (const T &ignored, int _numElements, VertexRange dstPtr, size_t dstOffset, size_t dstStride) |
| | Create an interleaved array within an existing VertexRange, but do not upload data to it.
|
| |
| template<class T > |
| | VertexRange (const T &ignored, int _numElements, VertexBuffer::Ref dstPtr) |
| | Allocate a vertex range within a vertex buffer with no offset, but do not upload data to it.
|
| |
| template<class T > |
| | VertexRange (const Array< T > &source, VertexRange dstPtr, size_t dstOffset, size_t dstStride) |
| |
| VertexBuffer::Ref | area () |
| |
| VertexBuffer::Ref G3D_DEPRECATED | area () const |
| |
| VertexBuffer::Ref | buffer () |
| | The G3D::VertexBuffer containing this VertexRange.
|
| |
| VertexBuffer::Ref | buffer () const |
| | The G3D::VertexBuffer containing this VertexRange.
|
| |
| size_t | elementSize () const |
| |
|
| |
| uint64 | generation () const |
| |
| void * | mapBuffer (GLenum permissions) |
| | Return a pointer to CPU-addressable memory for this VertexRange.
|
| |
| size_t | maxSize () const |
| | Maximum size that can be loaded via update into this VertexRange.
|
| |
| bool | normalizedFixedPoint () |
| | True if this vertex is storing numbers in normalized fixed point format.
|
| |
| bool | operator== (const VertexRange &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.
|
| |
| void | setNormalizedFixedPoint (bool b) |
| |
| int | size () const |
| | Number of elements in this array (not byte size!)
|
| |
| void * | startAddress () |
| | For VBO_MEMORY, this is the offset.
|
| |
| size_t | stride () const |
| |
|
| |
| VertexBuffer::Type | type () const |
| |
| GLenum | underlyingRepresentation () const |
| |
| void | unmapBuffer () |
| | Release CPU addressable memory previously returned by mapBuffer.
|
| |
| 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.
|
| |
| bool | valid () const |
| | Returns true if this VertexRange can be used for rendering (i.e., contains data and the parent VertexBuffer has not been reset).
|
| |
|
| template<class T1 , class T2 , class T3 , class T4 , class T5 > |
| static void | createInterleaved (const Array< T1 > &src1, VertexRange &var1, const Array< T2 > &src2, VertexRange &var2, const Array< T3 > &src3, VertexRange &var3, const Array< T4 > &src4, VertexRange &var4, const Array< T5 > &src5, VertexRange &var5, VertexBufferRef area) |
| | Creates five interleaved VertexRange arrays simultaneously.
|
| |
| template<class T1 , class T2 , class T3 , class T4 > |
| static void | createInterleaved (const Array< T1 > &src1, VertexRange &var1, const Array< T2 > &src2, VertexRange &var2, const Array< T3 > &src3, VertexRange &var3, const Array< T4 > &src4, VertexRange &var4, VertexBufferRef area) |
| |
| template<class T1 , class T2 , class T3 , class T4 , class T5 > |
| static void | updateInterleaved (const Array< T1 > &src1, VertexRange &var1, const Array< T2 > &src2, VertexRange &var2, const Array< T3 > &src3, VertexRange &var3, const Array< T4 > &src4, VertexRange &var4, const Array< T5 > &src5, VertexRange &var5) |
| | Update a set of interleaved arrays.
|
| |
| template<class T1 , class T2 , class T3 , class T4 > |
| static void | updateInterleaved (const Array< T1 > &src1, VertexRange &var1, const Array< T2 > &src2, VertexRange &var2, const Array< T3 > &src3, VertexRange &var3, const Array< T4 > &src4, VertexRange &var4) |
| |
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 VertexRange 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 VertexRange 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::VertexRange::VertexRange |
( |
const T & |
ignored, |
|
|
int |
_numElements, |
|
|
VertexRange |
dstPtr, |
|
|
size_t |
dstOffset, |
|
|
size_t |
dstStride |
|
) |
| |
|
inline |
Create an interleaved array within an existing VertexRange, but do not upload data to it.
Data can later be uploaded by update() or mapBuffer().
Example:
<PRE>
G3D_BEGIN_PACKED_CLASS
struct Packed {
Vector3 vertex;
Vector2 texcoord;
}
G3D_END_PACKED_CLASS
...
int stride = sizeof(Vector3) + sizeof(Vector2);
int totalSize = stride * N;
VertexRange interleavedBlock(totalSize, area);
VertexRange vertex(Vector3() N, interleavedBlock, 0, stride);
VertexRange 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::VertexRange::createInterleaved |
( |
const Array< T1 > & |
src1, |
|
|
VertexRange & |
var1, |
|
|
const Array< T2 > & |
src2, |
|
|
VertexRange & |
var2, |
|
|
const Array< T3 > & |
src3, |
|
|
VertexRange & |
var3, |
|
|
const Array< T4 > & |
src4, |
|
|
VertexRange & |
var4, |
|
|
const Array< T5 > & |
src5, |
|
|
VertexRange & |
var5, |
|
|
VertexBufferRef |
area |
|
) |
| |
|
inlinestatic |
Creates five interleaved VertexRange arrays simultaneously.
Creates five interleaved VertexRange 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 VertexRange" 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().