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

*** ** * ** ***


```
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 companion functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#getStatusString(kotlin.Int)(error: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Return a string representation of the corresponding EGL status code. |

| ### Public companion properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#V14()` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)(sync: https://developer.android.com/reference/kotlin/androidx/opengl/EGLSyncKHR, flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, timeoutNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Blocks the calling thread until the specified sync object is signalled or until `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` nanoseconds have passed. |
| `https://developer.android.com/reference/android/opengl/EGLContext.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglCreateContext(android.opengl.EGLConfig)(config: https://developer.android.com/reference/android/opengl/EGLConfig.html)` Create an EGLContext with the default display. |
| `https://developer.android.com/reference/kotlin/androidx/opengl/EGLImageKHR?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglCreateImageFromHardwareBuffer(android.hardware.HardwareBuffer)(hardwareBuffer: https://developer.android.com/reference/android/hardware/HardwareBuffer.html)` Creates an EGLImage from the provided `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. |
| `https://developer.android.com/reference/android/opengl/EGLSurface.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglCreatePBufferSurface(android.opengl.EGLConfig,androidx.graphics.opengl.egl.EGLConfigAttributes)( config: https://developer.android.com/reference/android/opengl/EGLConfig.html, configAttributes: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLConfigAttributes? )` Create a Pixel Buffer surface with the corresponding `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLConfigAttributes`. |
| `https://developer.android.com/reference/kotlin/androidx/opengl/EGLSyncKHR?` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglCreateSyncKHR(kotlin.Int,androidx.graphics.opengl.egl.EGLConfigAttributes)(type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, attributes: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLConfigAttributes?)` Creates a sync object of the specified type associated with the specified display, and returns a handle to the new object. |
| `https://developer.android.com/reference/android/opengl/EGLSurface.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglCreateWindowSurface(android.opengl.EGLConfig,android.view.Surface,androidx.graphics.opengl.egl.EGLConfigAttributes)( config: https://developer.android.com/reference/android/opengl/EGLConfig.html, surface: https://developer.android.com/reference/android/view/Surface.html, configAttributes: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLConfigAttributes? )` 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. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglDestroyContext(android.opengl.EGLContext)(eglContext: https://developer.android.com/reference/android/opengl/EGLContext.html)` Destroy the given EGLContext generated in `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglCreateContext(android.opengl.EGLConfig)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglDestroyImageKHR(androidx.opengl.EGLImageKHR)(image: https://developer.android.com/reference/kotlin/androidx/opengl/EGLImageKHR)` Destroy the given `https://developer.android.com/reference/kotlin/androidx/opengl/EGLImageKHR` instance. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglDestroySurface(android.opengl.EGLSurface)(surface: https://developer.android.com/reference/android/opengl/EGLSurface.html)` Destroys an EGL surface. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglDestroySyncKHR(androidx.opengl.EGLSyncKHR)(sync: https://developer.android.com/reference/kotlin/androidx/opengl/EGLSyncKHR)` Destroys the given sync object associated with the specified display |
| `https://developer.android.com/reference/android/opengl/EGLSurface.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglGetCurrentDrawSurface()()` Return the current surface used for drawing pixels. |
| `https://developer.android.com/reference/android/opengl/EGLSurface.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglGetCurrentReadSurface()()` Return the current surface used for reading or copying pixels. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglGetError()()` Returns the error of the last called EGL function in the current thread. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglGetSyncAttribKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.IntArray,kotlin.Int)( sync: https://developer.android.com/reference/kotlin/androidx/opengl/EGLSyncKHR, attribute: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html, offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Query attributes of the provided sync object. |
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLVersion` | `https://developer.android.com/reference/kotlin/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/kotlin/androidx/graphics/opengl/egl/EGLVersion`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglMakeCurrent(android.opengl.EGLContext,android.opengl.EGLSurface,android.opengl.EGLSurface)( context: https://developer.android.com/reference/android/opengl/EGLContext.html, drawSurface: https://developer.android.com/reference/android/opengl/EGLSurface.html, readSurface: https://developer.android.com/reference/android/opengl/EGLSurface.html )` Binds the current context to the given draw and read surfaces. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglQueryString(kotlin.Int)(nameId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Query for the capabilities associated with the given eglDisplay. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglQuerySurface(android.opengl.EGLSurface,kotlin.Int,kotlin.IntArray,kotlin.Int)( surface: https://developer.android.com/reference/android/opengl/EGLSurface.html, attribute: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, result: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html, offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Query the EGL attributes of the provided surface |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglSwapBuffers(android.opengl.EGLSurface)(surface: https://developer.android.com/reference/android/opengl/EGLSurface.html)` Post EGL surface color buffer to a native window |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/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/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglGetError()` |
| `https://developer.android.com/reference/android/opengl/EGLConfig.html?` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#loadConfig(androidx.graphics.opengl.egl.EGLConfigAttributes)(configAttributes: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLConfigAttributes)` Load a corresponding EGLConfig from the provided `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLConfigAttributes` If the EGLConfig could not be loaded, null is returned |

## Public companion functions

### getStatusString

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

```
fun getStatusString(error: Int): String
```

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

## Public companion properties

### V14

```
val V14: EGLSpec
```

## Public functions

### eglClientWaitSyncKHR

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

```
fun eglClientWaitSyncKHR(sync: EGLSyncKHR, flags: Int, timeoutNanos: Long): Int
```

Blocks the calling thread until the specified sync object is signalled or until `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` nanoseconds have passed. More than one `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` may be outstanding on the same `https://developer.android.com/reference/kotlin/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/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` and the `https://developer.android.com/reference/kotlin/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/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is zero, then `https://developer.android.com/reference/kotlin/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/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is the special value `https://developer.android.com/reference/kotlin/androidx/opengl/EGLExt#EGL_FOREVER_KHR()`, then `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/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/kotlin/androidx/opengl/EGLExt#EGL_TIMEOUT_EXPIRED_KHR()` indicates that the specified timeout period expired before `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` was signalled, or if `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is zero, indicates that `https://developer.android.com/reference/kotlin/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/kotlin/androidx/opengl/EGLExt#EGL_CONDITION_SATISFIED_KHR()` indicates that `https://developer.android.com/reference/kotlin/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/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` was already signaled when `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/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/kotlin/androidx/opengl/EGLExt#EGL_SYNC_FLUSH_COMMANDS_BIT_KHR()` is set on the flags parameter and the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLSpec#eglClientWaitSyncKHR(androidx.opengl.EGLSyncKHR,kotlin.Int,kotlin.Long)` is unsignaled when `https://developer.android.com/reference/kotlin/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/kotlin/androidx/opengl/EGLExt#EGL_SYNC_FLUSH_COMMANDS_BIT_KHR()` bit is ignored.

| Parameters |
|---|---|
| `sync: https://developer.android.com/reference/kotlin/androidx/opengl/EGLSyncKHR` | EGLSyncKHR object to wait on |
| `flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Optional flags to provide to handle flushing of pending commands |
| `timeoutNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | 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 |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Result code indicating the status of the wait request. Either `https://developer.android.com/reference/kotlin/androidx/opengl/EGLExt#EGL_CONDITION_SATISFIED_KHR()`, if the sync did signal within the specified timeout, `https://developer.android.com/reference/kotlin/androidx/opengl/EGLExt#EGL_TIMEOUT_EXPIRED_KHR()` if the sync did not signal within the specified timeout, or `https://developer.android.com/reference/kotlin/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)

```
fun eglCreateContext(config: EGLConfig): EGLContext
```

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

| Parameters |
|---|---|
| `config: https://developer.android.com/reference/android/opengl/EGLConfig.html` | `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)
fun eglCreateImageFromHardwareBuffer(hardwareBuffer: HardwareBuffer): EGLImageKHR?
```

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/kotlin/androidx/opengl/EGLImageKHR` from the client buffer.

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

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/opengl/EGLImageKHR?` | an `https://developer.android.com/reference/kotlin/androidx/opengl/EGLImageKHR` instance representing the `https://developer.android.com/reference/kotlin/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)

```
fun eglCreatePBufferSurface(
    config: EGLConfig,
    configAttributes: EGLConfigAttributes?
): EGLSurface
```

Create a Pixel Buffer surface with the corresponding `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `config: https://developer.android.com/reference/android/opengl/EGLConfig.html` | Specifies the EGL Frame buffer configuration that defines the frame buffer resource available to the surface |
| `configAttributes: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLConfigAttributes?` | 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)

```
fun eglCreateSyncKHR(type: Int, attributes: EGLConfigAttributes?): EGLSyncKHR?
```

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/kotlin/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/kotlin/androidx/opengl/EGLSyncKHR` instance is no longer necessary, consumers are encouraged to call `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Indicates the type of sync object that is returned |
| `attributes: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLConfigAttributes?` | Specifies the configuration of the sync object returned |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/opengl/EGLSyncKHR?` | the `https://developer.android.com/reference/kotlin/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)

```
fun eglCreateWindowSurface(
    config: EGLConfig,
    surface: Surface,
    configAttributes: EGLConfigAttributes?
): EGLSurface
```

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 |
|---|---|
| `config: https://developer.android.com/reference/android/opengl/EGLConfig.html` | Specifies the EGL frame buffer configuration that defines the frame buffer resource available to the surface |
| `surface: https://developer.android.com/reference/android/view/Surface.html` | Android surface to consume rendered content |
| `configAttributes: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLConfigAttributes?` | 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)

