Table Of Contents

Previous topic

21.51. The TextureManager Object

Next topic

21.53. The VMath Object

This Page

21.52. The VertexBufferManager Object

Provides allocation and freeing of ranges with in VertexBuffers.

The VertexBufferManager will create and free any VertexBuffers it requires.

Required scripts

The VertexBufferManager object requires:

/*{{ javascript("jslib/vertexbuffermanager.js") }}*/

21.52.1. Constructor

21.52.1.1. create

Summary

Syntax

var vertexBufferManager = VertexBufferManager.create(graphicsDevice, dynamic);
graphicsDevice
The GraphicsDevice object to allocate from.
dynamic
If true the VertexBuffers should be created with the dynamic flag set to true. By default the VertexBuffers are static.

21.52.2. Method

21.52.2.1. allocate

Summary

Allocate a number of vertices of a given format.

The returned object should be retained to pass to free().

Syntax

var attributes = [graphicsDevice.VERTEXFORMAT_FLOAT4,
                  graphicsDevice.VERTEXFORMAT_FLOAT4,
                  graphicsDevice.VERTEXFORMAT_FLOAT3,
                  graphicsDevice.VERTEXFORMAT_FLOAT3,
                  graphicsDevice.VERTEXFORMAT_FLOAT2];

var allocation = vertexBufferManager.allocate(numVertices , attributes);

var vertexBuffer = allocation.vertexBuffer;
var baseIndex = allocation.baseIndex;
numVertices
The number of vertices to allocate.
attributes
Vertex format. An array of vertex format strings.

The returned object has two public values:

vertexBuffer
The VertexBuffer the vertices are allocated from.
baseIndex
The first index in the buffer to use.

21.52.2.2. free

Summary

Called to free an allocation from the VertexBufferManager.

Syntax

vertexBufferManager.free(allocation);
allocation
The object returned from allocate().

21.52.2.3. destroy

Summary

Called when the object is no longer required.

Syntax

vertexBufferManager.destroy();

21.52.3. Properties

21.52.3.1. version

Summary

The version number of the VertexBufferManager implementation.

Syntax

var versionNumber = vertexBufferManager.version;