Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
loading-screens: draw black below loading screens
  • Loading branch information
blattersturm committed Jul 4, 2019
1 parent a18fabe commit b9075c0
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions code/components/loading-screens-five/src/LoadingScreens.cpp
Expand Up @@ -21,6 +21,9 @@

#include <CoreConsole.h>

#include <Rect.h>
#include <DrawCommands.h>

#include <Error.h>

static std::shared_ptr<ConVar<bool>> g_loadProfileConvar;
Expand All @@ -35,6 +38,7 @@ static std::set<uint64_t> g_visitedTimings;

using fx::Resource;

static bool g_doDrawBelowLoadingScreens;
static bool frameOn = false;
static bool primedMapLoad = false;

Expand All @@ -60,6 +64,8 @@ static void DestroyFrame()
{
if (frameOn)
{
g_doDrawBelowLoadingScreens = false;

nui::DestroyFrame("loadingScreen");

frameOn = false;
Expand Down Expand Up @@ -251,6 +257,8 @@ static InitFunction initFunction([] ()
}
});

g_doDrawBelowLoadingScreens = true;

nui::CreateFrame("loadingScreen", loadingScreens.back());
nui::OverrideFocus(true);

Expand Down Expand Up @@ -523,4 +531,45 @@ static InitFunction initFunction([] ()
InvokeNUIScript("onDataFileEntry", doc);
}
});

OnPostFrontendRender.Connect([]()
{
if (!g_doDrawBelowLoadingScreens)
{
return;
}

SetTextureGtaIm(rage::grcTextureFactory::GetNoneTexture());

auto oldRasterizerState = GetRasterizerState();
SetRasterizerState(GetStockStateIdentifier(RasterizerStateNoCulling));

auto oldBlendState = GetBlendState();
SetBlendState(GetStockStateIdentifier(BlendStateNoBlend));

auto oldDepthStencilState = GetDepthStencilState();
SetDepthStencilState(GetStockStateIdentifier(DepthStencilStateNoDepth));

PushDrawBlitImShader();

BeginImVertices(4, 4);

CRect rect(0.0f, 0.0f, 6144.0f, 6144.0f);
uint32_t color = 0x00000000;

AddImVertex(rect.fX1, rect.fY1, 0.0f, 0.0f, 0.0f, -1.0f, color, 0.0f, 0.0f);
AddImVertex(rect.fX2, rect.fY1, 0.0f, 0.0f, 0.0f, -1.0f, color, 0.0f, 0.0f);
AddImVertex(rect.fX1, rect.fY2, 0.0f, 0.0f, 0.0f, -1.0f, color, 0.0f, 0.0f);
AddImVertex(rect.fX2, rect.fY2, 0.0f, 0.0f, 0.0f, -1.0f, color, 0.0f, 0.0f);

DrawImVertices();

PopDrawBlitImShader();

SetRasterizerState(oldRasterizerState);

SetBlendState(oldBlendState);

SetDepthStencilState(oldDepthStencilState);
}, INT32_MIN);
});

0 comments on commit b9075c0

Please sign in to comment.