Class GlUtil
- java.lang.Object
-
- com.google.android.exoplayer2.util.GlUtil
-
public final class GlUtil extends Object
GL utilities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGlUtil.AttributeGL attribute, which can be attached to a buffer withGlUtil.Attribute.setBuffer(float[], int).static classGlUtil.UniformGL uniform, which can be attached to a sampler usingGlUtil.Uniform.setSamplerTexId(int, int).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckGlError()If there is an OpenGl error, logs the error and ifExoPlayerLibraryInfo.GL_ASSERTIONS_ENABLEDis true throws aRuntimeException.static intcompileProgram(String[] vertexCode, String[] fragmentCode)Builds a GL shader program from vertex and fragment shader code.static intcompileProgram(String vertexCode, String fragmentCode)Builds a GL shader program from vertex and fragment shader code.static FloatBuffercreateBuffer(float[] data)Allocates a FloatBuffer with the given data.static FloatBuffercreateBuffer(int capacity)Allocates a FloatBuffer.static intcreateExternalTexture()Creates a GL_TEXTURE_EXTERNAL_OES with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.static GlUtil.Attribute[]getAttributes(int program)Returns theGlUtil.Attributes in the specifiedprogram.static GlUtil.Uniform[]getUniforms(int program)Returns theGlUtil.Uniforms in the specifiedprogram.static booleanisProtectedContentExtensionSupported(Context context)Returns whether creating a GL context with "EGL_EXT_protected_content" is possible.static booleanisSurfacelessContextExtensionSupported()Returns whether creating a GL context with "EGL_KHR_surfaceless_context" is possible.
-
-
-
Method Detail
-
isProtectedContentExtensionSupported
public static boolean isProtectedContentExtensionSupported(Context context)
Returns whether creating a GL context with "EGL_EXT_protected_content" is possible. Iftrue, the device supports a protected output path for DRM content when using GL.
-
isSurfacelessContextExtensionSupported
public static boolean isSurfacelessContextExtensionSupported()
Returns whether creating a GL context with "EGL_KHR_surfaceless_context" is possible.
-
checkGlError
public static void checkGlError()
If there is an OpenGl error, logs the error and ifExoPlayerLibraryInfo.GL_ASSERTIONS_ENABLEDis true throws aRuntimeException.
-
compileProgram
public static int compileProgram(String[] vertexCode, String[] fragmentCode)
Builds a GL shader program from vertex and fragment shader code.- Parameters:
vertexCode- GLES20 vertex shader program as arrays of strings. Strings are joined by adding a new line character in between each of them.fragmentCode- GLES20 fragment shader program as arrays of strings. Strings are joined by adding a new line character in between each of them.- Returns:
- GLES20 program id.
-
compileProgram
public static int compileProgram(String vertexCode, String fragmentCode)
Builds a GL shader program from vertex and fragment shader code.- Parameters:
vertexCode- GLES20 vertex shader program.fragmentCode- GLES20 fragment shader program.- Returns:
- GLES20 program id.
-
getAttributes
public static GlUtil.Attribute[] getAttributes(int program)
Returns theGlUtil.Attributes in the specifiedprogram.
-
getUniforms
public static GlUtil.Uniform[] getUniforms(int program)
Returns theGlUtil.Uniforms in the specifiedprogram.
-
createBuffer
public static FloatBuffer createBuffer(float[] data)
Allocates a FloatBuffer with the given data.- Parameters:
data- Used to initialize the new buffer.
-
createBuffer
public static FloatBuffer createBuffer(int capacity)
Allocates a FloatBuffer.- Parameters:
capacity- The new buffer's capacity, in floats.
-
createExternalTexture
public static int createExternalTexture()
Creates a GL_TEXTURE_EXTERNAL_OES with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.
-
-