Class VertexBuffer.Builder

  • Enclosing class:
    VertexBuffer

    public static class VertexBuffer.Builder
    extends java.lang.Object
    • Constructor Detail

      • Builder

        public Builder()
    • 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 to bufferCount - 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 Builder for 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. Using byteOffset and byteStride, attributes can be interleaved in the same buffer.

        This is a no-op if the attribute is an invalid enum. This is a no-op if the bufferIndex is out of bounds.

        Warning: VertexAttribute.TANGENTS must be specified as a quaternion and is how normals are specified.

        Parameters:
        attribute - the attribute to set up
        bufferIndex - 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 buffer bufferIndex
        byteStride - stride in bytes to the next element of this attribute. When set to zero the attribute size, as defined by attributeType is used.
        Returns:
        A reference to this Builder for 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. Using byteOffset and byteStride, attributes can be interleaved in the same buffer.

        This is a no-op if the attribute is an invalid enum. This is a no-op if the bufferIndex is out of bounds.

        Warning: VertexAttribute.TANGENTS must be specified as a quaternion and is how normals are specified.

        Parameters:
        attribute - the attribute to set up
        bufferIndex - 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 Builder for 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 Builder object for chaining calls. This is a no-op if the attribute is 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 to
        enabled - true to automatically normalize the given attribute
        Returns:
        this Builder object for chaining calls. This is a no-op if the attribute is an invalid enum.
      • build

        @NonNull
        public VertexBuffer build​(@NonNull
                                  Engine engine)
        Creates the VertexBuffer object and returns a pointer to it.
        Parameters:
        engine - reference to the Engine to associate this VertexBuffer with
        Returns:
        the newly created VertexBuffer object
        Throws:
        java.lang.IllegalStateException - if the VertexBuffer could not be created