Skip to content

Commit

Permalink
Use pixel format enums for creating surfaces instead color mask values
Browse files Browse the repository at this point in the history
This bumps the min SDL version to 2.0.5, but it's a lot easier to read.
  • Loading branch information
Vultraz committed Jul 31, 2017
1 parent e0dc068 commit 7b735f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/font/text.cpp
Expand Up @@ -741,8 +741,8 @@ void pango_text::rerender(const bool force)
}
}

surface_.assign(SDL_CreateRGBSurfaceFrom(
&surface_buffer_[0], width, height, 32, stride, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000));
surface_.assign(SDL_CreateRGBSurfaceWithFormatFrom(
&surface_buffer_[0], width, height, 32, stride, SDL_PIXELFORMAT_ARGB8888));

// ...and add it to the cache.
rendered_text_cache.emplace(hash_, texture(surface_));
Expand Down
24 changes: 12 additions & 12 deletions src/sdl/utils.cpp
Expand Up @@ -41,21 +41,21 @@ bool is_neutral(const surface& surf)
}

static SDL_PixelFormat& get_neutral_pixel_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;
}
{
static bool first_time = true;
static SDL_PixelFormat format;

return format;
if(first_time) {
first_time = false;
surface surf(SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888));

format = *surf->format;
format.palette = nullptr;
}

return format;
}

surface make_neutral_surface(const surface &surf)
{
if(surf == nullptr) {
Expand Down

0 comments on commit 7b735f7

Please sign in to comment.