Class GlUtil


  • @Deprecated
    public final class GlUtil
    extends Object
    Deprecated.
    com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
    OpenGL ES utilities.
    • Field Detail

      • HOMOGENEOUS_COORDINATE_VECTOR_SIZE

        public static final int HOMOGENEOUS_COORDINATE_VECTOR_SIZE
        Deprecated.
        Number of elements in a 3d homogeneous coordinate vector describing a vertex.
        See Also:
        Constant Field Values
      • LENGTH_NDC

        public static final float LENGTH_NDC
        Deprecated.
        Length of the normalized device coordinate (NDC) space, which spans from -1 to 1.
        See Also:
        Constant Field Values
      • EGL_CONFIG_ATTRIBUTES_RGBA_8888

        public static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_8888
        Deprecated.
      • EGL_CONFIG_ATTRIBUTES_RGBA_1010102

        public static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_1010102
        Deprecated.
    • Method Detail

      • getNormalizedCoordinateBounds

        public static float[] getNormalizedCoordinateBounds()
        Deprecated.
        Bounds of normalized device coordinates, commonly used for defining viewport boundaries.
      • getTextureCoordinateBounds

        public static float[] getTextureCoordinateBounds()
        Deprecated.
        Typical bounds used for sampling from textures.
      • create4x4IdentityMatrix

        public static float[] create4x4IdentityMatrix()
        Deprecated.
        Creates a 4x4 identity matrix.
      • setToIdentity

        public static void setToIdentity​(float[] matrix)
        Deprecated.
        Sets the input matrix to an identity matrix.
      • createVertexBuffer

        public static float[] createVertexBuffer​(List<float[]> vertexList)
        Deprecated.
        Flattens the list of 4 element NDC coordinate vectors into a buffer.
      • isProtectedContentExtensionSupported

        public static boolean isProtectedContentExtensionSupported​(Context context)
        Deprecated.
        Returns whether creating a GL context with EXTENSION_PROTECTED_CONTENT is possible.

        If true, the device supports a protected output path for DRM content when using GL.

      • isYuvTargetExtensionSupported

        public static boolean isYuvTargetExtensionSupported()
        Deprecated.
        Returns whether the EXTENSION_YUV_TARGET extension is supported.

        This extension allows sampling raw YUV values from an external texture, which is required for HDR input.

      • isBt2020PqExtensionSupported

        public static boolean isBt2020PqExtensionSupported()
        Deprecated.
        Returns whether EXTENSION_COLORSPACE_BT2020_PQ is supported.
      • getCurrentContext

        public static EGLContext getCurrentContext()
        Deprecated.
        Gets the current context.
      • clearOutputFrame

        public static void clearOutputFrame()
                                     throws GlUtil.GlException
        Deprecated.
        Fills the pixels in the current output render target with (r=0, g=0, b=0, a=0).
        Throws:
        GlUtil.GlException
      • focusEglSurface

        @RequiresApi(17)
        public static void focusEglSurface​(EGLDisplay eglDisplay,
                                           EGLContext eglContext,
                                           EGLSurface eglSurface,
                                           int width,
                                           int height)
                                    throws GlUtil.GlException
        Deprecated.
        Makes the specified eglSurface the render target, using a viewport of width by height pixels.
        Throws:
        GlUtil.GlException
      • focusFramebuffer

        @RequiresApi(17)
        public static void focusFramebuffer​(EGLDisplay eglDisplay,
                                            EGLContext eglContext,
                                            EGLSurface eglSurface,
                                            int framebuffer,
                                            int width,
                                            int height)
                                     throws GlUtil.GlException
        Deprecated.
        Makes the specified framebuffer the render target, using a viewport of width by height pixels.
        Throws:
        GlUtil.GlException
      • focusFramebufferUsingCurrentContext

        @RequiresApi(17)
        public static void focusFramebufferUsingCurrentContext​(int framebuffer,
                                                               int width,
                                                               int height)
                                                        throws GlUtil.GlException
        Deprecated.
        Makes the specified framebuffer the render target, using a viewport of width by height pixels.

        The caller must ensure that there is a current OpenGL context before calling this method.

        Parameters:
        framebuffer - The identifier of the framebuffer object to bind as the output render target.
        width - The viewport width, in pixels.
        height - The viewport height, in pixels.
        Throws:
        GlUtil.GlException
      • createBuffer

        public static FloatBuffer createBuffer​(float[] data)
        Deprecated.
        Allocates a FloatBuffer with the given data.
        Parameters:
        data - Used to initialize the new buffer.
      • createExternalTexture

        public static int createExternalTexture()
                                         throws GlUtil.GlException
        Deprecated.
        Creates a GL_TEXTURE_EXTERNAL_OES with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.
        Throws:
        GlUtil.GlException
      • createTexture

        public static int createTexture​(int width,
                                        int height,
                                        boolean useHighPrecisionColorComponents)
                                 throws GlUtil.GlException
        Deprecated.
        Allocates a new RGBA texture with the specified dimensions and color component precision.
        Parameters:
        width - The width of the new texture in pixels.
        height - The height of the new texture in pixels.
        useHighPrecisionColorComponents - If false, uses colors with 8-bit unsigned bytes. If true, use 16-bit (half-precision) floating-point.
        Returns:
        The texture identifier for the newly-allocated texture.
        Throws:
        GlUtil.GlException - If the texture allocation fails.
      • bindTexture

        public static void bindTexture​(int textureTarget,
                                       int texId)
                                throws GlUtil.GlException
        Deprecated.
        Binds the texture of the given type with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.
        Parameters:
        textureTarget - The target to which the texture is bound, e.g. GLES20.GL_TEXTURE_2D for a two-dimensional texture or GLES11Ext.GL_TEXTURE_EXTERNAL_OES for an external texture.
        texId - The texture identifier.
        Throws:
        GlUtil.GlException
      • createFboForTexture

        public static int createFboForTexture​(int texId)
                                       throws GlUtil.GlException
        Deprecated.
        Returns a new framebuffer for the texture.
        Parameters:
        texId - The identifier of the texture to attach to the framebuffer.
        Throws:
        GlUtil.GlException
      • deleteTexture

        public static void deleteTexture​(int textureId)
                                  throws GlUtil.GlException
        Deprecated.
        Deletes a GL texture.
        Parameters:
        textureId - The ID of the texture to delete.
        Throws:
        GlUtil.GlException
      • deleteFbo

        public static void deleteFbo​(int fboId)
                              throws GlUtil.GlException
        Deprecated.
        Deletes a framebuffer, or silently ignores the method call if fboId is unused.
        Throws:
        GlUtil.GlException
      • deleteRbo

        public static void deleteRbo​(int rboId)
                              throws GlUtil.GlException
        Deprecated.
        Deletes a renderbuffer, or silently ignores the method call if rboId is unused.
        Throws:
        GlUtil.GlException