mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-08 18:09:45 +01:00
Don't hardcode SDL_CreateRGBSurface BitsPerPixel/mask args
For some reason, GetSubSurface() and ApplyFilter() were hardcoding the bits-per-pixel and/or mask arguments to SDL_CreateRGBSurface(). I've made them simply re-use the bits-per-pixel and masks of the input surfaces they operate on, but the bits-per-pixel should always be 32 and masks should always go first-byte alpha, second-byte red, third-byte green, fourth-byte blue.
This commit is contained in:
parent
8af9007b5f
commit
760f1e8e5a
1 changed files with 11 additions and 9 deletions
|
@ -20,15 +20,17 @@ SDL_Surface* GetSubSurface( SDL_Surface* metaSurface, int x, int y, int width, i
|
|||
area.w = width;
|
||||
area.h = height;
|
||||
|
||||
// Set the RGBA mask values.
|
||||
Uint32 r, g, b, a;
|
||||
r = 0x000000ff;
|
||||
g = 0x0000ff00;
|
||||
b = 0x00ff0000;
|
||||
a = 0xff000000;
|
||||
|
||||
//Convert to the correct display format after nabbing the new _surface or we will slow things down.
|
||||
SDL_Surface* preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, r, g, b, a);
|
||||
SDL_Surface* preSurface = SDL_CreateRGBSurface(
|
||||
SDL_SWSURFACE,
|
||||
width,
|
||||
height,
|
||||
metaSurface->format->BitsPerPixel,
|
||||
metaSurface->format->Rmask,
|
||||
metaSurface->format->Gmask,
|
||||
metaSurface->format->Bmask,
|
||||
metaSurface->format->Amask
|
||||
);
|
||||
//SDL_Surface* subSurface = SDL_DisplayFormatAlpha(preSurface);
|
||||
|
||||
//SDL_FreeSurface(preSurface);
|
||||
|
@ -337,7 +339,7 @@ void UpdateFilter()
|
|||
|
||||
SDL_Surface* ApplyFilter( SDL_Surface* _src )
|
||||
{
|
||||
SDL_Surface* _ret = SDL_CreateRGBSurface(_src->flags, _src->w, _src->h, 32,
|
||||
SDL_Surface* _ret = SDL_CreateRGBSurface(_src->flags, _src->w, _src->h, _src->format->BitsPerPixel,
|
||||
_src->format->Rmask, _src->format->Gmask, _src->format->Bmask, _src->format->Amask);
|
||||
|
||||
int redOffset = rand() % 4;
|
||||
|
|
Loading…
Reference in a new issue