Dear Friends at Epic,
In UnrealClient.h,
Trying to access IsGameRenderingEnabled() throws compiler error, while other functions and static functions work correctly.
The underlying member that is being returned, bIsGameRenderingEnabled, is not being found for some reason.
here’s the compiler error I’m getting:
1>Module.VictoryGame.cpp.obj : error LNK2001: unresolved external symbol “protected: static bool FViewport::bIsGameRenderingEnabled” (?bIsGameRenderingEnabled@FViewport@@1_NA)
1>E:\RocketVictory\VictoryGame\Binaries\Win64\RocketEditor-VictoryGame.dll : fatal error LNK1120: 1 unresolved externals
I dont understand why it’s being listed as a static bool when its value changes during game time depending on whether render thread is frozen
the function is NOT static, its definition is:
//UnrealClient.h
bool IsGameRenderingEnabled() { return bIsGameRenderingEnabled; }
Here’s the line in my working code below, for which I am already posting a video online showing how to freeze game render any time
So to repeat, the code below works perfectly, except this one check to see if the rendering is frozen currently.
TheViewport->IsGameRenderingEnabled()
void AVictoryGamePlayerController::FreezeRenderIfNotForeGroundWindow()
{
//Get Player, assumes not multiplayer context
ULocalPlayer* ThisPlayer = GetWorld()->GetFirstLocalPlayerFromController();
//Found player?
if(!ThisPlayer) return;
//get view port ptr
UGameViewportClient* TheViewportClient = ThisPlayer->ViewportClient;
//Found viewport?
if(!TheViewportClient) return;
//~~~~ Viewport client ~~~
FViewport* TheViewport = TheViewportClient->Viewport;
if(!TheViewport) return;
//has focus but is *not* yet unfrozen
if (TheViewport->IsForegroundWindow() && !TheViewport->IsGameRenderingEnabled())
{
//unfreeze
FViewport::SetGameRenderingEnabled(true);
}
else
{
//freeze
FViewport::SetGameRenderingEnabled(false);
}
}
Any idea how I can check whether render thread is frozen or not and why the bool is listed as static?
PS: For comparison purposes, my call to:
if(TheViewport->IsForegroundWindow())
works perfectly fine and is the foundation of my video tutorial on freezing render thread when end user is tabbed out.