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 |
ALPHA_TYPE_OPAQUE
Pixel is opaque. |
int |
ALPHA_TYPE_PREMUL
Pixel components are premultiplied by alpha. |
int |
ALPHA_TYPE_PREMULT
Pixel components are independent of alpha. |
int |
ALPHA_TYPE_UNKNOWN
uninitialized. |
int |
TYPE_FLOAT
Represents one float. |
int |
TYPE_FLOAT2
Represents two floats. |
int |
TYPE_FLOAT3
Represents three floats. |
int |
TYPE_FLOAT4
Represents four floats. |
int |
TYPE_UBYTE4
Represents four bytes. |
Public methods | |
|---|---|
static
MeshSpecification
|
make(Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader, ColorSpace colorSpace, int alphaType)
Creates a |
static
MeshSpecification
|
make(Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader, ColorSpace colorSpace)
Creates a |
static
MeshSpecification
|
make(Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader)
Creates a |
Inherited methods | |
|---|---|
Constants
ALPHA_TYPE_OPAQUE
public static final int ALPHA_TYPE_OPAQUE
Pixel is opaque.
Constant Value: 1 (0x00000001)
ALPHA_TYPE_PREMUL
public static final int ALPHA_TYPE_PREMUL
Pixel components are premultiplied by alpha.
Constant Value: 2 (0x00000002)
ALPHA_TYPE_PREMULT
public static final int ALPHA_TYPE_PREMULT
Pixel components are independent of alpha.
Constant Value: 3 (0x00000003)
ALPHA_TYPE_UNKNOWN
public static final int ALPHA_TYPE_UNKNOWN
uninitialized.
Constant Value: 0 (0x00000000)
TYPE_FLOAT
public static final int TYPE_FLOAT
Represents one float. Its equivalent shader type is float.
Constant Value: 0 (0x00000000)
TYPE_FLOAT2
public static final int TYPE_FLOAT2
Represents two floats. Its equivalent shader type is float2.
Constant Value: 1 (0x00000001)
TYPE_FLOAT3
public static final int TYPE_FLOAT3
Represents three floats. Its equivalent shader type is float3.
Constant Value: 2 (0x00000002)
TYPE_FLOAT4
public static final int TYPE_FLOAT4
Represents four floats. Its equivalent shader type is float4.
Constant Value: 3 (0x00000003)
TYPE_UBYTE4
public static final int TYPE_UBYTE4
Represents four bytes. Its equivalent shader type is half4.
Constant Value: 4 (0x00000004)
Public methods
make
public static MeshSpecification make (Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader, ColorSpace colorSpace, int alphaType)
Creates a MeshSpecification object.
| Parameters | |
|---|---|
attributes |
Attribute: 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.
Value is between 1 and 1024 inclusive |
varyings |
Varying: 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#ALPHA_TYPE_UNKNOWN,
MeshSpecification#ALPHA_TYPE_OPAQUE,
MeshSpecification#ALPHA_TYPE_PREMUL, or
MeshSpecification#ALPHA_TYPE_PREMULT
Value is ALPHA_TYPE_UNKNOWN, ALPHA_TYPE_OPAQUE, ALPHA_TYPE_PREMUL, or ALPHA_TYPE_PREMULT |
| Returns | |
|---|---|
MeshSpecification |
MeshSpecification object for use when creating Mesh
This value cannot be null. |
make
public static MeshSpecification make (Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader, ColorSpace colorSpace)
Creates a MeshSpecification object. This uses a default AlphaType of ALPHA_TYPE_PREMUL.
| Parameters | |
|---|---|
attributes |
Attribute: 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.
Value is between 1 and 1024 inclusive |
varyings |
Varying: 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 (Attribute[] attributes, int vertexStride, Varying[] varyings, String vertexShader, String fragmentShader)
Creates a MeshSpecification object for use within Mesh. This uses a default
color space of ColorSpace.Named#SRGB and AlphaType of ALPHA_TYPE_PREMUL.
| Parameters | |
|---|---|
attributes |
Attribute: 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.
Value is between 1 and 1024 inclusive |
varyings |
Varying: 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. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2023-03-08 UTC.

