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

*** ** * ** ***


```
public final class EGLConfigAttributes.Builder
```

<br />

*** ** * ** ***

Builder used to create an instance of `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` Allows for a mapping of EGL configuration attributes to their corresponding values as well as including a previously generated `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` instance to be used as a template and conditionally update individual mapped values

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes.Builder#Builder()()` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes.Builder#build()()` Construct an instance of `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` with the mappings of integer keys to their respective values. |
| `final void` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes.Builder#include(androidx.graphics.opengl.egl.EGLConfigAttributes)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes attributes)` Include all the attributes of the given `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` instance. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes.Builder` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes.Builder#setAttribute(kotlin.Int,kotlin.Int)(int attribute, int value)` Map a given EGL configuration attribute key to the given EGL configuration value |

## Public constructors

### Builder

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

```
public Builder()
```

## Public methods

### build

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

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

Construct an instance of `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` with the mappings of integer keys to their respective values. This creates a flat integer array with alternating values for the key value pairs and ends with EGL_NONE

### include

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

```
public final void include(@NonNull EGLConfigAttributes attributes)
```

Include all the attributes of the given `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` instance. This is useful for creating a new `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` instance with all the same attributes as another, allowing for modification of attributes after the fact. For example, the following code snippet can be used to create an `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes` instance that has all the same configuration as `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes#RGBA_8888()` but with a 16 bit stencil buffer size:

For example from Java:

new EglConfigAttributes.Builder() .include(EGLConfigAttributes.RGBA_8888) .setAttribute(EGL14.EGL_STENCIL_SIZE, 16) .build()

Or from the Kotlin factory method:

```
EGLConfigAttributes {
     include(EGLConfigAttributes.RGBA_8888)
     EGL14.EGL_STENCIL_SIZE to 16
}
```

That is all attributes configured after the include will overwrite the attributes configured previously.

### setAttribute

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

```
public final @NonNull EGLConfigAttributes.Builder setAttribute(int attribute, int value)
```

Map a given EGL configuration attribute key to the given EGL configuration value

| Parameters |
|---|---|
| `int attribute` | EGL attribute name such as `https://developer.android.com/reference/android/opengl/EGL14.html#EGL_RED_SIZE` |
| `int value` | Corresponding value for the `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLConfigAttributes.Builder#setAttribute(kotlin.Int,kotlin.Int)` |