Added in API level 34

Mesh


open class Mesh
kotlin.Any
   ↳ android.graphics.Mesh

Class representing a mesh object. This class represents a Mesh object that can optionally be indexed. A MeshSpecification is required along with various attributes for detailing the mesh object, including a mode, vertex buffer, optional index buffer, and bounds for the mesh. Once generated, a mesh object can be drawn through Canvas.drawMesh(Mesh, BlendMode, Paint)

Summary

Constants
static Int

The mesh will be drawn with triangles without utilizing shared vertices.

static Int

The mesh will be drawn with triangles utilizing shared vertices.

Public constructors
Mesh(meshSpec: MeshSpecification, mode: Int, vertexBuffer: Buffer, vertexCount: Int, bounds: RectF)

Constructor for a non-indexed Mesh.

Mesh(meshSpec: MeshSpecification, mode: Int, vertexBuffer: Buffer, vertexCount: Int, indexBuffer: ShortBuffer, bounds: RectF)

Constructor for an indexed Mesh.

Public methods
open Unit
setColorUniform(uniformName: String, color: Color)

Sets the uniform color value corresponding to the shader assigned to the mesh.

open Unit
setColorUniform(uniformName: String, color: Int)

Sets the uniform color value corresponding to the shader assigned to the mesh.

open Unit
setColorUniform(uniformName: String, color: Long)

Sets the uniform color value corresponding to the shader assigned to the mesh.

open Unit
setFloatUniform(uniformName: String, value: Float)

Sets the uniform value corresponding to the shader assigned to the mesh.

open Unit
setFloatUniform(uniformName: String, value1: Float, value2: Float)

Sets the uniform value corresponding to the shader assigned to the mesh.

open Unit
setFloatUniform(uniformName: String, value1: Float, value2: Float, value3: Float)

Sets the uniform value corresponding to the shader assigned to the mesh.

open Unit
setFloatUniform(uniformName: String, value1: Float, value2: Float, value3: Float, value4: Float)

Sets the uniform value corresponding to the shader assigned to the mesh.

open Unit
setFloatUniform(uniformName: String, values: FloatArray)

Sets the uniform value corresponding to the shader assigned to the mesh.

open Unit
setIntUniform(uniformName: String, value: Int)

Sets the uniform value corresponding to the shader assigned to the mesh.

open Unit
setIntUniform(uniformName: String, value1: Int, value2: Int)

Sets the uniform value corresponding to the shader assigned to the mesh.

open Unit
setIntUniform(uniformName: String, value1: Int, value2: Int, value3: Int)

Sets the uniform value corresponding to the shader assigned to the mesh.

open Unit
setIntUniform(uniformName: String, value1: Int, value2: Int, value3: Int, value4: Int)

Sets the uniform value corresponding to the shader assigned to the mesh.

open Unit
setIntUniform(uniformName: String, values: IntArray)

Sets the uniform value corresponding to the shader assigned to the mesh.

Constants

TRIANGLES

Added in API level 34
static val TRIANGLES: Int

The mesh will be drawn with triangles without utilizing shared vertices.

Value: 0

TRIANGLE_STRIP

Added in API level 34
static val TRIANGLE_STRIP: Int

The mesh will be drawn with triangles utilizing shared vertices.

Value: 1

Public constructors

Mesh

Added in API level 34
Mesh(
    meshSpec: MeshSpecification,
    mode: Int,
    vertexBuffer: Buffer,
    vertexCount: Int,
    bounds: RectF)

Constructor for a non-indexed Mesh.

Parameters
meshSpec MeshSpecification: MeshSpecification used when generating the mesh. This value cannot be null.
mode Int: Determines what mode to draw the mesh in. Must be one of Mesh.TRIANGLES or Mesh.TRIANGLE_STRIP Value is android.graphics.Mesh#TRIANGLES, or android.graphics.Mesh#TRIANGLE_STRIP
vertexBuffer Buffer: vertex buffer representing through Buffer. This provides the data for all attributes provided within the meshSpec for every vertex. That is, a vertex buffer should be (attributes size * number of vertices) in length to be valid. Note that currently implementation will have a CPU backed buffer generated. This value cannot be null.
vertexCount Int: the number of vertices represented in the vertexBuffer and mesh.
bounds RectF: bounds of the mesh object. This value cannot be null.

Mesh

Added in API level 34
Mesh(
    meshSpec: MeshSpecification,
    mode: Int,
    vertexBuffer: Buffer,
    vertexCount: Int,
    indexBuffer: ShortBuffer,
    bounds: RectF)

Constructor for an indexed Mesh.

Parameters
meshSpec MeshSpecification: MeshSpecification used when generating the mesh. This value cannot be null.
mode Int: Determines what mode to draw the mesh in. Must be one of Mesh.TRIANGLES or Mesh.TRIANGLE_STRIP Value is android.graphics.Mesh#TRIANGLES, or android.graphics.Mesh#TRIANGLE_STRIP
vertexBuffer Buffer: vertex buffer representing through Buffer. This provides the data for all attributes provided within the meshSpec for every vertex. That is, a vertex buffer should be (attributes size * number of vertices) in length to be valid. Note that currently implementation will have a CPU backed buffer generated. This value cannot be null.
vertexCount Int: the number of vertices represented in the vertexBuffer and mesh.
indexBuffer ShortBuffer: index buffer representing through ShortBuffer. Indices are required to be 16 bits, so ShortBuffer is necessary. Note that currently implementation will have a CPU backed buffer generated. This value cannot be null.
bounds RectF: bounds of the mesh object. This value cannot be null.

