mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 12:32:34 +00:00
Sanitized the Being/End2D interface so that it can be used to keep the attribute buffer mapped while processing 2D commands.
For this to work the 2D mode has to be properly set and unset at the right places so that no double mapping occurs and no render operation can happen while in 2D mode. # Conflicts: # src/d_main.cpp # src/v_video.h
This commit is contained in:
parent
2d1043d1d3
commit
ecf6e3f620
4 changed files with 102 additions and 108 deletions
194
src/d_main.cpp
194
src/d_main.cpp
|
@ -733,112 +733,99 @@ void D_Display ()
|
||||||
{
|
{
|
||||||
wipe = false;
|
wipe = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screen->FrameTime = I_msTimeFS();
|
||||||
|
TexMan.UpdateAnimations(screen->FrameTime);
|
||||||
|
R_UpdateSky(screen->FrameTime);
|
||||||
|
screen->BeginFrame();
|
||||||
|
screen->ClearClipRect();
|
||||||
|
if ((gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL) && gametic != 0)
|
||||||
{
|
{
|
||||||
screen->FrameTime = I_msTimeFS();
|
// [ZZ] execute event hook that we just started the frame
|
||||||
TexMan.UpdateAnimations(screen->FrameTime);
|
//E_RenderFrame();
|
||||||
R_UpdateSky(screen->FrameTime);
|
//
|
||||||
screen->BeginFrame();
|
|
||||||
screen->ClearClipRect();
|
// Check for the presence of dynamic lights at the start of the frame once.
|
||||||
|
if ((gl_lights && vid_rendermode == 4) || (r_dynlights && vid_rendermode != 4))
|
||||||
|
{
|
||||||
|
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
||||||
|
level.HasDynamicLights = !!it.Next();
|
||||||
|
}
|
||||||
|
else level.HasDynamicLights = false; // lights are off so effectively we have none.
|
||||||
|
|
||||||
|
viewsec = screen->RenderView(&players[consoleplayer]);
|
||||||
|
screen->Begin2D();
|
||||||
|
screen->DrawBlend(viewsec);
|
||||||
|
if (automapactive)
|
||||||
|
{
|
||||||
|
AM_Drawer (hud_althud? viewheight : StatusBar->GetTopOfStatusbar());
|
||||||
|
}
|
||||||
|
if (!automapactive || viewactive)
|
||||||
|
{
|
||||||
|
screen->RefreshViewBorder ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// for timing the statusbar code.
|
||||||
|
//cycle_t stb;
|
||||||
|
//stb.Reset();
|
||||||
|
//stb.Clock();
|
||||||
|
if (hud_althud && viewheight == SCREENHEIGHT && screenblocks > 10)
|
||||||
|
{
|
||||||
|
StatusBar->DrawBottomStuff (HUD_AltHud);
|
||||||
|
if (DrawFSHUD || automapactive) DrawHUD();
|
||||||
|
if (players[consoleplayer].camera && players[consoleplayer].camera->player && !automapactive)
|
||||||
|
{
|
||||||
|
StatusBar->DrawCrosshair();
|
||||||
|
}
|
||||||
|
StatusBar->CallDraw (HUD_AltHud, vp.TicFrac);
|
||||||
|
StatusBar->DrawTopStuff (HUD_AltHud);
|
||||||
|
}
|
||||||
|
else if (viewheight == SCREENHEIGHT && viewactive && screenblocks > 10)
|
||||||
|
{
|
||||||
|
EHudState state = DrawFSHUD ? HUD_Fullscreen : HUD_None;
|
||||||
|
StatusBar->DrawBottomStuff (state);
|
||||||
|
StatusBar->CallDraw (state, vp.TicFrac);
|
||||||
|
StatusBar->DrawTopStuff (state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StatusBar->DrawBottomStuff (HUD_StatusBar);
|
||||||
|
StatusBar->CallDraw (HUD_StatusBar, vp.TicFrac);
|
||||||
|
StatusBar->DrawTopStuff (HUD_StatusBar);
|
||||||
|
}
|
||||||
|
//stb.Unclock();
|
||||||
|
//Printf("Stbar = %f\n", stb.TimeMS());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
screen->Begin2D();
|
||||||
switch (gamestate)
|
switch (gamestate)
|
||||||
{
|
{
|
||||||
case GS_FULLCONSOLE:
|
case GS_FULLCONSOLE:
|
||||||
screen->Begin2D(false);
|
screen->Begin2D();
|
||||||
C_DrawConsole ();
|
C_DrawConsole ();
|
||||||
M_Drawer ();
|
M_Drawer ();
|
||||||
screen->End2D();
|
screen->End2DAndUpdate ();
|
||||||
screen->Update ();
|
return;
|
||||||
return;
|
|
||||||
|
case GS_INTERMISSION:
|
||||||
case GS_LEVEL:
|
WI_Drawer ();
|
||||||
case GS_TITLELEVEL:
|
break;
|
||||||
if (!gametic)
|
|
||||||
{
|
case GS_FINALE:
|
||||||
screen->Begin2D(false);
|
F_Drawer ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GS_DEMOSCREEN:
|
||||||
|
D_PageDrawer ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
// [ZZ] execute event hook that we just started the frame
|
|
||||||
//E_RenderFrame();
|
|
||||||
//
|
|
||||||
|
|
||||||
// Check for the presence of dynamic lights at the start of the frame once.
|
|
||||||
if ((gl_lights && vid_rendermode == 4) || (r_dynlights && vid_rendermode != 4))
|
|
||||||
{
|
|
||||||
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
|
||||||
level.HasDynamicLights = !!it.Next();
|
|
||||||
}
|
|
||||||
else level.HasDynamicLights = false; // lights are off so effectively we have none.
|
|
||||||
|
|
||||||
viewsec = screen->RenderView(&players[consoleplayer]);
|
|
||||||
screen->Begin2D(false);
|
|
||||||
screen->DrawBlend(viewsec);
|
|
||||||
// returns with 2S mode set.
|
|
||||||
if (automapactive)
|
|
||||||
{
|
|
||||||
AM_Drawer (hud_althud? viewheight : StatusBar->GetTopOfStatusbar());
|
|
||||||
}
|
|
||||||
if (!automapactive || viewactive)
|
|
||||||
{
|
|
||||||
screen->RefreshViewBorder ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// for timing the statusbar code.
|
|
||||||
//cycle_t stb;
|
|
||||||
//stb.Reset();
|
|
||||||
//stb.Clock();
|
|
||||||
if (hud_althud && viewheight == SCREENHEIGHT && screenblocks > 10)
|
|
||||||
{
|
|
||||||
StatusBar->DrawBottomStuff (HUD_AltHud);
|
|
||||||
if (DrawFSHUD || automapactive) DrawHUD();
|
|
||||||
if (players[consoleplayer].camera && players[consoleplayer].camera->player && !automapactive)
|
|
||||||
{
|
|
||||||
StatusBar->DrawCrosshair();
|
|
||||||
}
|
|
||||||
StatusBar->CallDraw (HUD_AltHud, vp.TicFrac);
|
|
||||||
StatusBar->DrawTopStuff (HUD_AltHud);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (viewheight == SCREENHEIGHT && viewactive && screenblocks > 10)
|
|
||||||
{
|
|
||||||
EHudState state = DrawFSHUD ? HUD_Fullscreen : HUD_None;
|
|
||||||
StatusBar->DrawBottomStuff (state);
|
|
||||||
StatusBar->CallDraw (state, vp.TicFrac);
|
|
||||||
StatusBar->DrawTopStuff (state);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StatusBar->DrawBottomStuff (HUD_StatusBar);
|
|
||||||
StatusBar->CallDraw (HUD_StatusBar, vp.TicFrac);
|
|
||||||
StatusBar->DrawTopStuff (HUD_StatusBar);
|
|
||||||
}
|
|
||||||
//stb.Unclock();
|
|
||||||
//Printf("Stbar = %f\n", stb.TimeMS());
|
|
||||||
CT_Drawer ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GS_INTERMISSION:
|
|
||||||
screen->Begin2D(false);
|
|
||||||
WI_Drawer ();
|
|
||||||
CT_Drawer ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GS_FINALE:
|
|
||||||
screen->Begin2D(false);
|
|
||||||
F_Drawer ();
|
|
||||||
CT_Drawer ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GS_DEMOSCREEN:
|
|
||||||
screen->Begin2D(false);
|
|
||||||
D_PageDrawer ();
|
|
||||||
CT_Drawer ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CT_Drawer ();
|
||||||
|
|
||||||
// draw pause pic
|
// draw pause pic
|
||||||
if ((paused || pauseext) && menuactive == MENU_Off)
|
if ((paused || pauseext) && menuactive == MENU_Off)
|
||||||
{
|
{
|
||||||
|
@ -887,7 +874,7 @@ void D_Display ()
|
||||||
C_DrawConsole (); // draw console
|
C_DrawConsole (); // draw console
|
||||||
M_Drawer (); // menu is drawn even on top of everything
|
M_Drawer (); // menu is drawn even on top of everything
|
||||||
FStat::PrintStat ();
|
FStat::PrintStat ();
|
||||||
screen->Update (); // page flip or blit buffer
|
screen->End2DAndUpdate ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -897,6 +884,7 @@ void D_Display ()
|
||||||
|
|
||||||
GSnd->SetSfxPaused(true, 1);
|
GSnd->SetSfxPaused(true, 1);
|
||||||
I_FreezeTime(true);
|
I_FreezeTime(true);
|
||||||
|
screen->End2D();
|
||||||
screen->WipeEndScreen ();
|
screen->WipeEndScreen ();
|
||||||
|
|
||||||
wipestart = I_msTime();
|
wipestart = I_msTime();
|
||||||
|
@ -912,16 +900,16 @@ void D_Display ()
|
||||||
} while (diff < 1);
|
} while (diff < 1);
|
||||||
wipestart = nowtime;
|
wipestart = nowtime;
|
||||||
done = screen->WipeDo (1);
|
done = screen->WipeDo (1);
|
||||||
|
screen->Begin2D();
|
||||||
C_DrawConsole (); // console and
|
C_DrawConsole (); // console and
|
||||||
M_Drawer (); // menu are drawn even on top of wipes
|
M_Drawer (); // menu are drawn even on top of wipes
|
||||||
screen->Update (); // page flip or blit buffer
|
screen->End2DAndUpdate ();
|
||||||
NetUpdate (); // [RH] not sure this is needed anymore
|
NetUpdate (); // [RH] not sure this is needed anymore
|
||||||
} while (!done);
|
} while (!done);
|
||||||
screen->WipeCleanup();
|
screen->WipeCleanup();
|
||||||
I_FreezeTime(false);
|
I_FreezeTime(false);
|
||||||
GSnd->SetSfxPaused(false, 1);
|
GSnd->SetSfxPaused(false, 1);
|
||||||
}
|
}
|
||||||
screen->End2D();
|
|
||||||
cycles.Unclock();
|
cycles.Unclock();
|
||||||
FrameCycles = cycles;
|
FrameCycles = cycles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,6 @@ void OpenGLFrameBuffer::Update()
|
||||||
twoD.Reset();
|
twoD.Reset();
|
||||||
Flush3D.Reset();
|
Flush3D.Reset();
|
||||||
|
|
||||||
DrawRateStuff();
|
|
||||||
Flush3D.Clock();
|
Flush3D.Clock();
|
||||||
GLRenderer->Flush();
|
GLRenderer->Flush();
|
||||||
Flush3D.Unclock();
|
Flush3D.Unclock();
|
||||||
|
|
|
@ -20,7 +20,7 @@ public:
|
||||||
~OpenGLFrameBuffer();
|
~OpenGLFrameBuffer();
|
||||||
|
|
||||||
void InitializeState();
|
void InitializeState();
|
||||||
void Update();
|
void Update() override;
|
||||||
|
|
||||||
// Color correction
|
// Color correction
|
||||||
void SetGamma();
|
void SetGamma();
|
||||||
|
|
|
@ -441,11 +441,18 @@ public:
|
||||||
virtual IUniformBuffer *CreateUniformBuffer(size_t size, bool staticuse = false) { return nullptr; }
|
virtual IUniformBuffer *CreateUniformBuffer(size_t size, bool staticuse = false) { return nullptr; }
|
||||||
virtual IShaderProgram *CreateShaderProgram() { return nullptr; }
|
virtual IShaderProgram *CreateShaderProgram() { return nullptr; }
|
||||||
|
|
||||||
// Begin 2D drawing operations.
|
// Begin/End 2D drawing operations.
|
||||||
// Returns true if hardware-accelerated 2D has been entered, false if not.
|
void Begin2D() { isIn2D = true; }
|
||||||
void Begin2D(bool copy3d) { isIn2D = true; }
|
|
||||||
void End2D() { isIn2D = false; }
|
void End2D() { isIn2D = false; }
|
||||||
|
|
||||||
|
void End2DAndUpdate()
|
||||||
|
{
|
||||||
|
DrawRateStuff();
|
||||||
|
End2D();
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns true if Begin2D has been called and 2D drawing is now active
|
// Returns true if Begin2D has been called and 2D drawing is now active
|
||||||
bool HasBegun2D() { return isIn2D; }
|
bool HasBegun2D() { return isIn2D; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue