Package com.google.android.filament
Class VertexBuffer.Builder
- java.lang.Object
-
- com.google.android.filament.VertexBuffer.Builder
-
- Enclosing class:
- VertexBuffer
public static class VertexBuffer.Builder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VertexBuffer.Builderattribute(VertexBuffer.VertexAttribute attribute, int bufferIndex, VertexBuffer.AttributeType attributeType)Sets up an attribute for this vertex buffer set.VertexBuffer.Builderattribute(VertexBuffer.VertexAttribute attribute, int bufferIndex, VertexBuffer.AttributeType attributeType, int byteOffset, int byteStride)Sets up an attribute for this vertex buffer set.VertexBuffer.BuilderbufferCount(int bufferCount)Defines how many buffers will be created in this vertex buffer set.VertexBufferbuild(Engine engine)Creates theVertexBufferobject and returns a pointer to it.VertexBuffer.BuilderenableBufferObjects(boolean enabled)Allows buffers to be swapped out and shared using BufferObject.VertexBuffer.Buildernormalized(VertexBuffer.VertexAttribute attribute)Sets whether a given attribute should be normalized.VertexBuffer.Buildernormalized(VertexBuffer.VertexAttribute attribute, boolean enabled)Sets whether a given attribute should be normalized.VertexBuffer.BuildervertexCount(int vertexCount)Size of each buffer in this set, expressed in in number of vertices.
-
-
-
Method Detail
-
vertexCount
@NonNull public VertexBuffer.Builder vertexCount(@IntRange(from=1L) int vertexCount)
Size of each buffer in this set, expressed in in number of vertices.- Parameters:
vertexCount- number of vertices in each buffer in this set- Returns:
- A reference to this Builder for chaining calls.
-
enableBufferObjects
@NonNull public VertexBuffer.Builder enableBufferObjects(boolean enabled)
Allows buffers to be swapped out and shared using BufferObject. If buffer objects mode is enabled, clients must call setBufferObjectAt rather than setBufferAt. This allows sharing of data between VertexBuffer objects, but it may slightly increase the memory footprint of Filament's internal bookkeeping.- Parameters:
enabled- If true, enables buffer object mode. False by default.
-
bufferCount
@NonNull public VertexBuffer.Builder bufferCount(@IntRange(from=1L) int bufferCount)
Defines how many buffers will be created in this vertex buffer set. These buffers are later referenced by index from 0 tobufferCount- 1. This call is mandatory. The default is 0.- Parameters:
bufferCount- number of buffers in this vertex buffer set. The maximum value is 8.- Returns:
- this
Builderfor chaining calls
-
attribute
@NonNull public VertexBuffer.Builder attribute(@NonNull VertexBuffer.VertexAttribute attribute, @IntRange(from=0L) int bufferIndex, @NonNull VertexBuffer.AttributeType attributeType, @IntRange(from=0L) int byteOffset, @IntRange(from=0L) int byteStride)
Sets up an attribute for this vertex buffer set. UsingbyteOffsetandbyteStride, attributes can be interleaved in the same buffer.This is a no-op if the
attributeis an invalid enum. This is a no-op if thebufferIndexis out of bounds.Warning:
VertexAttribute.TANGENTSmust be specified as a quaternion and is how normals are specified.- Parameters:
attribute- the attribute to set upbufferIndex- the index of the buffer containing the data for this attribute. Must be between 0 and bufferCount() - 1.attributeType- the type of the attribute data (e.g. byte, float3, etc...)byteOffset- offset in bytes into the bufferbufferIndexbyteStride- stride in bytes to the next element of this attribute. When set to zero the attribute size, as defined byattributeTypeis used.- Returns:
- A reference to this
Builderfor chaining calls. - See Also:
VertexBuffer.VertexAttribute
-
attribute
@NonNull public VertexBuffer.Builder attribute(@NonNull VertexBuffer.VertexAttribute attribute, @IntRange(from=0L) int bufferIndex, @NonNull VertexBuffer.AttributeType attributeType)
Sets up an attribute for this vertex buffer set. UsingbyteOffsetandbyteStride, attributes can be interleaved in the same buffer.This is a no-op if the
attributeis an invalid enum. This is a no-op if thebufferIndexis out of bounds.Warning:
VertexAttribute.TANGENTSmust be specified as a quaternion and is how normals are specified.- Parameters:
attribute- the attribute to set upbufferIndex- the index of the buffer containing the data for this attribute. Must be between 0 and bufferCount() - 1.attributeType- the type of the attribute data (e.g. byte, float3, etc...)- Returns:
- A reference to this
Builderfor chaining calls. - See Also:
VertexBuffer.VertexAttribute
-
normalized
@NonNull public VertexBuffer.Builder normalized(@NonNull VertexBuffer.VertexAttribute attribute)
Sets whether a given attribute should be normalized. By default attributes are not normalized. A normalized attribute is mapped between 0 and 1 in the shader. This applies only to integer types.- Parameters:
attribute- enum of the attribute to set the normalization flag to- Returns:
- this
Builderobject for chaining calls. This is a no-op if theattributeis an invalid enum.
-
normalized
@NonNull public VertexBuffer.Builder normalized(@NonNull VertexBuffer.VertexAttribute attribute, boolean enabled)
Sets whether a given attribute should be normalized. By default attributes are not normalized. A normalized attribute is mapped between 0 and 1 in the shader. This applies only to integer types.- Parameters:
attribute- enum of the attribute to set the normalization flag toenabled- true to automatically normalize the given attribute- Returns:
- this
Builderobject for chaining calls. This is a no-op if theattributeis an invalid enum.
-
build
@NonNull public VertexBuffer build(@NonNull Engine engine)
Creates theVertexBufferobject and returns a pointer to it.- Parameters:
engine- reference to theEngineto associate thisVertexBufferwith- Returns:
- the newly created
VertexBufferobject - Throws:
java.lang.IllegalStateException- if the VertexBuffer could not be created
-
-