# DefaultGlObjectsProvider

Artifact: [androidx.media3:media3-effect](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/effect/DefaultGlObjectsProvider.java+class:androidx.media3.effect.DefaultGlObjectsProvider)

*** ** * ** ***


```
@UnstableApi
class DefaultGlObjectsProvider : GlObjectsProvider
```

<br />

*** ** * ** ***

Implementation of `https://developer.android.com/reference/kotlin/androidx/media3/common/GlObjectsProvider` that configures an `https://developer.android.com/reference/android/opengl/EGLContext.html` to share data with a preexisting `sharedEglContext`.

The created `https://developer.android.com/reference/android/opengl/EGLContext.html` is configured with 8-bit RGB or 10-bit RGB attributes and no depth buffer or render buffers.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultGlObjectsProvider#DefaultGlObjectsProvider()()` Creates an instance with no shared EGL context. |
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultGlObjectsProvider#DefaultGlObjectsProvider(android.opengl.EGLContext)(sharedEglContext: https://developer.android.com/reference/android/opengl/EGLContext.html?)` Creates an instance with the specified shared EGL context. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultGlObjectsProvider#createBuffersForTexture(int,int,int)(texId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a `https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo` containing the identifiers of the newly created buffers. |
| `https://developer.android.com/reference/android/opengl/EGLContext.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultGlObjectsProvider#createEglContext(android.opengl.EGLDisplay,int,int[])( eglDisplay: https://developer.android.com/reference/android/opengl/EGLDisplay.html!, openGlVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, configAttributes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>! )` Creates a new `https://developer.android.com/reference/android/opengl/EGLContext.html` for the specified `https://developer.android.com/reference/android/opengl/EGLDisplay.html`. |
| `https://developer.android.com/reference/android/opengl/EGLSurface.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultGlObjectsProvider#createEglSurface(android.opengl.EGLDisplay,java.lang.Object,int,boolean)( eglDisplay: https://developer.android.com/reference/android/opengl/EGLDisplay.html!, surface: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, @https://developer.android.com/reference/kotlin/androidx/media3/common/C.ColorTransfer colorTransfer: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, isEncoderInputSurface: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Creates a new `https://developer.android.com/reference/android/opengl/EGLSurface.html` wrapping the specified `surface`. |
| `https://developer.android.com/reference/android/opengl/EGLSurface.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultGlObjectsProvider#createFocusedPlaceholderEglSurface(android.opengl.EGLContext,android.opengl.EGLDisplay)( eglContext: https://developer.android.com/reference/android/opengl/EGLContext.html!, eglDisplay: https://developer.android.com/reference/android/opengl/EGLDisplay.html! )` Creates and focuses a placeholder `https://developer.android.com/reference/android/opengl/EGLSurface.html`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/DefaultGlObjectsProvider#release(android.opengl.EGLDisplay)(eglDisplay: https://developer.android.com/reference/android/opengl/EGLDisplay.html!)` Releases the created objects. |

## Public constructors

### DefaultGlObjectsProvider

```
DefaultGlObjectsProvider()
```

Creates an instance with no shared EGL context.

### DefaultGlObjectsProvider

```
DefaultGlObjectsProvider(sharedEglContext: EGLContext?)
```

Creates an instance with the specified shared EGL context.

| Parameters |
|---|---|
| `sharedEglContext: https://developer.android.com/reference/android/opengl/EGLContext.html?` | The context with which to share data, or `null` if none. |

## Public functions

### createBuffersForTexture

```
fun createBuffersForTexture(texId: Int, width: Int, height: Int): GlTextureInfo!
```

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/common/GlTextureInfo` containing the identifiers of the newly created buffers.

| Parameters |
|---|---|
| `texId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The identifier of the texture to attach to the buffers. |
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The width of the texture in pixels. |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The height of the texture in pixels. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/GlUtil.GlException` | If an error occurs during creation. |

### createEglContext

```
fun createEglContext(
    eglDisplay: EGLDisplay!,
    openGlVersion: Int,
    configAttributes: IntArray<Int>!
): EGLContext!
```

Creates a new `https://developer.android.com/reference/android/opengl/EGLContext.html` for the specified `https://developer.android.com/reference/android/opengl/EGLDisplay.html`.

| Parameters |
|---|---|
| `eglDisplay: https://developer.android.com/reference/android/opengl/EGLDisplay.html!` | The `https://developer.android.com/reference/android/opengl/EGLDisplay.html` to create an `https://developer.android.com/reference/android/opengl/EGLContext.html` for. |
| `openGlVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The version of OpenGL ES to configure. Accepts either `2`, for OpenGL ES 2.0, or `3`, for OpenGL ES 3.0. |
| `configAttributes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | The attributes to configure EGL with. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/GlUtil.GlException` | If an error occurs during creation. |

### createEglSurface

```
fun createEglSurface(
    eglDisplay: EGLDisplay!,
    surface: Any!,
    @C.ColorTransfer colorTransfer: Int,
    isEncoderInputSurface: Boolean
): EGLSurface!
```

Creates a new `https://developer.android.com/reference/android/opengl/EGLSurface.html` wrapping the specified `surface`.

| Parameters |
|---|---|
| `eglDisplay: https://developer.android.com/reference/android/opengl/EGLDisplay.html!` | The `https://developer.android.com/reference/android/opengl/EGLDisplay.html` to attach the surface to. |
| `surface: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | The surface to wrap; must be a surface, surface texture or surface holder. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.ColorTransfer colorTransfer: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/C.ColorTransfer` to which the `surface` is configured. Value is one of the following: - `Format.NO_VALUE` <br /> |
| `isEncoderInputSurface: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the `surface` is the input surface of an encoder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/GlUtil.GlException` | If an error occurs during creation. |

### createFocusedPlaceholderEglSurface

```
fun createFocusedPlaceholderEglSurface(
    eglContext: EGLContext!,
    eglDisplay: EGLDisplay!
): EGLSurface!
```

Creates and focuses a placeholder `https://developer.android.com/reference/android/opengl/EGLSurface.html`.

| Parameters |
|---|---|
| `eglContext: https://developer.android.com/reference/android/opengl/EGLContext.html!` | The `https://developer.android.com/reference/android/opengl/EGLContext.html` to make current. |
| `eglDisplay: https://developer.android.com/reference/android/opengl/EGLDisplay.html!` | The `https://developer.android.com/reference/android/opengl/EGLDisplay.html` to attach the surface to. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/opengl/EGLSurface.html!` | A placeholder `https://developer.android.com/reference/android/opengl/EGLSurface.html` that has been focused to allow rendering to take place, or `https://developer.android.com/reference/android/opengl/EGL14.html#EGL_NO_SURFACE` if the current context supports rendering without a surface. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/GlUtil.GlException` | If an error occurs during creation. |

### release

```
fun release(eglDisplay: EGLDisplay!): Unit
```

Releases the created objects.

| Parameters |
|---|---|
| `eglDisplay: https://developer.android.com/reference/android/opengl/EGLDisplay.html!` | The `https://developer.android.com/reference/android/opengl/EGLDisplay.html` to release the objects for. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/GlUtil.GlException` |   |