Class GlUtil.Program
- java.lang.Object
-
- com.google.android.exoplayer2.util.GlUtil.Program
-
-
Constructor Summary
Constructors Constructor Description Program(Context context, String vertexShaderFilePath, String fragmentShaderFilePath)
Compiles a GL shader program from vertex and fragment shader GLSL GLES20 code.Program(String vertexShaderGlsl, String fragmentShaderGlsl)
Creates a GL shader program from vertex and fragment shader GLSL GLES20 code.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bindAttributesAndUniforms()
Binds all attributes and uniforms in the program.void
delete()
Deletes the program.int
getAttributeArrayLocationAndEnable(String attributeName)
Returns the location of anGlUtil.Attribute
, which has been enabled as a vertex attribute array.int
getUniformLocation(String uniformName)
Returns the location of aGlUtil.Uniform
.void
setBufferAttribute(String name, float[] values, int size)
Sets a float buffer type attribute.void
setFloatsUniform(String name, float[] value)
Sets a float array type uniform.void
setFloatUniform(String name, float value)
Sets a float type uniform.void
setSamplerTexIdUniform(String name, int texId, int unit)
Sets a texture sampler type uniform.void
use()
Uses the program.
-
-
-
Constructor Detail
-
Program
public Program(Context context, String vertexShaderFilePath, String fragmentShaderFilePath) throws IOException
Compiles a GL shader program from vertex and fragment shader GLSL GLES20 code.- Parameters:
context
- TheContext
.vertexShaderFilePath
- The path to a vertex shader program.fragmentShaderFilePath
- The path to a fragment shader program.- Throws:
IOException
- When failing to read shader files.
-
Program
public Program(String vertexShaderGlsl, String fragmentShaderGlsl)
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.
- Parameters:
vertexShaderGlsl
- The vertex shader program.fragmentShaderGlsl
- The fragment shader program.
-
-
Method Detail
-
use
public void use()
Uses the program.Call this in the rendering loop to switch between different programs.
-
delete
public void delete()
Deletes the program. Deleted programs cannot be used again.
-
getAttributeArrayLocationAndEnable
public int getAttributeArrayLocationAndEnable(String attributeName)
Returns the location of anGlUtil.Attribute
, which has been enabled as a vertex attribute array.
-
getUniformLocation
public int getUniformLocation(String uniformName)
Returns the location of aGlUtil.Uniform
.
-
setBufferAttribute
public void setBufferAttribute(String name, float[] values, int size)
Sets a float buffer type attribute.
-
setSamplerTexIdUniform
public void setSamplerTexIdUniform(String name, int texId, int unit)
Sets a texture sampler type uniform.
-
setFloatUniform
public void setFloatUniform(String name, float value)
Sets a float type uniform.
-
setFloatsUniform
public void setFloatsUniform(String name, float[] value)
Sets a float array type uniform.
-
bindAttributesAndUniforms
public void bindAttributesAndUniforms()
Binds all attributes and uniforms in the program.
-
-