mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-10 16:03:15 -04:00
OpenGL: Go into reduced performance mode when window is obscured
This commit is contained in:
parent
455221207c
commit
db9ee23a86
@ -103,6 +103,9 @@ int Window_GetWindowState(void);
|
|||||||
cc_result Window_EnterFullscreen(void);
|
cc_result Window_EnterFullscreen(void);
|
||||||
/* Attempts to restore the window to before it entered full screen. */
|
/* Attempts to restore the window to before it entered full screen. */
|
||||||
cc_result Window_ExitFullscreen(void);
|
cc_result Window_ExitFullscreen(void);
|
||||||
|
/* Returns non-zero if the window is obscured (occluded or minimised) */
|
||||||
|
/* NOTE: Not supported by all windowing backends */
|
||||||
|
int Window_IsObscured(void);
|
||||||
|
|
||||||
/* Makes the window visible and focussed on screen. */
|
/* Makes the window visible and focussed on screen. */
|
||||||
void Window_Show(void);
|
void Window_Show(void);
|
||||||
|
@ -322,6 +322,8 @@ cc_result Window_ExitFullscreen(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Window_IsObscured(void) { return 0; }
|
||||||
|
|
||||||
void Window_Show(void) { } /* Window already visible */
|
void Window_Show(void) { } /* Window already visible */
|
||||||
void Window_SetSize(int width, int height) { }
|
void Window_SetSize(int width, int height) { }
|
||||||
|
|
||||||
|
@ -543,6 +543,8 @@ cc_result Window_ExitFullscreen(void) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Window_IsObscured(void) { return 0; }
|
||||||
|
|
||||||
void Window_Show(void) {
|
void Window_Show(void) {
|
||||||
ShowWindow(win_handle);
|
ShowWindow(win_handle);
|
||||||
/* TODO: Do we actually need to reposition */
|
/* TODO: Do we actually need to reposition */
|
||||||
|
@ -83,6 +83,8 @@ cc_result Window_EnterFullscreen(void) {
|
|||||||
}
|
}
|
||||||
cc_result Window_ExitFullscreen(void) { SDL_RestoreWindow(win_handle); return 0; }
|
cc_result Window_ExitFullscreen(void) { SDL_RestoreWindow(win_handle); return 0; }
|
||||||
|
|
||||||
|
int Window_IsObscured(void) { return 0; }
|
||||||
|
|
||||||
void Window_Show(void) { SDL_ShowWindow(win_handle); }
|
void Window_Show(void) { SDL_ShowWindow(win_handle); }
|
||||||
|
|
||||||
void Window_SetSize(int width, int height) {
|
void Window_SetSize(int width, int height) {
|
||||||
|
@ -466,6 +466,8 @@ cc_result Window_ExitFullscreen(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Window_IsObscured(void) { return 0; }
|
||||||
|
|
||||||
void Window_Show(void) { }
|
void Window_Show(void) { }
|
||||||
|
|
||||||
void Window_SetSize(int width, int height) {
|
void Window_SetSize(int width, int height) {
|
||||||
|
@ -447,6 +447,8 @@ cc_result Window_ExitFullscreen(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Window_IsObscured(void) { return 0; }
|
||||||
|
|
||||||
void Window_Show(void) {
|
void Window_Show(void) {
|
||||||
ShowWindow(win_handle, SW_SHOW);
|
ShowWindow(win_handle, SW_SHOW);
|
||||||
BringWindowToTop(win_handle);
|
BringWindowToTop(win_handle);
|
||||||
|
@ -433,6 +433,8 @@ cc_result Window_ExitFullscreen(void) {
|
|||||||
ToggleFullscreen(_NET_WM_STATE_REMOVE); return 0;
|
ToggleFullscreen(_NET_WM_STATE_REMOVE); return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Window_IsObscured(void) { return 0; }
|
||||||
|
|
||||||
void Window_Show(void) { XMapWindow(win_display, win_handle); }
|
void Window_Show(void) { XMapWindow(win_display, win_handle); }
|
||||||
|
|
||||||
void Window_SetSize(int width, int height) {
|
void Window_SetSize(int width, int height) {
|
||||||
|
@ -275,7 +275,15 @@ void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
|||||||
void Gfx_BeginFrame(void) { frameStart = Stopwatch_Measure(); }
|
void Gfx_BeginFrame(void) { frameStart = Stopwatch_Measure(); }
|
||||||
void Gfx_Clear(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }
|
void Gfx_Clear(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }
|
||||||
|
|
||||||
void Gfx_EndFrame(void) {
|
void Gfx_EndFrame(void) {
|
||||||
|
#ifndef CC_BUILD_GLMODERN
|
||||||
|
if (Window_IsObscured()) {
|
||||||
|
TickReducedPerformance();
|
||||||
|
} else {
|
||||||
|
EndReducedPerformance();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!GLContext_SwapBuffers()) Gfx_LoseContext("GLContext lost");
|
if (!GLContext_SwapBuffers()) Gfx_LoseContext("GLContext lost");
|
||||||
if (gfx_minFrameMs) LimitFPS();
|
if (gfx_minFrameMs) LimitFPS();
|
||||||
}
|
}
|
||||||
|
@ -323,6 +323,8 @@ cc_result Window_ExitFullscreen(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Window_IsObscured(void) { return 0; }
|
||||||
|
|
||||||
void Window_Show(void) {
|
void Window_Show(void) {
|
||||||
[winHandle makeKeyAndOrderFront:appHandle];
|
[winHandle makeKeyAndOrderFront:appHandle];
|
||||||
RefreshWindowBounds(); // TODO: even necessary?
|
RefreshWindowBounds(); // TODO: even necessary?
|
||||||
|
@ -248,6 +248,7 @@ void Window_CloseKeyboard(void) {
|
|||||||
int Window_GetWindowState(void) { return WINDOW_STATE_NORMAL; }
|
int Window_GetWindowState(void) { return WINDOW_STATE_NORMAL; }
|
||||||
cc_result Window_EnterFullscreen(void) { return ERR_NOT_SUPPORTED; }
|
cc_result Window_EnterFullscreen(void) { return ERR_NOT_SUPPORTED; }
|
||||||
cc_result Window_ExitFullscreen(void) { return ERR_NOT_SUPPORTED; }
|
cc_result Window_ExitFullscreen(void) { return ERR_NOT_SUPPORTED; }
|
||||||
|
int Window_IsObscured(void) { return 0; }
|
||||||
|
|
||||||
void Window_EnableRawMouse(void) { }
|
void Window_EnableRawMouse(void) { }
|
||||||
void Window_UpdateRawMouse(void) { }
|
void Window_UpdateRawMouse(void) { }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user