Public methods

setColorUniform

Added in API level 34
open fun setColorUniform(
    uniformName: String,
    color: Color
): Unit

Sets the uniform color value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than vec3 or vec4 and corresponding layout(color) annotation then an IllegalArgumentExcepton is thrown.

Parameters
uniformName String: name matching the color uniform declared in the shader program. This value cannot be null.
color Color: the provided sRGB color will be converted into the shader program's output colorspace and will be made available as a vec4 uniform in the program. This value cannot be null.

setColorUniform

Added in API level 34
open fun setColorUniform(
    uniformName: String,
    color: Int
): Unit

Sets the uniform color value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than vec3 or vec4 and corresponding layout(color) annotation then an IllegalArgumentExcepton is thrown.

Parameters
uniformName String: name matching the color uniform declared in the shader program. This value cannot be null.
color Int: the provided sRGB color will be converted into the shader program's output colorspace and be available as a vec4 uniform in the program.

setColorUniform

Added in API level 34
open fun setColorUniform(
    uniformName: String,
    color: Long
): Unit

Sets the uniform color value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than vec3 or vec4 and corresponding layout(color) annotation then an IllegalArgumentExcepton is thrown.

Parameters
uniformName String: name matching the color uniform declared in the shader program. This value cannot be null.
color Long: the provided sRGB color will be converted into the shader program's output colorspace and be available as a vec4 uniform in the program.

setFloatUniform

Added in API level 34
open fun setFloatUniform(
    uniformName: String,
    value: Float
): Unit

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than a float or float[1] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the float uniform declared in the shader program. This value cannot be null.
value Float: float value corresponding to the float uniform with the given name.

setFloatUniform

Added in API level 34
open fun setFloatUniform(
    uniformName: String,
    value1: Float,
    value2: Float
): Unit

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than a vec2 or float[2] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the float uniform declared in the shader program. This value cannot be null.
value1 Float: first float value corresponding to the float uniform with the given name.
value2 Float: second float value corresponding to the float uniform with the given name.

setFloatUniform

Added in API level 34
open fun setFloatUniform(
    uniformName: String,
    value1: Float,
    value2: Float,
    value3: Float
): Unit

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than a vec3 or float[3] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the float uniform declared in the shader program. This value cannot be null.
value1 Float: first float value corresponding to the float uniform with the given name.
value2 Float: second float value corresponding to the float uniform with the given name.
value3 Float: third float value corresponding to the float unifiform with the given name.

setFloatUniform

Added in API level 34
open fun setFloatUniform(
    uniformName: String,
    value1: Float,
    value2: Float,
    value3: Float,
    value4: Float
): Unit

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than a vec4 or float[4] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the float uniform declared in the shader program. This value cannot be null.
value1 Float: first float value corresponding to the float uniform with the given name.
value2 Float: second float value corresponding to the float uniform with the given name.
value3 Float: third float value corresponding to the float uniform with the given name.
value4 Float: fourth float value corresponding to the float uniform with the given name.

setFloatUniform

Added in API level 34
open fun setFloatUniform(
    uniformName: String,
    values: FloatArray
): Unit

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than a float (for N=1), vecN, or float[N], where N is the length of the values param, then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the float uniform declared in the shader program. This value cannot be null.
values FloatArray: float value corresponding to the vec4 float uniform with the given name. This value cannot be null.

setIntUniform

Added in API level 34
open fun setIntUniform(
    uniformName: String,
    value: Int
): Unit

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than int or int[1] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the int uniform declared in the shader program. This value cannot be null.
value Int: value corresponding to the int uniform with the given name.

setIntUniform

Added in API level 34
open fun setIntUniform(
    uniformName: String,
    value1: Int,
    value2: Int
): Unit

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than ivec2 or int[2] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the int uniform declared in the shader program. This value cannot be null.
value1 Int: first value corresponding to the int uniform with the given name.
value2 Int: second value corresponding to the int uniform with the given name.

setIntUniform

Added in API level 34
open fun setIntUniform(
    uniformName: String,
    value1: Int,
    value2: Int,
    value3: Int
): Unit

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than ivec3 or int[3] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the int uniform declared in the shader program. This value cannot be null.
value1 Int: first value corresponding to the int uniform with the given name.
value2 Int: second value corresponding to the int uniform with the given name.
value3 Int: third value corresponding to the int uniform with the given name.

setIntUniform

Added in API level 34
open fun setIntUniform(
    uniformName: String,
    value1: Int,
    value2: Int,
    value3: Int,
    value4: Int
): Unit

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than ivec4 or int[4] then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the int uniform declared in the shader program. This value cannot be null.
value1 Int: first value corresponding to the int uniform with the given name.
value2 Int: second value corresponding to the int uniform with the given name.
value3 Int: third value corresponding to the int uniform with the given name.
value4 Int: fourth value corresponding to the int uniform with the given name.

setIntUniform

Added in API level 34
open fun setIntUniform(
    uniformName: String,
    values: IntArray
): Unit

Sets the uniform value corresponding to the shader assigned to the mesh. If the shader does not have a uniform with that name or if the uniform is declared with a type other than an int (for N=1), ivecN, or int[N], where N is the length of the values param, then an IllegalArgumentException is thrown.

Parameters
uniformName String: name matching the int uniform declared in the shader program. This value cannot be null.
values IntArray: int values corresponding to the vec4 int uniform with the given name. This value cannot be null.