@UnstableApi
public final class GlUtil


OpenGL ES utilities.

Summary

Nested types

public final class GlUtil.GlException extends Exception

Thrown when an OpenGL error occurs.

Constants

static final int[]
static final int[]
static final long

Marker value for when no fence sync is set.

static final int

Number of elements in a 3d homogeneous coordinate vector describing a vertex.

static final float
LENGTH_NDC = 2.0f

Length of the normalized device coordinate (NDC) space, which spans from -1 to 1.

Public methods

static void
awaitSyncObject(long syncObject)

Ensures that following commands on the current OpenGL context will not be executed until the sync point has been reached.

static void
bindTexture(int textureTarget, int texId, int sampleFilter)

Binds the texture of the given type with the specified MIN and MAG sampling filter and GL_CLAMP_TO_EDGE wrapping.

static void
blitFrameBuffer(
    int readFboId,
    GlRect readRect,
    int drawFboId,
    GlRect drawRect
)

Copies the pixels from readFboId into drawFboId.

static void
checkEglException(String errorMessage)

Collects EGL errors that occurred in the last called EGL function and throws a GlException with the combined error code.

static void

Collects all OpenGL errors that occurred since this method was last called and throws a GlException with the combined error message.

static void
checkGlException(boolean expression, String errorMessage)

Throws a GlException with the given message if expression evaluates to false.

static void

Fills the pixels in the current output render target buffers with (r=0, g=0, b=0, a=0).

static void

Fills the pixels in the current output render target buffers with (r=0, g=0, b=0, a=1).

static float[]

Creates a 4x4 identity matrix.

static FloatBuffer
createBuffer(float[] data)

Allocates a FloatBuffer with the given data.

static EGLContext

Creates a new EGLContext for the specified EGLDisplay.

static EGLContext
createEglContext(
    EGLContext sharedContext,
    EGLDisplay eglDisplay,
    @IntRange(from = 2, to = 3) int openGlVersion,
    int[] configAttributes
)

Creates a new EGLContext for the specified EGLDisplay.

static EGLSurface
createEglSurface(
    EGLDisplay eglDisplay,
    Object surface,
    @C.ColorTransfer int colorTransfer,
    boolean isEncoderInputSurface
)

Creates a new EGLSurface wrapping the specified surface.

static int

Creates a GL_TEXTURE_EXTERNAL_OES with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.

static int

Returns a new framebuffer for the texture.

static EGLSurface
createFocusedPlaceholderEglSurface(
    EGLContext eglContext,
    EGLDisplay eglDisplay
)

Creates and focuses a placeholder EGLSurface.

static long

Returns a newly created sync object and inserts it into the GL command stream.

static int

Creates a pixel buffer object with a data store of the given size and usage GL_DYNAMIC_READ.

static int
createRgb10A2Texture(int width, int height)

Allocates a new normalized integerGL_RGB10_A2 texture with the specified dimensions.

static int

Allocates a new texture, initialized with the bitmap data and size.

static int
createTexture(
    int width,
    int height,
    boolean useHighPrecisionColorComponents
)

Allocates a new RGBA texture with the specified dimensions and color component precision.

static float[]
createVertexBuffer(List<float[]> vertexList)

Flattens the list of 4 element NDC coordinate vectors into a buffer.

static void
deleteBuffer(int bufferId)

Deletes a buffer object, or silently ignores the method call if bufferId is unused.

static void
deleteFbo(int fboId)

Deletes a framebuffer, or silently ignores the method call if fboId is unused.

static void
deleteRbo(int rboId)

Deletes a renderbuffer, or silently ignores the method call if rboId is unused.

static void
deleteSyncObject(long syncObject)

Deletes the underlying native object.

static void
deleteSyncObjectQuietly(long syncObject)

Releases the GL sync object if set, suppressing any error.

static void
deleteTexture(int textureId)

Deletes a GL texture.

static void
destroyEglContext(
    @Nullable EGLDisplay eglDisplay,
    @Nullable EGLContext eglContext
)

Destroys the EGLContext identified by the provided EGLDisplay and EGLContext.

static void
destroyEglSurface(
    @Nullable EGLDisplay eglDisplay,
    @Nullable EGLSurface eglSurface
)

Destroys the EGLSurface