# EGLSpec

Artifact: [androidx.graphics:graphics-core](https://developer.android.com/jetpack/androidx/releases/graphics) [View Source](https://cs.android.com/search?q=file:androidx/graphics/opengl/egl/EGLSpec.kt+class:androidx.graphics.opengl.egl.EGLSpec) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

*** ** * ** ***


```
public interface EGLSpec
```

<br />

*** ** * ** ***

Interface for accessing various EGL facilities independent of EGL versions. That is each EGL version implements this specification.

EGLSpec is not thread safe and is up to the caller of these methods to guarantee thread safety.

## Summary

| ### Public fields |
|---|---|
| `default static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#V14()` |

| ### Public methods |
|---|---|
| `abstract int` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/opengl/EGLSyncKHR sync, int flags, long timeoutNanos )` Blocks the calling thread until the specified sync object is signalled or until `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` nanoseconds have passed. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLContext.html` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglCreateContext(android.opengl.EGLConfig)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLConfig.html config)` Create an EGLContext with the default display. |
| `abstract https://developer.android.com/reference/androidx/opengl/EGLImageKHR` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglCreateImageFromHardwareBuffer(android.hardware.HardwareBuffer)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/HardwareBuffer.html hardwareBuffer)` Creates an EGLImage from the provided `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglCreatePBufferSurface(android.opengl.EGLConfig,androidx.graphics.opengl.egl.EGLConfigAttributes)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLConfig.html config, https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes configAttributes )` Create a Pixel Buffer surface with the corresponding `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes`. |
| `abstract https://developer.android.com/reference/androidx/opengl/EGLSyncKHR` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglCreateSyncKHR(kotlin.Int,androidx.graphics.opengl.egl.EGLConfigAttributes)(int type, https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes attributes)` Creates a sync object of the specified type associated with the specified display, and returns a handle to the new object. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglCreateWindowSurface(android.opengl.EGLConfig,android.view.Surface,androidx.graphics.opengl.egl.EGLConfigAttributes)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLConfig.html config, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/Surface.html surface, https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes configAttributes )` Creates an on screen EGL window surface from the given `https://developer.android.com/reference/android/view/Surface.html` and returns a handle to it. |
| `abstract void` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglDestroyContext(android.opengl.EGLContext)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLContext.html eglContext)` Destroy the given EGLContext generated in `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglCreateContext(android.opengl.EGLConfig)` |
| `abstract boolean` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglDestroyImageKHR(androidx.opengl.EGLImageKHR)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/opengl/EGLImageKHR image)` Destroy the given `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` instance. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglDestroySurface(android.opengl.EGLSurface)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html surface)` Destroys an EGL surface. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglDestroySyncKHR(androidx.opengl.EGLSyncKHR)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/opengl/EGLSyncKHR sync)` Destroys the given sync object associated with the specified display |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglGetCurrentDrawSurface()()` Return the current surface used for drawing pixels. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglGetCurrentReadSurface()()` Return the current surface used for reading or copying pixels. |
| `abstract int` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglGetError()()` Returns the error of the last called EGL function in the current thread. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglGetSyncAttribKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.IntArray,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/opengl/EGLSyncKHR sync, int attribute, @https://developer.android.com/reference/androidx/annotation/NonNull int[] value, int offset )` Query attributes of the provided sync object. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLVersion` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglInitialize()()` Initialize the EGL implementation and return the major and minor version of the EGL implementation through `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLVersion`. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglMakeCurrent(android.opengl.EGLContext,android.opengl.EGLSurface,android.opengl.EGLSurface)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLContext.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html drawSurface, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html readSurface )` Binds the current context to the given draw and read surfaces. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglQueryString(kotlin.Int)(int nameId)` Query for the capabilities associated with the given eglDisplay. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglQuerySurface(android.opengl.EGLSurface,kotlin.Int,kotlin.IntArray,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html surface, int attribute, @https://developer.android.com/reference/androidx/annotation/NonNull int[] result, int offset )` Query the EGL attributes of the provided surface |
| `abstract boolean` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglSwapBuffers(android.opengl.EGLSurface)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html surface)` Post EGL surface color buffer to a native window |
| `default @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#getErrorMessage()()` Convenience method to obtain the corresponding error string from the error code obtained from `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglGetError()` |
| `default static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#getStatusString(kotlin.Int)(int error)` Return a string representation of the corresponding EGL status code. |
| `abstract https://developer.android.com/reference/android/opengl/EGLConfig.html` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#loadConfig(androidx.graphics.opengl.egl.EGLConfigAttributes)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes configAttributes)` Load a corresponding EGLConfig from the provided `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` If the EGLConfig could not be loaded, null is returned |

