- added a ClearScreen function to the 2D drawer to wrap the frequent occurence of this use case.

This commit is contained in:
Christoph Oelckers 2020-01-05 10:48:44 +01:00
parent a3020ed867
commit 746aa4da82
12 changed files with 34 additions and 27 deletions

View file

@ -385,6 +385,11 @@ void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, F
AddCommand(&dg); AddCommand(&dg);
} }
void F2DDrawer::ClearScreen(PalEntry color)
{
AddColorOnlyQuad(0, 0, screen->GetWidth(), screen->GetHeight(), color);
}
//========================================================================== //==========================================================================
// //
// //

View file

@ -133,7 +133,7 @@ public:
void AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin); void AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin);
void AddColorOnlyQuad(int left, int top, int width, int height, PalEntry color, FRenderStyle *style = nullptr); void AddColorOnlyQuad(int left, int top, int width, int height, PalEntry color, FRenderStyle *style = nullptr);
void ClearScreen(PalEntry color = 0xff000000);
void AddLine(float x1, float y1, float x2, float y2, uint32_t color, uint8_t alpha = 255); void AddLine(float x1, float y1, float x2, float y2, uint32_t color, uint8_t alpha = 255);
void AddLine(float x1, float y1, float x2, float y2, int cx, int cy, int cx2, int cy2, uint32_t color, uint8_t alpha = 255); void AddLine(float x1, float y1, float x2, float y2, int cx, int cy, int cx2, int cy2, uint32_t color, uint8_t alpha = 255);

View file

@ -227,7 +227,7 @@ void DMessageBoxMenu::Drawer()
} }
else else
{ {
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xa0000000); twod->ClearScreen(0xa0000000);
gi->DrawCenteredTextScreen(origin, mFullMessage, 100, false); gi->DrawCenteredTextScreen(origin, mFullMessage, 100, false);
} }
} }

View file

@ -1288,25 +1288,25 @@ void G_PlayE4Cutscene(void)
renderFlushPerms(); renderFlushPerms();
videoSetViewableArea(0, 0, xdim-1, ydim-1); videoSetViewableArea(0, 0, xdim-1, ydim-1);
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
if (Anim_Play("vol41a.anm")) if (Anim_Play("vol41a.anm"))
goto end_vol4a; goto end_vol4a;
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
if (Anim_Play("vol42a.anm")) if (Anim_Play("vol42a.anm"))
goto end_vol4a; goto end_vol4a;
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
Anim_Play("vol43a.anm"); Anim_Play("vol43a.anm");
end_vol4a: end_vol4a:
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
FX_StopAllSounds(); FX_StopAllSounds();

View file

@ -898,7 +898,7 @@ void G_DisplayRest(int32_t smoothratio)
if (ud.overhead_on == 2) if (ud.overhead_on == 2)
{ {
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
G_DrawBackground(); // Necessary GL fills the entire screen with black G_DrawBackground(); // Necessary GL fills the entire screen with black
renderDrawMapView(cposx, cposy, pp->zoom, cang); renderDrawMapView(cposx, cposy, pp->zoom, cang);
} }

View file

@ -622,7 +622,7 @@ void DrawMap()
//drawoverheadmap(initx, inity, lMapZoom, inita); //drawoverheadmap(initx, inity, lMapZoom, inita);
if (nMapMode == 2) if (nMapMode == 2)
{ {
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
RefreshBackground(); RefreshBackground();
renderDrawMapView(initx, inity, lMapZoom, inita); renderDrawMapView(initx, inity, lMapZoom, inita);
} }

View file

@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "light.h" #include "light.h"
#include "cd.h" #include "cd.h"
#include "menu/menu.h" #include "menu/menu.h"
#include "v_2ddrawer.h"
#include <string> #include <string>
#include <assert.h> #include <assert.h>
@ -672,6 +673,7 @@ int menu_DrawTheMap(int nLevel, int nLevelNew, int nLevelBest)
while (nIdleSeconds < 12) while (nIdleSeconds < 12)
{ {
HandleAsync(); HandleAsync();
twod->ClearScreen();
if (((int)totalclock - startTime) / kTimerTicks) if (((int)totalclock - startTime) / kTimerTicks)
{ {

View file

@ -256,7 +256,7 @@ void PlayMovie(const char* fileName)
} }
} }
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
rotatesprite(160 << 16, 100 << 16, z, angle, kMovieTile, 0, 1, 2, 0, 0, xdim - 1, ydim - 1); rotatesprite(160 << 16, 100 << 16, z, angle, kMovieTile, 0, 1, 2, 0, 0, xdim - 1, ydim - 1);
if (bDoFade) { if (bDoFade) {

View file

@ -1907,23 +1907,23 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum)
renderFlushPerms(); renderFlushPerms();
videoSetViewableArea(0,0,xdim-1,ydim-1); videoSetViewableArea(0,0,xdim-1,ydim-1);
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
int animReturn = Anim_Play("vol41a.anm"); int animReturn = Anim_Play("vol41a.anm");
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
if (animReturn) if (animReturn)
goto end_vol4a; goto end_vol4a;
animReturn = Anim_Play("vol42a.anm"); animReturn = Anim_Play("vol42a.anm");
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
if (animReturn) if (animReturn)
goto end_vol4a; goto end_vol4a;
Anim_Play("vol43a.anm"); Anim_Play("vol43a.anm");
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
end_vol4a: end_vol4a:

View file

@ -928,7 +928,7 @@ void G_DisplayRest(int32_t smoothratio)
if (ud.overhead_on == 2) if (ud.overhead_on == 2)
{ {
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
G_DrawBackground(); G_DrawBackground();
renderDrawMapView(cposx, cposy, pp->zoom, cang); renderDrawMapView(cposx, cposy, pp->zoom, cang);
} }

View file

@ -326,7 +326,7 @@ playanm(short anim_num)
ENDOFANIMLOOP: ENDOFANIMLOOP:
GLInterface.EnableNonTransparent255(false); GLInterface.EnableNonTransparent255(false);
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
videoSetPalette(0, BASEPAL, 2); videoSetPalette(0, BASEPAL, 2);

View file

@ -1462,7 +1462,7 @@ void LogoLevel(void)
DSPRINTF(ds,"About to display 3drealms pic..."); DSPRINTF(ds,"About to display 3drealms pic...");
MONO_PRINT(ds); MONO_PRINT(ds);
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
rotatesprite(0, 0, RS_SCALE, 0, THREED_REALMS_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1); rotatesprite(0, 0, RS_SCALE, 0, THREED_REALMS_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
videoNextPage(); videoNextPage();
//FadeIn(0, 3); //FadeIn(0, 3);
@ -1486,7 +1486,7 @@ void LogoLevel(void)
} }
} }
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
videoSetPalette(0, BASEPAL, 2); videoSetPalette(0, BASEPAL, 2);
@ -1517,7 +1517,7 @@ void CreditsLevel(void)
save = gs.BorderNum; save = gs.BorderNum;
ClearStartMost(); ClearStartMost();
gs.BorderNum = save; gs.BorderNum = save;
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
// Lo Wang feel like singing! // Lo Wang feel like singing!
@ -1580,7 +1580,7 @@ void CreditsLevel(void)
} }
// put up a blank screen while loading // put up a blank screen while loading
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
inputState.ClearAllInput(); inputState.ClearAllInput();
Mus_Stop(); Mus_Stop();
@ -1618,7 +1618,7 @@ TitleLevel(void)
tempbuf[i] = i; tempbuf[i] = i;
palookup[0] = tempbuf; palookup[0] = tempbuf;
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
ready2send = 0; ready2send = 0;
@ -1675,19 +1675,19 @@ TitleLevel(void)
void DrawMenuLevelScreen(void) void DrawMenuLevelScreen(void)
{ {
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
rotatesprite(0, 0, RS_SCALE, 0, TITLE_PIC, 20, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1); rotatesprite(0, 0, RS_SCALE, 0, TITLE_PIC, 20, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
} }
void DrawStatScreen(void) void DrawStatScreen(void)
{ {
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
rotatesprite(0, 0, RS_SCALE, 0, STAT_SCREEN_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1); rotatesprite(0, 0, RS_SCALE, 0, STAT_SCREEN_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
} }
void DrawLoadLevelScreen(void) void DrawLoadLevelScreen(void)
{ {
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
rotatesprite(0, 0, RS_SCALE, 0, TITLE_PIC, 20, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1); rotatesprite(0, 0, RS_SCALE, 0, TITLE_PIC, 20, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
} }
@ -1723,7 +1723,7 @@ void MenuLevel(void)
DemoMode = FALSE; DemoMode = FALSE;
DemoPlaying = FALSE; DemoPlaying = FALSE;
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
//FadeOut(0, 0); //FadeOut(0, 0);
@ -1833,7 +1833,7 @@ void MenuLevel(void)
inputState.ClearAllInput(); inputState.ClearAllInput();
M_ClearMenus(); M_ClearMenus();
InMenuLevel = FALSE; InMenuLevel = FALSE;
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
} }
@ -2058,7 +2058,7 @@ void BonusScreen(PLAYERp pp)
if (Level < 0) Level = 0; if (Level < 0) Level = 0;
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
videoNextPage(); videoNextPage();
inputState.ClearAllInput(); inputState.ClearAllInput();
@ -2101,7 +2101,7 @@ void BonusScreen(PLAYERp pp)
gStateControl(&State, &Tics); gStateControl(&State, &Tics);
twod->AddColorOnlyQuad(0, 0, xdim, ydim, 0xff000000); twod->ClearScreen();
rotatesprite(0, 0, RS_SCALE, 0, 5120, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1); rotatesprite(0, 0, RS_SCALE, 0, 5120, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
if (UserMapName[0]) if (UserMapName[0])