1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Re-add temporary allocation in BlitSurfaceTransform

Unfortunately there needs to be an intermediate surface for proper alpha
color blending to happen via SDL_BlitSurface. The exact SDL blending
logic seems complicated and unclear for me to implement at the moment,
and my attempts kind of failed, so this is just a stopgap measure to at
least get the game rendering how it was before I screwed it up.
This commit is contained in:
Misa 2023-01-04 15:33:56 -08:00
parent 91339c77db
commit 2e03f2b03d

View file

@ -220,6 +220,14 @@ static void BlitSurfaceTransform(
blit_y = dest_rect->y; blit_y = dest_rect->y;
} }
/* FIXME: Find a way to do this without allocating... */
SDL_Surface* tempsurface = RecreateSurface(dest);
if (tempsurface == NULL)
{
return;
}
SDL_SetSurfaceBlendMode(tempsurface, SDL_BLENDMODE_BLEND);
for (int x = 0; x < orig_rect.w; x++) for (int x = 0; x < orig_rect.w; x++)
{ {
for (int y = 0; y < orig_rect.h; y++) for (int y = 0; y < orig_rect.h; y++)
@ -237,9 +245,12 @@ static void BlitSurfaceTransform(
} }
const SDL_Color result = transform(pixel, color); const SDL_Color result = transform(pixel, color);
DrawPixel(dest, blit_x + x, blit_y + y, result); DrawPixel(tempsurface, blit_x + x, blit_y + y, result);
} }
} }
SDL_BlitSurface(tempsurface, NULL, dest, NULL);
VVV_freefunc(SDL_FreeSurface, tempsurface);
} }
static SDL_Color transform_color(const SDL_Color pixel, const SDL_Color color) static SDL_Color transform_color(const SDL_Color pixel, const SDL_Color color)