mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-21 12:18:28 +00:00
Fixed bug 2924 - SDL_CreateRGBSurface[From] versions that take SDL_PIXELFORMAT enum
Daniel Gibson Currently, SDL_CreateRGBSurface() and SDL_CreateRGBSurfaceFrom() take Uint32 masks for RGBA to "describe" the Pixelformat of the surface. Internally those value are only used to map to one of the SDL_PIXELFORMAT_* enum values that are used for further processing. I think it would be both handy and more efficient to be able to specify SDL_PIXELFORMAT_* yourself without using SDL_PixelFormatEnumToMasks() to create masks first, so I implemented functions that do that: SDL_CreateRGBSurfaceWithFormat() and SDL_CreateRGBSurfaceWithFormatFrom() which are like the versions without "WithFormat" but instead of taking 4 Uint32s for R/G/B/A masks, they take one for a SDL_PIXELFORMAT_* enum value. Together with https://bugzilla.libsdl.org/show_bug.cgi?id=2923 creating a SDL_Surface* from RGBA data (e.g. from stb_image) is as easy as surf = SDL_SDL_CreateRGBSurfaceWithFormat(0, w, h, bppToUse*8, SDL_PIXELFORMAT_RGBA32);
This commit is contained in:
parent
73f2c5413d
commit
d2676c2985
4 changed files with 60 additions and 15 deletions
|
@ -445,6 +445,8 @@
|
|||
#define SDL_iconv_close SDL_iconv_close_REAL
|
||||
#define SDL_iconv SDL_iconv_REAL
|
||||
#define SDL_iconv_string SDL_iconv_string_REAL
|
||||
#define SDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat_REAL
|
||||
#define SDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom_REAL
|
||||
#define SDL_CreateRGBSurface SDL_CreateRGBSurface_REAL
|
||||
#define SDL_CreateRGBSurfaceFrom SDL_CreateRGBSurfaceFrom_REAL
|
||||
#define SDL_FreeSurface SDL_FreeSurface_REAL
|
||||
|
@ -607,3 +609,5 @@
|
|||
#define SDL_RenderGetIntegerScale SDL_RenderGetIntegerScale_REAL
|
||||
#define SDL_DequeueAudio SDL_DequeueAudio_REAL
|
||||
#define SDL_SetWindowResizable SDL_SetWindowResizable_REAL
|
||||
#define SDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat_REAL
|
||||
#define SDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom_REAL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue