---
name: "SDL_RenderReadPixels"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_RenderReadPixels"
---

# SDL\_RenderReadPixels(3)

Read pixels from the current rendering target.

## NAME

SDL\_RenderReadPixels - Read pixels from the current rendering target.

## HEADER FILE

Defined in SDL3/SDL\_render.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**SDL\_Surface \* SDL\_RenderReadPixels(SDL\_Renderer \*renderer, const SDL\_Rect \*rect);**

## DESCRIPTION

The returned surface contains pixels inside the desired area clipped to the current viewport, and should be freed with

**SDL\_DestroySurface** ().

Note that this returns the actual pixels on the screen, so if you are using logical presentation you should use

**SDL\_GetRenderLogicalPresentationRect** () to get the area containing your content. **WARNING** : This is a very slow operation, and should not be used frequently. If you're using this on the main rendering target, it should be called after rendering and before  **SDL\_RenderPresent** ().

## FUNCTION PARAMETERS

- *renderer*

  the rendering context.

- *rect*

  an  **SDL\_Rect**\
    structure representing the area to read, which will be clipped to the current viewport, or NULL for the entire viewport.

## RETURN VALUE

( **SDL\_Surface**\
  \*) Returns a new  **SDL\_Surface**\
  on success or NULL on failure; call  **SDL\_GetError** () for more information.

## THREAD SAFETY

This function should only be called on the main thread.

## AVAILABILITY

This function is available since SDL 3.2.0.
