# FrameBuffer

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

*** ** * ** ***


```
@RequiresApi(value = 26)
public final class FrameBuffer implements AutoCloseable
```

<br />

*** ** * ** ***

Object that enables rendering into a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` by creating a frame buffer object from it by leveraging Android specific EGL extensions to create an `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` object that is loaded as a texture.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/graphics/opengl/FrameBuffer#FrameBuffer(androidx.graphics.opengl.egl.EGLSpec,android.hardware.HardwareBuffer)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec egl, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/HardwareBuffer.html hardwareBuffer)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/graphics/opengl/FrameBuffer#close()()` Closes out the frame buffer, freeing all resources within it. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/HardwareBuffer.html` | `https://developer.android.com/reference/androidx/graphics/opengl/FrameBuffer#getHardwareBuffer()()` the `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` that this class wraps and used to generate a `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` object |
| `final boolean` | `https://developer.android.com/reference/androidx/graphics/opengl/FrameBuffer#isClosed()()` Boolean that tells if the frame buffer is currently closed |
| `final void` | `https://developer.android.com/reference/androidx/graphics/opengl/FrameBuffer#makeCurrent()()` Binds this frame buffer to the read and draw framebuffer targets if it's not closed. |

## Public constructors

### FrameBuffer

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

```
public FrameBuffer(@NonNull EGLSpec egl, @NonNull HardwareBuffer hardwareBuffer)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec egl` | `https://developer.android.com/reference/androidx/graphics/opengl/egl/EGLSpec` used to specify EGL version and call various EGL methods |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/HardwareBuffer.html hardwareBuffer` | the `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` that this class wraps and used to generate a `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` object |

## Public methods

### close

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

```
public void close()
```

Closes out the frame buffer, freeing all resources within it. This should be done only when the frame buffer is no longer needed or being accessed.

### getHardwareBuffer

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

```
public final @NonNull HardwareBuffer getHardwareBuffer()
```

the `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` that this class wraps and used to generate a `https://developer.android.com/reference/androidx/opengl/EGLImageKHR` object

### isClosed

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

```
public final boolean isClosed()
```

Boolean that tells if the frame buffer is currently closed

### makeCurrent

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

```
public final void makeCurrent()
```

Binds this frame buffer to the read and draw framebuffer targets if it's not closed. If the frame buffer is already closed this method will do nothing.