mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-27 21:51:00 +00:00
- skip rendering when application is not active
Use vid_activeinbackground CVAR to override this behavior
(cherry picked from commit 2be84dc636
)
# Conflicts:
# src/gl/system/gl_framebuffer.cpp
# src/posix/cocoa/i_video.mm
# src/posix/sdl/gl_sysfb.h
# src/posix/sdl/sdlglvideo.cpp
# src/win32/gl_sysfb.h
# src/win32/win32gliface.cpp
This commit is contained in:
parent
b0c013b9dc
commit
21ce592771
11 changed files with 25 additions and 59 deletions
|
@ -250,6 +250,7 @@ FStartupInfo DoomStartupInfo;
|
||||||
FString lastIWAD;
|
FString lastIWAD;
|
||||||
int restart = 0;
|
int restart = 0;
|
||||||
bool batchrun; // just run the startup and collect all error messages in a logfile, then quit without any interaction
|
bool batchrun; // just run the startup and collect all error messages in a logfile, then quit without any interaction
|
||||||
|
bool AppActive = true;
|
||||||
|
|
||||||
cycle_t FrameCycles;
|
cycle_t FrameCycles;
|
||||||
|
|
||||||
|
@ -658,6 +659,8 @@ CVAR (Flag, compat_multiexit, compatflags2, COMPATF2_MULTIEXIT);
|
||||||
CVAR (Flag, compat_teleport, compatflags2, COMPATF2_TELEPORT);
|
CVAR (Flag, compat_teleport, compatflags2, COMPATF2_TELEPORT);
|
||||||
CVAR (Flag, compat_pushwindow, compatflags2, COMPATF2_PUSHWINDOW);
|
CVAR (Flag, compat_pushwindow, compatflags2, COMPATF2_PUSHWINDOW);
|
||||||
|
|
||||||
|
CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// D_Display
|
// D_Display
|
||||||
|
@ -674,6 +677,11 @@ void D_Display ()
|
||||||
if (nodrawers || screen == NULL)
|
if (nodrawers || screen == NULL)
|
||||||
return; // for comparative timing / profiling
|
return; // for comparative timing / profiling
|
||||||
|
|
||||||
|
if (!AppActive && (screen->IsFullscreen() || !vid_activeinbackground))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cycle_t cycles;
|
cycle_t cycles;
|
||||||
|
|
||||||
cycles.Reset();
|
cycles.Reset();
|
||||||
|
|
|
@ -166,12 +166,6 @@ void OpenGLFrameBuffer::InitializeState()
|
||||||
|
|
||||||
void OpenGLFrameBuffer::Update()
|
void OpenGLFrameBuffer::Update()
|
||||||
{
|
{
|
||||||
if (!CanUpdate())
|
|
||||||
{
|
|
||||||
GLRenderer->Flush();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Begin2D(false);
|
Begin2D(false);
|
||||||
|
|
||||||
DrawRateStuff();
|
DrawRateStuff();
|
||||||
|
|
|
@ -302,18 +302,24 @@ ApplicationController* appCtrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern bool AppActive;
|
||||||
|
|
||||||
- (void)applicationDidBecomeActive:(NSNotification*)aNotification
|
- (void)applicationDidBecomeActive:(NSNotification*)aNotification
|
||||||
{
|
{
|
||||||
ZD_UNUSED(aNotification);
|
ZD_UNUSED(aNotification);
|
||||||
|
|
||||||
S_SetSoundPaused(1);
|
S_SetSoundPaused(1);
|
||||||
|
|
||||||
|
AppActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillResignActive:(NSNotification*)aNotification
|
- (void)applicationWillResignActive:(NSNotification*)aNotification
|
||||||
{
|
{
|
||||||
ZD_UNUSED(aNotification);
|
ZD_UNUSED(aNotification);
|
||||||
|
|
||||||
S_SetSoundPaused((!!i_soundinbackground) || 0);
|
S_SetSoundPaused(i_soundinbackground);
|
||||||
|
|
||||||
|
AppActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1122,22 +1122,6 @@ void SDLGLFB::InitializeState()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLGLFB::CanUpdate()
|
|
||||||
{
|
|
||||||
if (m_Lock != 1)
|
|
||||||
{
|
|
||||||
if (m_Lock > 0)
|
|
||||||
{
|
|
||||||
UpdatePending = true;
|
|
||||||
--m_Lock;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLGLFB::SwapBuffers()
|
void SDLGLFB::SwapBuffers()
|
||||||
{
|
{
|
||||||
[[NSOpenGLContext currentContext] flushBuffer];
|
[[NSOpenGLContext currentContext] flushBuffer];
|
||||||
|
|
|
@ -81,7 +81,6 @@ protected:
|
||||||
|
|
||||||
void InitializeState();
|
void InitializeState();
|
||||||
|
|
||||||
bool CanUpdate();
|
|
||||||
void SwapBuffers();
|
void SwapBuffers();
|
||||||
|
|
||||||
void SetGammaTable(uint16_t* table);
|
void SetGammaTable(uint16_t* table);
|
||||||
|
|
|
@ -311,9 +311,16 @@ void MessagePump (const SDL_Event &sev)
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
switch (sev.window.event)
|
switch (sev.window.event)
|
||||||
{
|
{
|
||||||
|
extern bool AppActive;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
|
S_SetSoundPaused(1);
|
||||||
|
AppActive = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
S_SetSoundPaused((!!i_soundinbackground) || sev.window.event == SDL_WINDOWEVENT_FOCUS_GAINED);
|
S_SetSoundPaused(i_soundinbackground);
|
||||||
|
AppActive = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -405,20 +405,6 @@ void SDLGLFB::InitializeState()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLGLFB::CanUpdate ()
|
|
||||||
{
|
|
||||||
if (m_Lock != 1)
|
|
||||||
{
|
|
||||||
if (m_Lock > 0)
|
|
||||||
{
|
|
||||||
UpdatePending = true;
|
|
||||||
--m_Lock;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLGLFB::SetGammaTable(uint16_t *tbl)
|
void SDLGLFB::SetGammaTable(uint16_t *tbl)
|
||||||
{
|
{
|
||||||
if (m_supportsGamma)
|
if (m_supportsGamma)
|
||||||
|
|
|
@ -77,7 +77,6 @@ public:
|
||||||
|
|
||||||
virtual int GetTrueHeight() { return GetClientHeight(); }
|
virtual int GetTrueHeight() { return GetClientHeight(); }
|
||||||
protected:
|
protected:
|
||||||
bool CanUpdate();
|
|
||||||
void SetGammaTable(uint16_t *tbl);
|
void SetGammaTable(uint16_t *tbl);
|
||||||
void ResetGammaTable();
|
void ResetGammaTable();
|
||||||
void InitializeState();
|
void InitializeState();
|
||||||
|
|
|
@ -156,7 +156,7 @@ LPDIRECTINPUT8 g_pdi;
|
||||||
LPDIRECTINPUT g_pdi3;
|
LPDIRECTINPUT g_pdi3;
|
||||||
|
|
||||||
|
|
||||||
BOOL AppActive = TRUE;
|
extern bool AppActive;
|
||||||
int SessionState = 0;
|
int SessionState = 0;
|
||||||
int BlockMouseMove;
|
int BlockMouseMove;
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_ACTIVATEAPP:
|
case WM_ACTIVATEAPP:
|
||||||
AppActive = wParam;
|
AppActive = wParam == TRUE;
|
||||||
if (wParam)
|
if (wParam)
|
||||||
{
|
{
|
||||||
SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS);
|
SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS);
|
||||||
|
|
|
@ -63,7 +63,6 @@
|
||||||
#include "gl/system/gl_swframebuffer.h"
|
#include "gl/system/gl_swframebuffer.h"
|
||||||
|
|
||||||
extern HWND Window;
|
extern HWND Window;
|
||||||
extern BOOL AppActive;
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
|
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
|
||||||
|
@ -80,8 +79,6 @@ PFNWGLSWAPINTERVALEXTPROC myWglSwapIntervalExtProc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|
||||||
|
|
||||||
CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||||
{
|
{
|
||||||
Printf("This won't take effect until " GAMENAME " is restarted.\n");
|
Printf("This won't take effect until " GAMENAME " is restarted.\n");
|
||||||
|
@ -1143,18 +1140,6 @@ void Win32GLFrameBuffer::InitializeState()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool Win32GLFrameBuffer::CanUpdate()
|
|
||||||
{
|
|
||||||
if (!AppActive && (IsFullscreen() || !vid_activeinbackground)) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void Win32GLFrameBuffer::ResetGammaTable()
|
void Win32GLFrameBuffer::ResetGammaTable()
|
||||||
{
|
{
|
||||||
if (m_supportsGamma)
|
if (m_supportsGamma)
|
||||||
|
|
|
@ -67,8 +67,6 @@ public:
|
||||||
void InitializeState();
|
void InitializeState();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool CanUpdate();
|
|
||||||
void ResetGammaTable();
|
void ResetGammaTable();
|
||||||
void SetGammaTable(uint16_t * tbl);
|
void SetGammaTable(uint16_t * tbl);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue