Table Of Contents

Previous topic

17. Low Level API

Next topic

17.2. The TurbulenzEngine Object

This Page

17.1. The DrawParameters Object

A DrawParameters object is a collection of state used by the renderer to render an object. Its purpose is to provide an efficient way to draw large number of objects. They are rendered with GraphicsDevice.drawArray().

A Renderable generates a collection of these that are processed by the renderers, ordering them by pass.

They are created using GraphicsDevice.createDrawParameters().

17.1.1. Methods

17.1.1.1. setTechniqueParameters

Summary

Sets an element of the array of TechniqueParameters objects.

These are applied in order when an object is rendered. They are applied after any global techniqueParameters the renderers set for each technique.

Syntax

drawParameters.setTechniqueParameters(index, techniqueParameters);
index
An index in to the array. Valid values are 0 to 7.
techniqueParameters
A techniqueParameters object. This can be null to clear previously set values.

17.1.1.2. setVertexBuffer

Summary

Sets an element of the array of VertexBuffers objects.

There should be an equal number of Semantics and VertexBuffers.

Syntax

drawParameters.setVertexBuffer(index,  vertexBuffer);
drawParameters.setSemantics(index,  semantics);
index
An index in to the array. Valid values are 0 to 15.
vertexBuffer
A vertexBuffer object. This can be null to clear previously set values.

17.1.1.3. setSemantics

Summary

Sets an element of the array of Semantics objects.

There should be an equal number of Semantics and VertexBuffers.

Syntax

drawParameters.setVertexBuffer(index,  vertexBuffer);
drawParameters.setSemantics(index,  semantics);
index
An index in to the array. Valid values are 0 to 15.
semantics
A semantics object. This can be null to clear previously set values.

17.1.1.4. setOffset

Summary

Sets an element of the array of offsets. The offsets are the index in the appropriate VertexBuffer that the index calls are relevant to.

These are 0 by default.

Syntax

drawParameters.setVertexBuffer(index,  vertexBuffer);
drawParameters.setSemantics(index,  semantics);
drawParameters.setOffset(index,  offset);
index
An index in to the array. Valid values are 0 to 15.
offset
The offset value.

17.1.1.5. getTechniqueParameters

Summary

Gets an element of the array of TechniqueParameters objects.

Syntax

var techniqueParameters = drawParameters.getTechniqueParameters(index);
index
An index in to the array. Valid values are 0 to 7.

Returns a TechniqueParameters object, which may be null.

17.1.1.6. getVertexBuffer

Summary

Gets an element of the array of VertexBuffers objects.

Syntax

var vertexBuffer = drawParameters.getVertexBuffer(index);
index
An index in to the array. Valid values are 0 to 15.

Returns a VertexBuffers object, which may be null.

17.1.1.7. getSemantics

Summary

Gets an element of the array of Semantics objects.

Syntax

var semantics = drawParameters.getSemantics(index);
index
An index in to the array. Valid values are 0 to 15.

Returns a Semantics object, which may be null.

17.1.1.8. getOffset

Summary

Gets an element of the array of offsets.

Syntax

var offset = drawParameters.getOffset(index);
index
An index in to the array. Valid values are 0 to 15.

Returns a number.

17.1.2. Properties

17.1.2.1. technique

Summary

The Technique object to render with.

Syntax

drawParameters.technique = shader.getTechnique(techniqueName);

17.1.2.2. primitive

Summary

The kind of Primitive.

Syntax

drawParameters.primitive = graphicsDevice.PRIMITIVE_TRIANGLES;

17.1.2.3. indexBuffer

Summary

Use for drawing indexed primitives with an IndexBuffer. If this is set then count must also be specified.

See count and firstIndex for non-indexed primitives.

Syntax

drawParameters.indexBuffer = indexBuffer;
drawParameters.numIndices = numIndices;

17.1.2.4. count

Summary

If the indexBuffer is set then this is the number of indices to draw.

If the indexBuffer is not set then this is the number of vertices to draw.

Syntax

drawParameters.indexBuffer = indexBuffer;
drawParameters.count = numIndices;

or

drawParameters.count = numVertices;
drawParameters.firstIndex = firstIndex;

17.1.2.5. firstIndex

Summary

If the indexBuffer is set then this is the offset in the IndexBuffer of the first index to be used.

If the indexBuffer is not set then this is the index in the VertexBuffer of first vertex to use.

It defaults to 0.

Syntax

drawParameters.count = numVertices;
drawParameters.firstIndex = firstIndex;

17.1.2.6. sortKey

Summary

A number used to sort arrays of DrawParameters by. Typically for transparent passes this would be distance and for opaque passes a value designed for efficiency, e.g. grouping objects with the same technique together.

It defaults to 0.

Syntax

drawParameters.sortKey = object.distance;

17.1.2.7. userData

Summary

An object for custom use. When using the JSLib renderers this object has the passIndex attached to it.

Syntax

drawParameters.userData.passIndex = renderer.passIndex.transparent;