Stay organized with collections Save and categorize content based on your preferences.

MeshSpecification

public class MeshSpecification
extends Object

java.lang.Object
   ↳ android.graphics.MeshSpecification


Class responsible for holding specifications for Mesh creations. This class generates a MeshSpecification via the Make method, where multiple parameters to set up the mesh are supplied, including attributes, vertex stride, varyings, and vertex/fragment shaders. There are also additional methods to provide an optional ColorSpace as well as an alpha type. Note that there are several limitations on various mesh specifications: 1. The max amount of attributes allowed is 8. 2. The offset alignment length is 4 bytes. 2. The max stride length is 1024. 3. The max amount of varyings is 6. These should be kept in mind when generating a mesh specification, as exceeding them will lead to errors.

Summary

Nested classes

class MeshSpecification.Attribute

Data class to represent a single attribute in a shader. 

class MeshSpecification.Varying

Data class to represent a single varying variable. 

Constants

int FLOAT

Represents one float.

int FLOAT2

Represents two floats.

int FLOAT3

Represents three floats.

int FLOAT4

Represents four floats.

int OPAQUE

Pixel is opaque.

int PREMUL

Pixel components are premultiplied by alpha.

int UBYTE4

Represents four bytes.

int UNKNOWN

uninitialized.

int UNPREMULT

Pixel components are independent of alpha.

Public methods

static MeshSpecification make(List<MeshSpecification.Attribute> attributes, int vertexStride, List<MeshSpecification.Varying> varyings, String vertexShader, String fragmentShader, ColorSpace colorSpace)

Creates a MeshSpecification object.

static MeshSpecification make(List<MeshSpecification.Attribute> attributes, int vertexStride, List<MeshSpecification.Varying> varyings, String vertexShader, String fragmentShader)

Creates a MeshSpecification object for use within Mesh.

static MeshSpecification make(List<MeshSpecification.Attribute> attributes, int vertexStride, List<MeshSpecification.Varying> varyings, String vertexShader, String fragmentShader, ColorSpace colorSpace, int alphaType)

Creates a MeshSpecification object.

Inherited methods

Constants

FLOAT

public static final int FLOAT

Represents one float. Its equivalent shader type is float.

Constant Value: 0 (0x00000000)

FLOAT2

public static final int FLOAT2

Represents two floats. Its equivalent shader type is float2.

Constant Value: 1 (0x00000001)

FLOAT3

public static final int FLOAT3

Represents three floats. Its equivalent shader type is float3.

Constant Value: 2 (0x00000002)

FLOAT4

public static final int FLOAT4

Represents four floats. Its equivalent shader type is float4.

Constant Value: 3 (0x00000003)

OPAQUE

public static final int OPAQUE

Pixel is opaque.

Constant Value: 1 (0x00000001)

PREMUL

public static final int PREMUL

Pixel components are premultiplied by alpha.

Constant Value: 2 (0x00000002)

UBYTE4

public static final int UBYTE4

Represents four bytes. Its equivalent shader type is half4.

Constant Value: 4 (0x00000004)

UNKNOWN

public static final int UNKNOWN

uninitialized.

Constant Value: 0 (0x00000000)

UNPREMULT

public static final int UNPREMULT

Pixel components are independent of alpha.

Constant Value: 3 (0x00000003)

Public methods

make

public static MeshSpecification make (List<MeshSpecification.Attribute> attributes, 
                int vertexStride, 
                List<MeshSpecification.Varying> varyings, 
                String vertexShader, 
                String fragmentShader, 
                ColorSpace colorSpace)

Creates a MeshSpecification object.

Parameters
attributes List: list of attributes represented by Attribute. Can hold a max of 8. This value cannot be null.

vertexStride int: length of vertex stride in bytes. This should be the size of a single vertex' attributes. Max of 1024 is accepted.

varyings List: List of varyings represented by Varying. Can hold a max of 6. Note that `position` is provided by default, does not need to be provided in the list, and does not count towards the 6 varyings allowed. This value cannot be null.

vertexShader String: vertex shader to be supplied to the mesh. Ensure that the position varying is set within the shader to get proper results. This value cannot be null.

fragmentShader String: fragment shader to be supplied to the mesh. This value cannot be null.

colorSpace ColorSpace: ColorSpace to tell what color space to work in. This value cannot be null.

Returns
MeshSpecification MeshSpecification object for use when creating Mesh This value cannot be null.

make

public static MeshSpecification make (List<MeshSpecification.Attribute> attributes, 
                int vertexStride, 
                List<MeshSpecification.Varying> varyings, 
                String vertexShader, 
                String fragmentShader)

Creates a MeshSpecification object for use within Mesh.

Parameters
attributes List: list of attributes represented by Attribute. Can hold a max of 8. This value cannot be null.

vertexStride int: length of vertex stride in bytes. This should be the size of a single vertex' attributes. Max of 1024 is accepted.

varyings List: List of varyings represented by Varying. Can hold a max of 6. Note that `position` is provided by default, does not need to be provided in the list, and does not count towards the 6 varyings allowed. This value cannot be null.

vertexShader String: vertex shader to be supplied to the mesh. Ensure that the position varying is set within the shader to get proper results. This value cannot be null.

fragmentShader String: fragment shader to be supplied to the mesh. This value cannot be null.

Returns
MeshSpecification MeshSpecification object for use when creating Mesh This value cannot be null.

make

public static MeshSpecification make (List<MeshSpecification.Attribute> attributes, 
                int vertexStride, 
                List<MeshSpecification.Varying> varyings, 
                String vertexShader, 
                String fragmentShader, 
                ColorSpace colorSpace, 
                int alphaType)

Creates a MeshSpecification object.

Parameters
attributes List: list of attributes represented by Attribute. Can hold a max of 8. This value cannot be null.

vertexStride int: length of vertex stride in bytes. This should be the size of a single vertex' attributes. Max of 1024 is accepted.

varyings List: List of varyings represented by Varying. Can hold a max of 6. Note that `position` is provided by default, does not need to be provided in the list, and does not count towards the 6 varyings allowed. This value cannot be null.

vertexShader String: vertex shader to be supplied to the mesh. Ensure that the position varying is set within the shader to get proper results. This value cannot be null.

fragmentShader String: fragment shader to be supplied to the mesh. This value cannot be null.

colorSpace ColorSpace: ColorSpace to tell what color space to work in. This value cannot be null.

alphaType int: Describes how to interpret the alpha component for a pixel. Must be one of MeshSpecification#UNKNOWN, MeshSpecification#OPAQUE, MeshSpecification#PREMUL, or MeshSpecification#UNPREMULT Value is UNKNOWN, OPAQUE, PREMUL, or UNPREMULT

Returns
MeshSpecification MeshSpecification object for use when creating Mesh This value cannot be null.