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

*** ** * ** ***


```
public final class GLFrameBufferRenderer.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#Builder(android.view.SurfaceView,androidx.graphics.opengl.GLFrameBufferRenderer.Callback)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/SurfaceView.html surfaceView, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Callback callback )` Create a new `https://developer.android.com/reference/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/androidx/graphics/surface/SurfaceControlCompat` that is presented on screen. |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer` | `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#build()()` Create the `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer` with the specified parameters on this `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` instance |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setBufferFormat(kotlin.Int)(int format)` Specify the buffer format of the underlying buffers being rendered into by the created `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setGLRenderer(androidx.graphics.opengl.GLRenderer)(https://developer.android.com/reference/androidx/graphics/opengl/GLRenderer glRenderer)` Configure the `https://developer.android.com/reference/androidx/graphics/opengl/GLRenderer` instance to be used by the `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setMaxBuffers(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1, to = 64) int numBuffers)` Specify the maximum number of buffers used within the swap chain of the `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setSyncStrategy(androidx.graphics.opengl.SyncStrategy)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/SyncStrategy syncStrategy)` Specify the `https://developer.android.com/reference/androidx/graphics/opengl/SyncStrategy` used for determining when to create `https://developer.android.com/reference/androidx/hardware/SyncFenceCompat` objects in order to handle synchronization. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder#setUsageFlags(kotlin.Long)(long usageFlags)` 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/androidx/graphics/opengl/GLFrameBufferRenderer`. |

## Public constructors

### Builder

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

```
public Builder(
    @NonNull SurfaceView surfaceView,
    @NonNull GLFrameBufferRenderer.Callback callback
)
```

Create a new `https://developer.android.com/reference/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/androidx/graphics/surface/SurfaceControlCompat` that is presented on screen.

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

## Public methods

### build

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

```
public final @NonNull GLFrameBufferRenderer build()
```

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

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

### setBufferFormat

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

```
public final @NonNull GLFrameBufferRenderer.Builder setBufferFormat(int format)
```

Specify the buffer format of the underlying buffers being rendered into by the created `https://developer.android.com/reference/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 |
|---|---|
| `int format` | 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/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull GLFrameBufferRenderer.Builder setGLRenderer(GLRenderer glRenderer)
```

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

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull GLFrameBufferRenderer.Builder setMaxBuffers(@IntRange(from = 1, to = 64) int numBuffers)
```

Specify the maximum number of buffers used within the swap chain of the `https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer`. If 1 is specified, then the created `https://developer.android.com/reference/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/androidx/hardware/SyncFenceCompat` instance specified by the corresponding `https://developer.android.com/reference/androidx/graphics/opengl/SyncStrategy` algorithm

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

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

| See also |
|---|---|
| `https://developer.android.com/reference/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)

```
public final @NonNull GLFrameBufferRenderer.Builder setSyncStrategy(@NonNull SyncStrategy syncStrategy)
```

Specify the `https://developer.android.com/reference/androidx/graphics/opengl/SyncStrategy` used for determining when to create `https://developer.android.com/reference/androidx/hardware/SyncFenceCompat` objects in order to handle synchronization. The `https://developer.android.com/reference/androidx/hardware/SyncFenceCompat` instance created according to the algorithm specified in the provided `https://developer.android.com/reference/androidx/graphics/opengl/SyncStrategy` will be passed to the corresponding `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/SyncStrategy syncStrategy` | `https://developer.android.com/reference/androidx/graphics/opengl/SyncStrategy` used to determine when to create synchronization boundaries for buffer consumption. The default is `https://developer.android.com/reference/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/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull GLFrameBufferRenderer.Builder setUsageFlags(long usageFlags)
```

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/androidx/graphics/opengl/GLFrameBufferRenderer`.

| Parameters |
|---|---|
| `long usageFlags` | 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/androidx/graphics/opengl/GLFrameBufferRenderer` will render into. Must be one of `https://developer.android.com/reference/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/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/GLFrameBufferRenderer.Builder` | The builder instance |