Package com.google.android.exoplayer2.util

## 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 class` | `GlUtil.Attribute` | GL attribute, which can be attached to a buffer with `GlUtil.Attribute.setBuffer(float[], int)`.
    `static class` | `GlUtil.Uniform` | GL uniform, which can be attached to a sampler using `GlUtil.Uniform.setSamplerTexId(int, int)`.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `checkGlError()` | If there is an OpenGl error, logs the error and if `ExoPlayerLibraryInfo.GL_ASSERTIONS_ENABLED` is true throws a `RuntimeException`.
    `static int` | `compileProgram​(String[] vertexCode, String[] fragmentCode)` | Builds a GL shader program from vertex and fragment shader code.
    `static int` | `compileProgram​(String vertexCode, String fragmentCode)` | Builds a GL shader program from vertex and fragment shader code.
    `static FloatBuffer` | `createBuffer​(float[] data)` | Allocates a FloatBuffer with the given data.
    `static FloatBuffer` | `createBuffer​(int capacity)` | Allocates a FloatBuffer.
    `static int` | `createExternalTexture()` | 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 the `GlUtil.Attribute`s in the specified `program`.
    `static GlUtil.Uniform[]` | `getUniforms​(int program)` | Returns the `GlUtil.Uniform`s in the specified `program`.
    `static boolean` | `isProtectedContentExtensionSupported​(Context context)` | Returns whether creating a GL context with "EGL_EXT_protected_content" is possible.
    `static boolean` | `isSurfacelessContextExtensionSupported()` | Returns whether creating a GL context with "EGL_KHR_surfaceless_context" is possible.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### isProtectedContentExtensionSupported

          public static boolean isProtectedContentExtensionSupported​(Context context)

      Returns whether creating a GL context with "EGL_EXT_protected_content" is possible. If `true`, 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 if `ExoPlayerLibraryInfo.GL_ASSERTIONS_ENABLED` is true throws a `RuntimeException`.

    - #### 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 the `GlUtil.Attribute`s in the specified `program`.

    - #### getUniforms

          public static GlUtil.Uniform[] getUniforms​(int program)

      Returns the `GlUtil.Uniform`s in the specified `program`.

    - #### 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.