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
renderer | The renderer. |
surface | The surface to copy. |
Return value
A new texture, or NULL on failure.
Example
texture = SDL_CreateTextureFromSurface(renderer, surface);See this code run in Load an image. Download the full program (.zip)
Notes
- The texture has its own copy, so you can free the surface at once.
In SDL2
The name is the same.