about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorCharadon <dev@iotib.net>2022-06-08 18:39:33 -0400
committerCharadon <dev@iotib.net>2022-06-08 18:39:33 -0400
commit1aa1b17557dca5cc870caebcf20f2a24984460d7 (patch)
treeb026d0b95c336cee57d07d39804aed6a57dd1542 /src
parentbb347dde99572c03bf8937b75931a3ff6530324f (diff)
downloadPong-C-1aa1b17557dca5cc870caebcf20f2a24984460d7.tar.gz
Fixed fullescreen mode
Diffstat (limited to 'src')
-rw-r--r--src/main.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 6a2ba9c..e2e6308 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,6 @@
 #include "pong.h"
+#include <SDL2/SDL_atomic.h>
+#include <raylib.h>
 
 int Difficulty = 1;
 SDL_atomic_t Ticks;
@@ -14,8 +16,16 @@ int AudioQueue[20];
 
 void set_screen_mode() {
 	switch(GlobalSettings.Fullscreen) {
-		case 1:
+		case 1: //Real Fullscreen is fickle as fuck. So it needs a timeout.
 			SetWindowSize(GetMonitorWidth(GetCurrentMonitor()), GetMonitorHeight(GetCurrentMonitor()));
+			int Timeout = SDL_AtomicGet(&Ticks)+100;
+			while(GetScreenHeight() != GetMonitorHeight(GetCurrentMonitor())) {
+				BeginDrawing();
+				EndDrawing();
+				if(SDL_AtomicGet(&Ticks) >= Timeout) { //Default to windowed if fullscreen fails for whatever reason.
+					goto FullScreenFailed;
+				}
+			}
 			SetWindowState(FLAG_FULLSCREEN_MODE);
 			break;
 		case 2:
@@ -25,6 +35,7 @@ void set_screen_mode() {
 			SetWindowSize(GetMonitorWidth(GetCurrentMonitor()), GetMonitorHeight(GetCurrentMonitor()));
 			break;
 		default:
+			FullScreenFailed:
 			ClearWindowState(FLAG_WINDOW_TOPMOST);
 			ClearWindowState(FLAG_WINDOW_UNDECORATED);
 			ClearWindowState(FLAG_FULLSCREEN_MODE);