SDL Wiki
(This is the documentation for SDL3, which is the current stable version. SDL2 was the previous version!)

SDL_RenderReadPixels

Read pixels from the current rendering target.

Header File

Defined in <SDL3/SDL_render.h>

Syntax

SDL_Surface * SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect);

Function Parameters

SDL_Renderer * renderer the rendering context.
const SDL_Rect * rect an SDL_Rect structure representing the area in pixels relative to the to 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.

Remarks

The returned surface should be freed with SDL_DestroySurface()

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().

Thread Safety

You may only call this function from the main thread.

Version

This function is available since SDL 3.1.3.


CategoryAPI, CategoryAPIFunction, CategoryRender


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.