## Public fields

### V14

```
default static final @NonNull EGLSpec V14
```

## Public methods

### eglClientWaitSyncKHR

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract int eglClientWaitSyncKHR(
    @NonNull EGLSyncKHR sync,
    int flags,
    long timeoutNanos
)
```

Blocks the calling thread until the specified sync object is signalled or until `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` nanoseconds have passed. More than one `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` may be outstanding on the same `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` at any given time. When there are multiple threads blocked on the same `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` and the `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` object has signalled, all such threads are released, but the order in which they are released is not defined.

If the value of `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is zero, then `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` simply tests the current status of sync. If the value of `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is the special value `https://developer.android.com/reference/androidx/opengl/EGLExt#EGL_FOREVER_KHR()`, then `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` does not time out. For all other values, `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is adjusted to the closest value allowed by the implementation-dependent timeout accuracy, which may be substantially longer than one nanosecond.

`https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` returns one of three status values describing the reason for returning. A return value of `https://developer.android.com/reference/androidx/opengl/EGLExt#EGL_TIMEOUT_EXPIRED_KHR()` indicates that the specified timeout period expired before `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` was signalled, or if `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is zero, indicates that `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is not signaled. A return value of `https://developer.android.com/reference/androidx/opengl/EGLExt#EGL_CONDITION_SATISFIED_KHR()` indicates that `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` was signaled before the timeout expired, which includes the case when `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` was already signaled when `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` was called. If an error occurs then an error is generated and `https://developer.android.com/reference/androidx/opengl/EGLExt#EGL_FALSE()` is returned.

If the sync object being blocked upon will not be signaled in finite time (for example by an associated fence command issued previously, but not yet flushed to the graphics pipeline), then `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` may wait forever. To help prevent this behavior, if the `https://developer.android.com/reference/androidx/opengl/EGLExt#EGL_SYNC_FLUSH_COMMANDS_BIT_KHR()` is set on the flags parameter and the `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is unsignaled when `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is called, then the equivalent flush will be performed for the current EGL context before blocking on sync. If no context is current bound for the API, the `https://developer.android.com/reference/androidx/opengl/EGLExt#EGL_SYNC_FLUSH_COMMANDS_BIT_KHR()` bit is ignored.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/opengl/EGLSyncKHR sync` | EGLSyncKHR object to wait on |
| `int flags` | Optional flags to provide to handle flushing of pending commands |
| `long timeoutNanos` | Optional timeout value to wait before this method returns, measured in nanoseconds. This value is always consumed as an unsigned long value so even negative values will be converted to their unsigned equivalent. |

| Returns |
|---|---|
| `int` | Result code indicating the status of the wait request. Either `https://developer.android.com/reference/androidx/opengl/EGLExt#EGL_CONDITION_SATISFIED_KHR()`, if the sync did signal within the specified timeout, `https://developer.android.com/reference/androidx/opengl/EGLExt#EGL_TIMEOUT_EXPIRED_KHR()` if the sync did not signal within the specified timeout, or `https://developer.android.com/reference/androidx/opengl/EGLExt#EGL_FALSE()` if an error occurs. |

