# GLFrameBufferRenderer

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/GLFrameBufferRenderer.kt+class:androidx.graphics.opengl.GLFrameBufferRenderer) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

*** ** * ** ***


```
@RequiresApi(value = 29)
class GLFrameBufferRenderer
```

<br />

*** ** * ** ***

Class responsible for supporting rendering to frame buffer objects that are backed by `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` instances. This provides for more flexibility in OpenGL rendering as it supports configuration of the number of buffers within the underlying swap chain, pixel format of the buffers as well as fine grained control over synchronization of buffer content.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` Builder used to create a `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` with various configurations |
| `interface https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Callback` `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` callbacks that are invoked to render OpenGL content within the underlying buffers. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#execute(java.lang.Runnable)(runnable: https://developer.android.com/reference/java/lang/Runnable.html)` Queue a `https://developer.android.com/reference/java/lang/Runnable.html` to be executed on the GL rendering thread. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#isValid()()` Determines whether or not the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` is in a valid state. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#release(kotlin.Boolean,kotlin.Function0)(cancelPending: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, onReleaseCallback: (() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)?)` Release resources associated with the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#render()()` Render content to a buffer and present the result to the display. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#bufferFormat()` Returns the `https://developer.android.com/reference/kotlin/androidx/hardware/HardwareBufferFormat` of the buffers that are being rendered into by this `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` |
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLRenderer` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#glRenderer()` Returns the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLRenderer` used for issuing requests to render into the underlying buffers with OpenGL. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#maxBuffers()` Returns the number of buffers within the swap chain used for rendering with this `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` |
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/SyncStrategy` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#syncStrategy()` Returns the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/SyncStrategy` used for determining when to create `https://developer.android.com/reference/kotlin/androidx/hardware/SyncFenceCompat` objects in order to handle synchronization. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#usageFlags()` Returns the current usage flag hints of the buffers that are being rendered into by this `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` |

## Public functions

### execute

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

```
fun execute(runnable: Runnable): Unit
```

Queue a `https://developer.android.com/reference/java/lang/Runnable.html` to be executed on the GL rendering thread. Note it is important this `https://developer.android.com/reference/java/lang/Runnable.html` does not block otherwise it can stall the GL thread.

| Parameters |
|---|---|
| `runnable: https://developer.android.com/reference/java/lang/Runnable.html` | to be executed |

### isValid

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

```
fun isValid(): Boolean
```

Determines whether or not the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` is in a valid state. That is the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#release(kotlin.Boolean,kotlin.Function0)` method has not been called. If this returns false, then subsequent calls to `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#render()`, and `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#release(kotlin.Boolean,kotlin.Function0)` are ignored

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if this `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` has been released, `false` otherwise |

### release

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

```
fun release(cancelPending: Boolean, onReleaseCallback: (() -> Unit)? = null): Unit
```

Release resources associated with the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`. After this method is invoked, the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` is in an invalid state and can no longer handle rendering content.

| Parameters |
|---|---|
| `cancelPending: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | If true, pending render requests are cancelled immediately. If false, pending render requests are completed before releasing the renderer. |
| `onReleaseCallback: (() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)? = null` | Optional callback to be invoked on the underlying OpenGL thread when releasing resources has been completed |

### render

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

```
fun render(): Unit
```

Render content to a buffer and present the result to the display.

If this `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` has been released, that is `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer#isValid()` returns `false`, this call is ignored.

## Public properties

### bufferFormat

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

```
val bufferFormat: Int
```

Returns the `https://developer.android.com/reference/kotlin/androidx/hardware/HardwareBufferFormat` of the buffers that are being rendered into by this `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`

Value is one of the following:

- `1`
- `22`
- `43`
- `2`
- `3`
- `4`
- `33`
- `35`
- `48`
- `49`
- `50`
- `51`
- `52`
- `53`
- `54`

<br />

### glRenderer

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

```
val glRenderer: GLRenderer
```

Returns the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLRenderer` used for issuing requests to render into the underlying buffers with OpenGL.

### maxBuffers

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

```
val maxBuffers: Int
```

Returns the number of buffers within the swap chain used for rendering with this `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`

### syncStrategy

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

```
val syncStrategy: SyncStrategy
```

Returns the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/SyncStrategy` used for determining when to create `https://developer.android.com/reference/kotlin/androidx/hardware/SyncFenceCompat` objects in order to handle synchronization. The `https://developer.android.com/reference/kotlin/androidx/hardware/SyncFenceCompat` instance created according to the algorithm specified in the provided `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/SyncStrategy` will be passed to the corresponding `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat.Transaction#setBuffer(androidx.graphics.surface.SurfaceControlCompat,android.hardware.HardwareBuffer,androidx.hardware.SyncFenceCompat,kotlin.Function1)` call in order to ensure the underlying buffer is not presented by the display until the fence signals.

### usageFlags

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

```
val usageFlags: Long
```

Returns the current usage flag hints of the buffers that are being rendered into by this `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`

Value is one of the following:

- `2`
- `3`
- `32`
- `48`
- `256`
- `512`
- `2048`
- `16384`
- `65536`
- `16777216`
- `8388608`
- `33554432`
- `67108864`
- `4294967296`

<br />