# GlObjectsProvider

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

*** ** * ** ***


```
@UnstableApi
public interface GlObjectsProvider
```

<br />

Known direct subclasses [DefaultGlObjectsProvider](https://developer.android.com/reference/androidx/media3/effect/DefaultGlObjectsProvider)

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

*** ** * ** ***

Provider to customize the creation and maintenance of GL objects.

## Summary

| ### Public methods |
|---|---|
| `abstract https://developer.android.com/reference/androidx/media3/common/GlTextureInfo` | `https://developer.android.com/reference/androidx/media3/common/GlObjectsProvider#createBuffersForTexture(int,int,int)(int texId, int width, int height)` Returns a `https://developer.android.com/reference/androidx/media3/common/GlTextureInfo` containing the identifiers of the newly created buffers. |
| `abstract https://developer.android.com/reference/android/opengl/EGLContext.html` | `https://developer.android.com/reference/androidx/media3/common/GlObjectsProvider#createEglContext(android.opengl.EGLDisplay,int,int[])( https://developer.android.com/reference/android/opengl/EGLDisplay.html eglDisplay, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 2, to = 3) int openGlVersion, int[] configAttributes )` Creates a new `https://developer.android.com/reference/android/opengl/EGLContext.html` for the specified `https://developer.android.com/reference/android/opengl/EGLDisplay.html`. |
| `abstract https://developer.android.com/reference/android/opengl/EGLSurface.html` | `https://developer.android.com/reference/androidx/media3/common/GlObjectsProvider#createEglSurface(android.opengl.EGLDisplay,java.lang.Object,int,boolean)( https://developer.android.com/reference/android/opengl/EGLDisplay.html eglDisplay, https://developer.android.com/reference/java/lang/Object.html surface, @https://developer.android.com/reference/androidx/media3/common/C.ColorTransfer int colorTransfer, boolean isEncoderInputSurface )` Creates a new `https://developer.android.com/reference/android/opengl/EGLSurface.html` wrapping the specified `surface`. |
| `abstract https://developer.android.com/reference/android/opengl/EGLSurface.html` | `https://developer.android.com/reference/androidx/media3/common/GlObjectsProvider#createFocusedPlaceholderEglSurface(android.opengl.EGLContext,android.opengl.EGLDisplay)( https://developer.android.com/reference/android/opengl/EGLContext.html eglContext, https://developer.android.com/reference/android/opengl/EGLDisplay.html eglDisplay )` Creates and focuses a placeholder `https://developer.android.com/reference/android/opengl/EGLSurface.html`. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/common/GlObjectsProvider#release(android.opengl.EGLDisplay)(https://developer.android.com/reference/android/opengl/EGLDisplay.html eglDisplay)` Releases the created objects. |

## Public methods

### createBuffersForTexture

```
abstract GlTextureInfo createBuffersForTexture(int texId, int width, int height)
```

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

| Parameters |
|---|---|
| `int texId` | The identifier of the texture to attach to the buffers. |
| `int width` | The width of the texture in pixels. |
| `int height` | The height of the texture in pixels. |

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

### createEglContext

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

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 |
|---|---|
| `https://developer.android.com/reference/android/opengl/EGLDisplay.html eglDisplay` | The `https://developer.android.com/reference/android/opengl/EGLDisplay.html` to create an `https://developer.android.com/reference/android/opengl/EGLContext.html` for. |
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 2, to = 3) int openGlVersion` | The version of OpenGL ES to configure. Accepts either `2`, for OpenGL ES 2.0, or `3`, for OpenGL ES 3.0. |
| `int[] configAttributes` | The attributes to configure EGL with. |

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

### createEglSurface

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

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

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

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

### createFocusedPlaceholderEglSurface

```
abstract EGLSurface createFocusedPlaceholderEglSurface(
    EGLContext eglContext,
    EGLDisplay eglDisplay
)
```

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/opengl/EGLContext.html eglContext` | The `https://developer.android.com/reference/android/opengl/EGLContext.html` to make current. |
| `https://developer.android.com/reference/android/opengl/EGLDisplay.html eglDisplay` | 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/androidx/media3/common/util/GlUtil.GlException` | If an error occurs during creation. |

### release

```
abstract void release(EGLDisplay eglDisplay)
```

Releases the created objects.

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

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