### eglCreateContext

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract @NonNull EGLContext eglCreateContext(@NonNull EGLConfig config)
```

Create an EGLContext with the default display. If createContext fails to create a rendering context, EGL_NO_CONTEXT is returned

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLConfig.html config` | `https://developer.android.com/reference/android/opengl/EGLConfig.html` used to create the `https://developer.android.com/reference/android/opengl/EGLContext.html` |

### eglCreateImageFromHardwareBuffer

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
@RequiresApi(value = 26)
abstract EGLImageKHR eglCreateImageFromHardwareBuffer(@NonNull HardwareBuffer hardwareBuffer)
```

Creates an EGLImage from the provided `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. This handles internally creating an EGLClientBuffer and an `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` from the client buffer.

When this `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` instance is no longer necessary, consumers should be sure to call the corresponding method `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglDestroyImageKHR(androidx.opengl.EGLImageKHR)` to deallocate the resource.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/HardwareBuffer.html hardwareBuffer` | Backing `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` for the generated EGLImage instance |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` | an `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` instance representing the `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` created from the HardwareBuffer. Because this is created internally through EGL's eglCreateImageKR method, this has the KHR suffix. This can return null if the EGL_ANDROID_image_native_buffer and EGL_KHR_image_base extensions are not supported or if allocation of the buffer fails. See www.khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_get_native_client_buffer.txt |

### eglCreatePBufferSurface

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract @NonNull EGLSurface eglCreatePBufferSurface(
    @NonNull EGLConfig config,
    EGLConfigAttributes configAttributes
)
```

Create a Pixel Buffer surface with the corresponding `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes`. Accepted attributes are defined as part of the OpenGL specification here: https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglCreatePbufferSurface.xhtml

If a pixel buffer surface could not be created, `https://developer.android.com/reference/android/opengl/EGL14.html#EGL_NO_SURFACE` is returned.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLConfig.html config` | Specifies the EGL Frame buffer configuration that defines the frame buffer resource available to the surface |
| `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes configAttributes` | Optional list of attributes for the pixel buffer surface |

### eglCreateSyncKHR

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract EGLSyncKHR eglCreateSyncKHR(int type, EGLConfigAttributes attributes)
```

Creates a sync object of the specified type associated with the specified display, and returns a handle to the new object. The configuration of the returned `https://developer.android.com/reference/androidx/opengl/EGLSyncKHR` object is specified by the provided attributes.

Consumers should ensure that the EGL_KHR_fence_sync EGL extension is supported before invoking this method otherwise a null EGLSyncFenceKHR object is returned.

When the `https://developer.android.com/reference/androidx/opengl/EGLSyncKHR` instance is no longer necessary, consumers are encouraged to call `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglDestroySyncKHR(androidx.opengl.EGLSyncKHR)` to deallocate this resource.

See: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_fence_sync.txt

| Parameters |
|---|---|
| `int type` | Indicates the type of sync object that is returned |
| `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes attributes` | Specifies the configuration of the sync object returned |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/opengl/EGLSyncKHR` | the `https://developer.android.com/reference/androidx/opengl/EGLSyncKHR` object to be used as a fence or null if this extension is not supported |

### eglCreateWindowSurface

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract @NonNull EGLSurface eglCreateWindowSurface(
    @NonNull EGLConfig config,
    @NonNull Surface surface,
    EGLConfigAttributes configAttributes
)
```

Creates an on screen EGL window surface from the given `https://developer.android.com/reference/android/view/Surface.html` and returns a handle to it.

See https://khronos.org/registry/EGL/sdk/docs/man/html/eglCreateWindowSurface.xhtml

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLConfig.html config` | Specifies the EGL frame buffer configuration that defines the frame buffer resource available to the surface |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/Surface.html surface` | Android surface to consume rendered content |
| `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes configAttributes` | Optional list of attributes for the specified surface |

### eglDestroyContext

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract void eglDestroyContext(@NonNull EGLContext eglContext)
```

Destroy the given EGLContext generated in `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglCreateContext(android.opengl.EGLConfig)`

See https://khronos.org/registry/EGL/sdk/docs/man/html/eglDestroyContext.xhtml

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLContext.html eglContext` | EGL rendering context to be destroyed |

