mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-13 19:06:03 +00:00
Made use of SDL_CreateRGBSurfaceWithFormat* on SDL 2.0.6+
These functions were introduced in 2.0.5, but a packaging error meant they weren't properly included in the VS libs for that release. So I set the minimum to 2.0.6. Not sure if we want to leave the fallbacks for the other versions or bump the minimum to 2.0.6.
This commit is contained in:
parent
976f37c08a
commit
b51677d985
@ -719,8 +719,13 @@ void pango_text::rerender(const bool force)
|
||||
}
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 6)
|
||||
surface_.assign(SDL_CreateRGBSurfaceWithFormatFrom(
|
||||
&surface_buffer_[0], width, height, 32, stride, SDL_PIXELFORMAT_ARGB8888));
|
||||
#else
|
||||
surface_.assign(SDL_CreateRGBSurfaceFrom(
|
||||
&surface_buffer_[0], width, height, 32, stride, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,21 +48,28 @@ bool is_neutral(const surface& surf)
|
||||
}
|
||||
|
||||
static SDL_PixelFormat& get_neutral_pixel_format()
|
||||
{
|
||||
static bool first_time = true;
|
||||
static SDL_PixelFormat format;
|
||||
{
|
||||
static bool first_time = true;
|
||||
static SDL_PixelFormat format;
|
||||
|
||||
if(first_time) {
|
||||
first_time = false;
|
||||
surface surf(SDL_CreateRGBSurface(0,1,1,32,SDL_RED_MASK,SDL_GREEN_MASK,
|
||||
SDL_BLUE_MASK,SDL_ALPHA_MASK));
|
||||
format = *surf->format;
|
||||
format.palette = nullptr;
|
||||
}
|
||||
if(first_time) {
|
||||
first_time = false;
|
||||
|
||||
return format;
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 6)
|
||||
surface surf(
|
||||
SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888));
|
||||
#else
|
||||
surface surf(
|
||||
SDL_CreateRGBSurface(0, 1, 1, 32, SDL_RED_MASK, SDL_GREEN_MASK, SDL_BLUE_MASK, SDL_ALPHA_MASK));
|
||||
#endif
|
||||
|
||||
format = *surf->format;
|
||||
format.palette = nullptr;
|
||||
}
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
surface make_neutral_surface(const surface &surf)
|
||||
{
|
||||
if(surf == nullptr) {
|
||||
@ -83,12 +90,17 @@ surface create_neutral_surface(int w, int h)
|
||||
}
|
||||
|
||||
SDL_PixelFormat format = get_neutral_pixel_format();
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 6)
|
||||
surface result = SDL_CreateRGBSurfaceWithFormat(0, w, h, format.BitsPerPixel, format.format);
|
||||
#else
|
||||
surface result = SDL_CreateRGBSurface(0, w, h,
|
||||
format.BitsPerPixel,
|
||||
format.Rmask,
|
||||
format.Gmask,
|
||||
format.Bmask,
|
||||
format.Amask);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -2096,8 +2108,13 @@ surface create_compatible_surface(const surface &surf, int width, int height)
|
||||
if(height == -1)
|
||||
height = surf->h;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 6)
|
||||
surface s = SDL_CreateRGBSurfaceWithFormat(0, width, height, surf->format->BitsPerPixel, surf->format->format);
|
||||
#else
|
||||
surface s = SDL_CreateRGBSurface(0, width, height, surf->format->BitsPerPixel,
|
||||
surf->format->Rmask, surf->format->Gmask, surf->format->Bmask, surf->format->Amask);
|
||||
#endif
|
||||
|
||||
if (surf->format->palette) {
|
||||
SDL_SetPaletteColors(s->format->palette, surf->format->palette->colors, 0, surf->format->palette->ncolors);
|
||||
}
|
||||
|
@ -182,13 +182,24 @@ void CVideo::make_fake()
|
||||
{
|
||||
fake_screen_ = true;
|
||||
refresh_rate_ = 1;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 6)
|
||||
frameBuffer = SDL_CreateRGBSurfaceWithFormat(0, 16, 16, 24, SDL_PIXELFORMAT_BGR888);
|
||||
#else
|
||||
frameBuffer = SDL_CreateRGBSurface(0, 16, 16, 24, 0xFF0000, 0xFF00, 0xFF, 0);
|
||||
#endif
|
||||
|
||||
image::set_pixel_format(frameBuffer->format);
|
||||
}
|
||||
|
||||
void CVideo::make_test_fake(const unsigned width, const unsigned height)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 6)
|
||||
frameBuffer = SDL_CreateRGBSurfaceWithFormat(0, width, height, 32, SDL_PIXELFORMAT_BGR888);
|
||||
#else
|
||||
frameBuffer = SDL_CreateRGBSurface(0, width, height, 32, 0xFF0000, 0xFF00, 0xFF, 0);
|
||||
#endif
|
||||
|
||||
image::set_pixel_format(frameBuffer->format);
|
||||
|
||||
fake_interactive = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user