GlProgram
@UnstableApi
class GlProgram
Represents a GLSL shader program.
After constructing a program, keep a reference for its lifetime and call delete (or release the current GL context) when it's no longer needed.
Summary
Public constructors |
|---|
|
Creates a GL shader program from vertex and fragment shader GLSL GLES20 code. |
|
Compiles a GL shader program from vertex and fragment shader GLSL GLES20 code. |
Public functions |
|
|---|---|
Unit |
Binds all attributes and uniforms in the program. |
Unit |
delete()Deletes the program. |
Int |
getAttributeArrayLocationAndEnable(attributeName: String!)Returns the location of an |
Int |
getUniformLocation(uniformName: String!)Returns the location of a |
Unit |
setBufferAttribute(name: String!, values: FloatArray!, size: Int)Sets a float buffer type attribute. |
Unit |
setExternalTexturesRequireNearestSampling(Sets whether to sample external textures with GL_NEAREST. |
Unit |
setFloatUniform(name: String!, value: Float)Sets a |
Unit |
setFloatsUniform(name: String!, value: FloatArray!)Sets a |
Unit |
setFloatsUniformIfPresent(name: String!, value: FloatArray!)Sets a |
Unit |
setIntUniform(name: String!, value: Int)Sets an |
Unit |
setIntsUniform(name: String!, value: IntArray!)Sets a |
Unit |
setSamplerTexIdUniform(name: String!, texId: Int, texUnitIndex: Int)Sets a texture sampler type uniform. |
Unit |
setSamplerTexIdUniform(Sets a texture sampler type uniform. |
Unit |
use()Uses the program. |
Public constructors
GlProgram
GlProgram(vertexShaderGlsl: String!, fragmentShaderGlsl: String!)
Creates a GL shader program from vertex and fragment shader GLSL GLES20 code.
This involves slow steps, like compiling, linking, and switching the GL program, so do not call this in fast rendering loops.
GlProgram
GlProgram(
context: Context!,
vertexShaderFilePath: String!,
fragmentShaderFilePath: String!
)
Compiles a GL shader program from vertex and fragment shader GLSL GLES20 code.
| Parameters | |
|---|---|
context: Context! |
The |
vertexShaderFilePath: String! |
The path to a vertex shader program. |
fragmentShaderFilePath: String! |
The path to a fragment shader program. |
| Throws | |
|---|---|
java.io.IOException |
When failing to read shader files. |
Public functions
bindAttributesAndUniforms
fun bindAttributesAndUniforms(): Unit
Binds all attributes and uniforms in the program.
getAttributeArrayLocationAndEnable
fun getAttributeArrayLocationAndEnable(attributeName: String!): Int
Returns the location of an Attribute, which has been enabled as a vertex attribute array.
getUniformLocation
fun getUniformLocation(uniformName: String!): Int
Returns the location of a Uniform.
setBufferAttribute
fun setBufferAttribute(name: String!, values: FloatArray!, size: Int): Unit
Sets a float buffer type attribute.
setExternalTexturesRequireNearestSampling
fun setExternalTexturesRequireNearestSampling(
externalTexturesRequireNearestSampling: Boolean
): Unit
Sets whether to sample external textures with GL_NEAREST.
The default value is false.
setFloatsUniform
fun setFloatsUniform(name: String!, value: FloatArray!): Unit
Sets a float[] type uniform.
setFloatsUniformIfPresent
fun setFloatsUniformIfPresent(name: String!, value: FloatArray!): Unit
Sets a float[] type uniform if name is present, no-op otherwise.
setSamplerTexIdUniform
fun setSamplerTexIdUniform(name: String!, texId: Int, texUnitIndex: Int): Unit
Sets a texture sampler type uniform.
setSamplerTexIdUniform
fun setSamplerTexIdUniform(
name: String!,
texId: Int,
texUnitIndex: Int,
@C.TextureMinFilter texMinFilter: Int
): Unit
Sets a texture sampler type uniform.
| Parameters | |
|---|---|
name: String! |
The uniform's name. |
texId: Int |
The texture identifier. |
texUnitIndex: Int |
The texture unit index. Use a different index (0, 1, 2, ...) for each texture sampler in the program. |
@C.TextureMinFilter texMinFilter: Int |
The |