Class GlUtil


  • public final class GlUtil
    extends Object
    GL utilities.
    • Field Detail

      • TEXTURE_ID_UNSET

        public static final int TEXTURE_ID_UNSET
        Represents an unset texture ID.
        See Also:
        Constant Field Values
      • glAssertionsEnabled

        public static boolean glAssertionsEnabled
        Whether to throw a GlUtil.GlException in case of an OpenGL error.
    • 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.
      • createEglDisplay

        @RequiresApi(17)
        public static EGLDisplay createEglDisplay()
        Returns an initialized default EGLDisplay.
      • getEglSurface

        @RequiresApi(17)
        public static EGLSurface getEglSurface​(EGLDisplay eglDisplay,
                                               Object surface)
        Returns a new EGLSurface wrapping the specified surface.
        Parameters:
        eglDisplay - The EGLDisplay to attach the surface to.
        surface - The surface to wrap; must be a surface, surface texture or surface holder.
      • focusSurface

        @RequiresApi(17)
        public static void focusSurface​(EGLDisplay eglDisplay,
                                        EGLContext eglContext,
                                        EGLSurface surface,
                                        int width,
                                        int height)
        Makes the specified surface the render target, using a viewport of width by height pixels.
      • deleteTexture

        public static void deleteTexture​(int textureId)
        Deletes a GL texture.
        Parameters:
        textureId - The ID of the texture to delete.
      • 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.
      • loadAsset

        public static String loadAsset​(Context context,
                                       String assetPath)
                                throws IOException
        Loads a file from the assets folder.
        Parameters:
        context - The Context.
        assetPath - The path to the file to load, from the assets folder.
        Returns:
        The content of the file to load.
        Throws:
        IOException - If the file couldn't be read.
      • createExternalTexture

        public static int createExternalTexture()
        Creates a GL_TEXTURE_EXTERNAL_OES with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.