SDL School

API reference / Images and textures

SDL_CreateTextureFromSurface

Function, SDL3

Copies a surface to the graphics card as a texture. You draw textures, and they are fast.

Declaration

#include <SDL3/SDL.h>

SDL_Texture * SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface);

Parameters

rendererThe renderer.
surfaceThe surface to copy.

Return value

A new texture, or NULL on failure.

Example

Load an image
texture = SDL_CreateTextureFromSurface(renderer, surface);

See this code run in Load an image. Download the full program (.zip)

Notes

In SDL2

The name is the same.

See also