### eglDestroyImageKHR

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract boolean eglDestroyImageKHR(@NonNull EGLImageKHR image)
```

Destroy the given `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` instance. Once destroyed, the image may not be used to create any additional `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` target resources within any client API contexts, although existing `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` siblings may continue to be used. `true` is returned if DestroyImageKHR succeeds, `false` indicates failure. This can return `false` if the corresponding `https://developer.android.com/reference/android/opengl/EGLContext.html` is not valid.

See: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_image_base.txt

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/opengl/EGLImageKHR image` | EGLImageKHR to be destroyed |

| Returns |
|---|---|
| `boolean` | `true` if the destruction of the EGLImageKHR object was successful, `false` otherwise |

### eglDestroySurface

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract boolean eglDestroySurface(@NonNull EGLSurface surface)
```

Destroys an EGL surface.

If the EGL surface is not current to any thread, eglDestroySurface destroys it immediately. Otherwise, surface is destroyed when it becomes not current to any thread. Furthermore, resources associated with a pbuffer surface are not released until all color buffers of that pbuffer bound to a texture object have been released. Deferral of surface destruction would still return true as deferral does not indicate a failure condition

| Returns |
|---|---|
| `boolean` | `true` if destruction of the EGLSurface was successful, false otherwise |

### eglDestroySyncKHR

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract boolean eglDestroySyncKHR(@NonNull EGLSyncKHR sync)
```

Destroys the given sync object associated with the specified display

Consumers should ensure that the EGL_KHR_fence_sync EGL extension is supported before invoking this method otherwise a null EGLSyncFenceKHR object is returned. See: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_fence_sync.txt

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/opengl/EGLSyncKHR sync` | Fence object to be destroyed |

| Returns |
|---|---|
| `boolean` | `true` if the `https://developer.android.com/reference/androidx/opengl/EGLSyncKHR` object was destroyed successfully `false` otherwise. This can return `false` if the sync object is not a valid sync object for the provided display or if the display provided in this method does not match the display used to create this sync in `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglCreateSyncKHR(kotlin.Int,androidx.graphics.opengl.egl.EGLConfigAttributes)`. |

### eglGetCurrentDrawSurface

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract @NonNull EGLSurface eglGetCurrentDrawSurface()
```

Return the current surface used for drawing pixels. If no context is current, `https://developer.android.com/reference/android/opengl/EGL14.html#EGL_NO_SURFACE` is returned.

### eglGetCurrentReadSurface

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract @NonNull EGLSurface eglGetCurrentReadSurface()
```

Return the current surface used for reading or copying pixels. If no context is current, `https://developer.android.com/reference/android/opengl/EGL14.html#EGL_NO_SURFACE` is returned

### eglGetError

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract int eglGetError()
```

Returns the error of the last called EGL function in the current thread. Initially, the error is set to EGL_SUCCESS. When an EGL function could potentially generate several different errors (for example, when passed both a bad attribute name, and a bad attribute value for a legal attribute name), the implementation may choose to generate any one of the applicable errors.

See https://khronos.org/registry/EGL/sdk/docs/man/html/eglGetError.xhtml for more information and error codes that could potentially be returned

### eglGetSyncAttribKHR

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract boolean eglGetSyncAttribKHR(
    @NonNull EGLSyncKHR sync,
    int attribute,
    @NonNull int[] value,
    int offset
)
```

Query attributes of the provided sync object. Accepted attributes to query depend on the type of sync object. If no errors are generated, this returns true and the value of the queried attribute is stored in the value array at the offset position. If this method returns false, the provided value array is unmodified.

