---
url: /api/core/renderTarget/functions/setRenderTarget.md
---
# setRenderTarget()

```ts
function setRenderTarget(
  gl: WebGL2RenderingContext,
  target: RenderTarget | null,
  clear?: boolean,
): void;
```

Sets the current render target for the WebGL context.

## Parameters

### gl

`WebGL2RenderingContext`

The WebGL2 context.

### target

[`RenderTarget`](../type-aliases/RenderTarget.md) | `null`

The render target to bind. If null, binds the canvas (default framebuffer).

### clear?

`boolean` = `true`

Whether to clear the color and depth buffers after binding.

## Returns

`void`