```
fun eglDestroyContext(eglContext: EGLContext): Unit
```

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

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

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

### eglDestroyImageKHR

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

```
fun eglDestroyImageKHR(image: EGLImageKHR): Boolean
```

Destroy the given `https://developer.android.com/reference/kotlin/androidx/opengl/EGLImageKHR` instance. Once destroyed, the image may not be used to create any additional `https://developer.android.com/reference/kotlin/androidx/opengl/EGLImageKHR` target resources within any client API contexts, although existing `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `image: https://developer.android.com/reference/kotlin/androidx/opengl/EGLImageKHR` | EGLImageKHR to be destroyed |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `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)

```
fun eglDestroySurface(surface: EGLSurface): Boolean
```

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 |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `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)

```
fun eglDestroySyncKHR(sync: EGLSyncKHR): Boolean
```

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 |
|---|---|
| `sync: https://developer.android.com/reference/kotlin/androidx/opengl/EGLSyncKHR` | Fence object to be destroyed |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the `https://developer.android.com/reference/kotlin/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/kotlin/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)

```
fun eglGetCurrentDrawSurface(): EGLSurface
```

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)

```
fun eglGetCurrentReadSurface(): EGLSurface
```

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)

```
fun eglGetError(): Int
```

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)

```
fun eglGetSyncAttribKHR(
    sync: EGLSyncKHR,
    attribute: Int,
    value: IntArray,
    offset: Int
): Boolean
```

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 |
|---|---|
| `sync: https://developer.android.com/reference/kotlin/androidx/opengl/EGLSyncKHR` | EGLSyncKHR object to query attributes |
| `attribute: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Corresponding EGLSyncKHR attribute to query on `https://developer.android.com/reference/kotlin/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 /> |
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html` | Integer array used to store the result of the query |
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Index within the value array to store the result of the attribute query |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `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)