See: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_fence_sync.txt

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/opengl/EGLSyncKHR sync` | EGLSyncKHR object to query attributes |
| `int attribute` | Corresponding EGLSyncKHR attribute to query on `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglGetSyncAttribKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.IntArray,kotlin.Int)` Value is one of the following: - `12535` - `12529` - `12536` <br /> |
| `@https://developer.android.com/reference/androidx/annotation/NonNull int[] value` | Integer array used to store the result of the query |
| `int offset` | Index within the value array to store the result of the attribute query |

| Returns |
|---|---|
| `boolean` | `true` if the attribute was queried successfully, false otherwise. Failure cases include attempting to call this method on an invalid sync object, or the display provided not matching the display that was used to create this sync object. Additionally if the queried attribute is not supported for the sync object, false is returned. |

### eglInitialize

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract @NonNull EGLVersion eglInitialize()
```

Initialize the EGL implementation and return the major and minor version of the EGL implementation through `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLVersion`. If initialization fails, this returns `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLVersion#Unknown()`

### eglMakeCurrent

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract boolean eglMakeCurrent(
    @NonNull EGLContext context,
    @NonNull EGLSurface drawSurface,
    @NonNull EGLSurface readSurface
)
```

Binds the current context to the given draw and read surfaces. The draw surface is used for all operations except for any pixel data read back or copy operations which are taken from the read surface.

The same EGLSurface may be specified for both draw and read surfaces.

See https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglMakeCurrent.xhtml for more information

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLContext.html context` | EGL rendering context to be attached to the surfaces |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html drawSurface` | EGLSurface to draw pixels into. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html readSurface` | EGLSurface used for read/copy operations. |

### eglQueryString

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract @NonNull String eglQueryString(int nameId)
```

Query for the capabilities associated with the given eglDisplay. The result contains a space separated list of the capabilities.

| Parameters |
|---|---|
| `int nameId` | identifier for the EGL string to query |

### eglQuerySurface

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract boolean eglQuerySurface(
    @NonNull EGLSurface surface,
    int attribute,
    @NonNull int[] result,
    int offset
)
```

Query the EGL attributes of the provided surface

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html surface` | EGLSurface to be queried |
| `int attribute` | EGL attribute to query on the given EGL Surface |
| `@https://developer.android.com/reference/androidx/annotation/NonNull int[] result` | Int array to store the result of the query |
| `int offset` | Index within `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglQuerySurface(android.opengl.EGLSurface,kotlin.Int,kotlin.IntArray,kotlin.Int)` to store the value of the queried attribute |

| Returns |
|---|---|
| `boolean` | `true` if the query was completed successfully, false otherwise. If the query fails, `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglQuerySurface(android.opengl.EGLSurface,kotlin.Int,kotlin.IntArray,kotlin.Int)` is unmodified |

### eglSwapBuffers

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract boolean eglSwapBuffers(@NonNull EGLSurface surface)
```

Post EGL surface color buffer to a native window

See https://khronos.org/registry/EGL/sdk/docs/man/html/eglSwapBuffers.xhtml

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/opengl/EGLSurface.html surface` | Specifies the EGL drawing surface whose buffers are to be swapped |

| Returns |
|---|---|
| `boolean` | `true` if swapping of buffers succeeds, false otherwise |

### getErrorMessage

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
default @NonNull String getErrorMessage()
```

Convenience method to obtain the corresponding error string from the error code obtained from `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec#eglGetError()`

### getStatusString

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
default static final @NonNull String getStatusString(int error)
```

Return a string representation of the corresponding EGL status code. If the provided error value is not an EGL status code, the hex representation is returned instead

### loadConfig

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
abstract EGLConfig loadConfig(@NonNull EGLConfigAttributes configAttributes)
```

Load a corresponding EGLConfig from the provided `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` If the EGLConfig could not be loaded, null is returned

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes configAttributes` | Desired `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` to create an `https://developer.android.com/reference/android/opengl/EGLConfig.html` |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/opengl/EGLConfig.html` | the `https://developer.android.com/reference/android/opengl/EGLConfig.html` with the provided `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` or null if an `https://developer.android.com/reference/android/opengl/EGLConfig.html` could not be created with the specified attributes |