Back to class index

Class VertexBuffer

Summary

Stores a CPU and/or GPU-side array of vertices.

Description

A vertex buffer may simultaneously contain both a CPU-side and a GPU-side array of vertex data. Use only a CPU-side vertex buffer if you need to do programmatic manipulation of vertex data and never need to submit it to GPU for rendering. Use only a GPU-side vertex buffer if you are dealing with static geometry that only needs to exist on the GPU for rendering. Use a mixed CPU+GPU-side vertex buffer if you are dynamically updating the contents of the vertex buffer, or otherwise need a shadow copy of the vertex array to be present for the vertex data.

The contents of the CPU and GPU side buffers are not automatically kept in sync, meaning that if you change the CPU-side data, you will manually need to call UpdateToGpu(); to upload that data over to the GPU-side buffer.

Member Reference

VertexBufferStores a CPU and/or GPU-side array of vertices.
hasPosPreScaleMatrixIf true, position data should be transformed through a pre-scale matrix before rendering.
posScaleSpecifies a pre-scale value to apply to the position stream of this vertex buffer when rendering.
posAddSpecifies a pre-add value to apply to the position stream of this vertex buffer when rendering.
usedVertexAttribStreamIndicesSpecifies a bitmask of the vertex attribute channel indices in use.
vertexBufferObjectPoints to the GPU-side VBO that stores the vertex data.
vertexBufferObject2Stores a second copy of the GPU-side VBO, if this buffer is updated dynamically.
gpuVertexBufferBytes2Stores the number of bytes currently stored to the VBO 2 (if using double-buffering).
vbToVsInputMappingsMaps each element in the vertex buffer to an vertex buffer input slot in the vertex shader.
nameA human-readable name to identify this VertexBuffer.
ctorConstructs a new uninitialized vertex buffer.
~dtor
ctor
operator=(rhs)
ctorConstructs a new vertex buffer with the given parameters.
Deinit()Frees up all resources used by this VertexBuffer and makes it null.
SetVertexDeclaration(decl)Sets a new format for the vertex buffer.
ConvertToVertexDeclaration(decl)Converts the vertex format of this VertexBuffer to the given vertex declaration.
Declaration()[const] (+1 overload)Returns the declaration object that specifies the structure of the vertices in this vertex buffer.
SetNumVertices(...)Specifies the new vertex count for this vertex buffer.
EraseVertices(index,numVertices)Erases vertices from the middle of the buffer.
NumVertices()[const]Returns the number of vertices in this vertex buffer.
CapacityBytes()[const]Returns the number of vertices the CPU-side allocated buffer can contain.
AppendVertices(numVertices) (+1 overload)Adds the given amount of vertices to the end of this vertex buffer (CPU-side memory).
NumPrimitives()[const]Returns the number of basic primitives (lines, triangles) specified in this vertex buffer.
SizeBytes()[const]Returns the size of the USED portion of the CPU-side vertex buffer in bytes.
VertexSizeBytes()[const]Returns the size of a single vertex in bytes.
Set(...) (+2 overloads)This is a generic setter function for assigning a value to an element of any type.
SetFloat4(...)Sets a float4 variable.
SetFloat3(...)Sets a float3 variable.
SetFloat2(...)Sets a float2 variable.
SetFloat(...)Sets a float variable.
Set(...)Sets a single attribute of a given vertex.
Get(...)[const]Reads a single attribute of a given vertex as float4.
SwapVertices(i,j)Swaps all contents of the given vertices at indices i and j.
GetPointer(vertexIndex) (+1 overload)Returns a raw pointer to the vertex at the given index in the CPU-side array of this vertex buffer.
CpuPtr() (+1 overload)Returns a pointer to the CPU-side array of vertex data, or null if no CPU-side data is present.
GetPointer(vertexIndex)[const] (+1 overload)Returns a pointer to the start of the given vertex in the CPU-side vertex buffer, or null if no CPU-side data is present.
GetOffset(vertexIndex)[const] (+1 overload)Returns the byte offset from the beginning of the vertex buffer to the start of the given vertex.
AllocateCpuMemory()Creates the CPU-side data array for this vertex buffer, if one did not yet exist.
AllocateGpuMemory(...) (+1 overload)Creates the GPU-side data array for this vertex buffer, if one did not yet exist.
UpdateToGpu()Copies the CPU-side vertex buffer data to the GPU memory.
HasCpuMemory()[const]Returns true if this vertex buffer has CPU-side data allocated.
CpuSizeBytes()[const]Returns the number of bytes in the cpu-side data array of this vertex buffer.
HasGpuMemory()[const]Returns true if this vertex buffer has GPU-side data allocated.
GpuSizeBytes()[const]Returns the number of bytes ALLOCATED (not necessarily used, which is given by numVertices) in the cpu- side data array of this vertex buffer.
FreeCpuMemory()Destroys the CPU-side vertex array, if that existed.
FreeGpuMemory()Destroys the GPU-side vertex array, if that existed.
BindToMaterial(material)Each VertexBuffer must be bound to a material before use.
IsBindingCompatibleWith(material)[const]Tests if this VertexBuffer and the given Material are compatible, so that the given material can be used when rendering the contents of this vertex buffer.
IsBoundToMaterial()[const]Returns true if this vertex buffer has been successfully bound to a material.
BoundingAABB()[const] (+1 overload)Computes the minimal bounding AABB for the vertices of this vertex buffer.
BoundingSphere()[const]Computes the optimal bounding sphere for the vertices of this vertex buffer.
ConvexHull()[const]Computes the convex hull of the vertices of this vertex buffer.
NumVerticesNeededToRenderNPrimitives(numPrimitives)[const]If this VB is an unindiced VB, tells how many vertices are needed to render the given amount of primitives.
SaveToFile(filename) (+1 overload)Saves the contents of this VertexBuffer to the given geometry file, in a binary form.
LoadFromFile(...) (+1 overload)Loads this VertexBuffer from the given binary geometry file.
Transform(matrix)
WeldVertices(...)Optimizes this vertex buffer and snaps all vertices that have positions within the given positionEpsilon, and other attributes within the given otherEpsilon threshold.
RemoveSmallTriangles(minArea)Deletes all triangles whose total surface area is less or equal to the given area.
PreScaleMatrix()[const]Returns the position prescale matrix that is used in conjunction with the geometry in this vertex buffer.
Name()[const]
Back to class index