```
fun eglInitialize(): EGLVersion
```

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

### eglMakeCurrent

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

```
fun eglMakeCurrent(
    context: EGLContext,
    drawSurface: EGLSurface,
    readSurface: EGLSurface
): Boolean
```

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 |
|---|---|
| `context: https://developer.android.com/reference/android/opengl/EGLContext.html` | EGL rendering context to be attached to the surfaces |
| `drawSurface: https://developer.android.com/reference/android/opengl/EGLSurface.html` | EGLSurface to draw pixels into. |
| `readSurface: https://developer.android.com/reference/android/opengl/EGLSurface.html` | EGLSurface used for read/copy operations. |

### eglQueryString

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

```
fun eglQueryString(nameId: Int): String
```

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

| Parameters |
|---|---|
| `nameId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | identifier for the EGL string to query |

### eglQuerySurface

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

```
fun eglQuerySurface(
    surface: EGLSurface,
    attribute: Int,
    result: IntArray,
    offset: Int
): Boolean
```

Query the EGL attributes of the provided surface

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the query was completed successfully, false otherwise. If the query fails, `https://developer.android.com/reference/kotlin/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)

```
fun eglSwapBuffers(surface: EGLSurface): Boolean
```

Post EGL surface color buffer to a native window

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

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `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)

```
open fun getErrorMessage(): String
```

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

### loadConfig

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

```
fun loadConfig(configAttributes: EGLConfigAttributes): EGLConfig?
```

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

| Parameters |
|---|---|
| `configAttributes: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/egl/EGLConfigAttributes` | Desired `https://developer.android.com/reference/kotlin/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/kotlin/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 |