API Reference

Class List

VertexBuffer

A vertex buffer is the mechanism via which the application specifies vertex data to the graphics hardware.

Summary

Methods

destroy

Frees resources associated with this vertex buffer.

getFormat

Returns the data format of the specified vertex buffer.

getNumVertices

Returns the number of vertices stored in the specified vertex buffer.

getUsage

Returns the usage type of the specified vertex buffer.

lock

Returns a mapped memory block representing the content of the vertex buffer.

setData

Copies data into vertex buffer's memory.

unlock

Notifies the graphics engine that the client side copy of the vertex buffer's memory can be returned to the control of the graphics driver.

Details

Constructor

VertexBuffer(graphicsDevice, format, numVertices, [usage], [initialData])

Create a new VertexBuffer instance.

Parameters

graphicsDeviceGraphicsDevice

The graphics device used to manage this vertex buffer.

formatVertexFormat

The vertex format of this vertex buffer.

numVerticesnumber

The number of vertices that this vertex buffer will hold.

usagenumber

The usage type of the vertex buffer (see BUFFER_*). Defaults to BUFFER_STATIC.

initialDataArrayBuffer

Initial data.

Methods

destroy()

Frees resources associated with this vertex buffer.

getFormat()

Returns the data format of the specified vertex buffer.

Returns

VertexFormat

The data format of the specified vertex buffer.

getNumVertices()

Returns the number of vertices stored in the specified vertex buffer.

Returns

number

The number of vertices stored in the vertex buffer.

getUsage()

Returns the usage type of the specified vertex buffer. This indicates whether the buffer can be modified once and used many times BUFFER_STATIC, modified repeatedly and used many times BUFFER_DYNAMIC or modified once and used at most a few times BUFFER_STREAM.

Returns

number

The usage type of the vertex buffer (see BUFFER_*).

lock()

Returns a mapped memory block representing the content of the vertex buffer.

Returns

ArrayBuffer

An array containing the byte data stored in the vertex buffer.

setData([data])

Copies data into vertex buffer's memory.

Parameters

dataArrayBuffer

Source data to copy.

Returns

boolean

True if function finished successfully, false otherwise.

unlock()

Notifies the graphics engine that the client side copy of the vertex buffer's memory can be returned to the control of the graphics driver.