1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-18 10:38:31 +02:00

Convert roomname background to a surface, then draw that

The roomname background used to just be a simple SDL_Rect that was drawn
using SDL_FillRect with a color of 0. Unfortunately, it seems that you
cannot use transparent colors with SDL_FillRect, it just defaults to
being fully opaque. However, you CAN draw surfaces with translucency,
which seems like the easiest thing to do. But the first step is to
convert the roomname background to an SDL_Surface.

This replaces the FillRect()s with SDL_BlitSurface() in the three places
roomnames are drawn: in towerrender, in gamerender, and in editorrender.
This commit is contained in:
Info Teddy 2020-01-24 20:32:55 -08:00 committed by Ethan Lee
parent f6fa8dd84c
commit c49ae404af
4 changed files with 10 additions and 3 deletions

View File

@ -238,6 +238,7 @@ public:
SDL_Rect foot_rect;
SDL_Rect prect;
SDL_Rect footerrect;
SDL_Surface* footerbuffer;
int linestate, linedelay;
int backoffset;

View File

@ -3447,7 +3447,8 @@ void editorrender( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, ent
{
if(ed.roomnamehide<12) ed.roomnamehide++;
}
FillRect(dwgfx.backBuffer, 0,230+ed.roomnamehide,320,10, dwgfx.getRGB(0,0,0));
dwgfx.footerrect.y = 230+ed.roomnamehide;
SDL_BlitSurface(dwgfx.footerbuffer, NULL, dwgfx.backBuffer, &dwgfx.footerrect);
dwgfx.Print(5,231+ed.roomnamehide,ed.level[ed.levx+(ed.maxwidth*ed.levy)].roomname, 196, 196, 255 - help.glow, true);
dwgfx.bprint(4, 222, "SPACE ^ SHIFT ^", 196, 196, 255 - help.glow, false);
dwgfx.bprint(268,222, "("+help.String(ed.levx+1)+","+help.String(ed.levy+1)+")",196, 196, 255 - help.glow, false);

View File

@ -125,6 +125,9 @@ int main(int argc, char *argv[])
const SDL_PixelFormat* fmt = gameScreen.GetFormat();
graphics.backBuffer = SDL_CreateRGBSurface(SDL_SWSURFACE ,320 ,240 ,32,fmt->Rmask,fmt->Gmask,fmt->Bmask,fmt->Amask ) ;
SDL_SetSurfaceBlendMode(graphics.backBuffer, SDL_BLENDMODE_NONE);
graphics.footerbuffer = SDL_CreateRGBSurface(SDL_SWSURFACE, 320, 10, 32, fmt->Rmask, fmt->Gmask, fmt->Bmask, fmt->Amask);
SDL_SetSurfaceBlendMode(graphics.footerbuffer, SDL_BLENDMODE_BLEND);
FillRect(graphics.footerbuffer, SDL_MapRGB(fmt, 0, 0, 0));
graphics.Makebfont();

View File

@ -1552,7 +1552,8 @@ void gamerender(Graphics& dwgfx, mapclass& map, Game& game, entityclass& obj, Ut
if(map.extrarow==0 || (map.custommode && map.roomname!=""))
{
FillRect(dwgfx.backBuffer, dwgfx.footerrect, 0);
dwgfx.footerrect.y = 230;
SDL_BlitSurface(dwgfx.footerbuffer, NULL, dwgfx.backBuffer, &dwgfx.footerrect);
if (map.finalmode)
{
@ -2808,7 +2809,8 @@ void towerrender(Graphics& dwgfx, Game& game, mapclass& map, entityclass& obj, U
}
FillRect(dwgfx.backBuffer, dwgfx.footerrect, 0x000000);
dwgfx.footerrect.y = 230;
SDL_BlitSurface(dwgfx.footerbuffer, NULL, dwgfx.backBuffer, &dwgfx.footerrect);
dwgfx.Print(5, 231, map.roomname, 196, 196, 255 - help.glow, true);
//dwgfx.rprint(5, 231,help.String(game.coins), 255 - help.glow/2, 255 - help.glow/2, 196, true);