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);
|
||||
/* Attempts to restore the window to before it entered full screen. */
|
||||
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. */
|
||||
void Window_Show(void);
|
||||
|
@ -322,6 +322,8 @@ cc_result Window_ExitFullscreen(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Window_IsObscured(void) { return 0; }
|
||||
|
||||
void Window_Show(void) { } /* Window already visible */
|
||||
void Window_SetSize(int width, int height) { }
|
||||
|
||||
|
@ -543,6 +543,8 @@ cc_result Window_ExitFullscreen(void) {
|
||||
return res;
|
||||
}
|
||||
|
||||
int Window_IsObscured(void) { return 0; }
|
||||
|
||||
void Window_Show(void) {
|
||||
ShowWindow(win_handle);
|
||||
/* 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; }
|
||||
|
||||
int Window_IsObscured(void) { return 0; }
|
||||
|
||||
void Window_Show(void) { SDL_ShowWindow(win_handle); }
|
||||
|
||||
void Window_SetSize(int width, int height) {
|
||||
|
@ -466,6 +466,8 @@ cc_result Window_ExitFullscreen(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Window_IsObscured(void) { return 0; }
|
||||
|
||||
void Window_Show(void) { }
|
||||
|
||||
void Window_SetSize(int width, int height) {
|
||||
|
@ -447,6 +447,8 @@ cc_result Window_ExitFullscreen(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Window_IsObscured(void) { return 0; }
|
||||
|
||||
void Window_Show(void) {
|
||||
ShowWindow(win_handle, SW_SHOW);
|
||||
BringWindowToTop(win_handle);
|
||||
|
@ -433,6 +433,8 @@ cc_result Window_ExitFullscreen(void) {
|
||||
ToggleFullscreen(_NET_WM_STATE_REMOVE); return 0;
|
||||
}
|
||||
|
||||
int Window_IsObscured(void) { return 0; }
|
||||
|
||||
void Window_Show(void) { XMapWindow(win_display, win_handle); }
|
||||
|
||||
void Window_SetSize(int width, int height) {
|
||||
|
@ -276,6 +276,14 @@ void Gfx_BeginFrame(void) { frameStart = Stopwatch_Measure(); }
|
||||
void Gfx_Clear(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }
|
||||
|
||||
void Gfx_EndFrame(void) {
|
||||
#ifndef CC_BUILD_GLMODERN
|
||||
if (Window_IsObscured()) {
|
||||
TickReducedPerformance();
|
||||
} else {
|
||||
EndReducedPerformance();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!GLContext_SwapBuffers()) Gfx_LoseContext("GLContext lost");
|
||||
if (gfx_minFrameMs) LimitFPS();
|
||||
}
|
||||
|
@ -323,6 +323,8 @@ cc_result Window_ExitFullscreen(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Window_IsObscured(void) { return 0; }
|
||||
|
||||
void Window_Show(void) {
|
||||
[winHandle makeKeyAndOrderFront:appHandle];
|
||||
RefreshWindowBounds(); // TODO: even necessary?
|
||||
|
@ -248,6 +248,7 @@ void Window_CloseKeyboard(void) {
|
||||
int Window_GetWindowState(void) { return WINDOW_STATE_NORMAL; }
|
||||
cc_result Window_EnterFullscreen(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_UpdateRawMouse(void) { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user