# GLFrameBufferRenderer.Builder

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

*** ** * ** ***


```
class GLFrameBufferRenderer.Builder
```

<br />

*** ** * ** ***

Builder used to create a `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` with various configurations

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#Builder(android.view.SurfaceView,androidx.graphics.opengl.GLFrameBufferRenderer.Callback)( surfaceView: https://developer.android.com/reference/android/view/SurfaceView.html, callback: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Callback )` Create a new `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` with the provided `https://developer.android.com/reference/android/view/SurfaceView.html` to be the parent of the `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` that is presented on screen. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#build()()` Create the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` with the specified parameters on this `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` instance |
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setBufferFormat(kotlin.Int)(format: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Specify the buffer format of the underlying buffers being rendered into by the created `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`. |
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setGLRenderer(androidx.graphics.opengl.GLRenderer)(glRenderer: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLRenderer?)` Configure the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLRenderer` instance to be used by the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`. |
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setMaxBuffers(kotlin.Int)(numBuffers: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1, to = 64) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Specify the maximum number of buffers used within the swap chain of the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`. |
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setSyncStrategy(androidx.graphics.opengl.SyncStrategy)(syncStrategy: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/SyncStrategy)` Specify 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://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setUsageFlags(kotlin.Long)(usageFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Specify the usage flags to be configured on the underlying `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` instances created by the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`. |

## Public constructors

### Builder

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

```
Builder(
    surfaceView: SurfaceView,
    callback: GLFrameBufferRenderer.Callback
)
```

Create a new `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` with the provided `https://developer.android.com/reference/android/view/SurfaceView.html` to be the parent of the `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` that is presented on screen.

| Parameters |
|---|---|
| `surfaceView: https://developer.android.com/reference/android/view/SurfaceView.html` | SurfaceView to be the parent of the `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat` instance used for presenting rendered content on screen |
| `callback: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Callback` | Callback used to render content within the corresponding buffers as well as optionally configuring `https://developer.android.com/reference/kotlin/androidx/graphics/surface/SurfaceControlCompat.Transaction` to present contents to the display |

## Public functions

### build

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

```
fun build(): GLFrameBufferRenderer
```

Create the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` with the specified parameters on this `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` instance

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` | The newly created `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` |

### setBufferFormat

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

```
fun setBufferFormat(format: Int): GLFrameBufferRenderer.Builder
```

Specify the buffer format of the underlying buffers being rendered into by the created `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`. The set of valid formats is implementation-specific and may depend on additional EGL extensions. The particular valid combinations for a given Android version and implementation should be documented by that version.

`https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBA_8888` and `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBX_8888` are guaranteed to be supported. However, consumers are recommended to query the desired HardwareBuffer configuration using `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#isSupported(int, int, int, int, long)`.

See: khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_get_native_client_buffer.txt

| Parameters |
|---|---|
| `format: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Pixel format of the buffers to be rendered into. The default is RGBA_8888. Value is one of the following: - `1` - `22` - `43` - `2` - `3` - `4` - `33` - `35` - `48` - `49` - `50` - `51` - `52` - `53` - `54` <br /> |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | The builder instance |

### setGLRenderer

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

```
fun setGLRenderer(glRenderer: GLRenderer?): GLFrameBufferRenderer.Builder
```

Configure the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLRenderer` instance to be used by the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`. By default this parameter is null indicating that the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` will create and manage its own `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLRenderer`. This is useful to share the same OpenGL resources and thread across multiple `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` instances.

| Parameters |
|---|---|
| `glRenderer: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLRenderer?` | The `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLRenderer` used for leveraging OpenGL resources including the GL thread |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | The builder instance |

### setMaxBuffers

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

```
fun setMaxBuffers(numBuffers: @IntRange(from = 1, to = 64) Int): GLFrameBufferRenderer.Builder
```

Specify the maximum number of buffers used within the swap chain of the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`. If 1 is specified, then the created `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` is running in "single buffer mode". In this case consumption of the buffer content would need to be coordinated with the `https://developer.android.com/reference/kotlin/androidx/hardware/SyncFenceCompat` instance specified by the corresponding `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/SyncStrategy` algorithm

| Parameters |
|---|---|
| `numBuffers: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1, to = 64) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of buffers within the swap chain to be consumed by the created `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`. This must be greater than zero. The default number of buffers used is 3. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | The builder instance |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setSyncStrategy(androidx.graphics.opengl.SyncStrategy)` | . |

### setSyncStrategy

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

```
fun setSyncStrategy(syncStrategy: SyncStrategy): GLFrameBufferRenderer.Builder
```

Specify 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.

| Parameters |
|---|---|
| `syncStrategy: https://developer.android.com/reference/kotlin/androidx/graphics/opengl/SyncStrategy` | `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/SyncStrategy` used to determine when to create synchronization boundaries for buffer consumption. The default is `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/SyncStrategy#ALWAYS()`, indicating a fence should always be created after a request to render has been made. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | The builder instance |

### setUsageFlags

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

```
fun setUsageFlags(usageFlags: Long): GLFrameBufferRenderer.Builder
```

Specify the usage flags to be configured on the underlying `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` instances created by the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer`.

| Parameters |
|---|---|
| `usageFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Usage flags to be configured on the created `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` instances that the `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer` will render into. Must be one of `https://developer.android.com/reference/kotlin/androidx/hardware/HardwareBufferUsage`. Note that the provided flags here are combined with the following mandatory default flags, `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_GPU_SAMPLED_IMAGE`, `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_GPU_COLOR_OUTPUT` and `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_COMPOSER_OVERLAY` Value is one of the following: - `2` - `3` - `32` - `48` - `256` - `512` - `2048` - `16384` - `65536` - `16777216` - `8388608` - `33554432` - `67108864` - `4294967296` <br /> |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | The builder instance |