SDL_CreateTextureFromSurface

Use this function to create a texture from an existing surface.

Syntax

SDL_Texture* SDL_CreateTextureFromSurface(Uint32       format,
                                          SDL_Surface* surface)

Function Parameters

format

one of the enumerated values in SDL_PixelFormatEnum, or 0 to pick an appropriate format; see Remarks for details

surface

the SDL_Surface structure containing pixel data used to fill the texture

Return Value

Returns the created texture or 0 if no rendering context was active, the format was unsupported, or the surface width or height were out of range; call SDL_GetError() for more information.

Code Examples

You can add your code example here

Remarks

The surface is not modified or freed by this function.

format may be one of the following:

SDL_PIXELFORMAT_UNKNOWN

SDL_PIXELFORMAT_INDEX1LSB

SDL_PIXELFORMAT_INDEX1MSB

SDL_PIXELFORMAT_INDEX4LSB

SDL_PIXELFORMAT_INDEX4MSB

SDL_PIXELFORMAT_INDEX8

SDL_PIXELFORMAT_RGB332

SDL_PIXELFORMAT_RGB444

SDL_PIXELFORMAT_RGB555

SDL_PIXELFORMAT_BGR555

SDL_PIXELFORMAT_ARGB4444

SDL_PIXELFORMAT_ABGR4444

SDL_PIXELFORMAT_ARGB1555

SDL_PIXELFORMAT_ABGR1555

SDL_PIXELFORMAT_RGB565

SDL_PIXELFORMAT_BGR565

SDL_PIXELFORMAT_RGB24

SDL_PIXELFORMAT_BGR24

SDL_PIXELFORMAT_RGB888

SDL_PIXELFORMAT_BGR888

SDL_PIXELFORMAT_ARGB8888

SDL_PIXELFORMAT_RGBA8888

SDL_PIXELFORMAT_ABGR8888

SDL_PIXELFORMAT_BGRA8888

SDL_PIXELFORMAT_ARGB2101010

SDL_PIXELFORMAT_YV12

planar mode: Y + V + U (3 planes)

SDL_PIXELFORMAT_IYUV

planar mode: Y + U + V (3 planes)

SDL_PIXELFORMAT_YUY2

packed mode: Y0+U0+Y1+V0 (1 plane)

SDL_PIXELFORMAT_UYVY

packed mode: U0+Y0+V0+Y1 (1 plane)

SDL_PIXELFORMAT_YVYU

packed mode: Y0+V0+Y1+U0 (1 plane)


CategoryAPI, CategoryVideo

SDL_CreateTextureFromSurface (last edited 2011-01-04 19:11:31 by SheenaSmith)

Feedback
Please include your contact information if you'd like to receive a reply.
Submit