about summary refs log tree commit diff stats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/main.c b/src/main.c
index d15877e..4e5d412 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,11 +1,6 @@
 #include "pong.h"
-#include <SDL2/SDL_atomic.h>
-#include <SDL2/SDL_thread.h>
-#include <SDL2/SDL_timer.h>
-#include <raylib.h>
 
 int Difficulty = 1;
-SDL_atomic_t Ticks;
 bool GameGoing = true;
 char VersionString[256];
 
@@ -24,11 +19,12 @@ void set_screen_mode() {
 	switch(GlobalSettings.Fullscreen) {
 		case 1: //Real Fullscreen is fickle as fuck. So it needs a timeout.
 			SetWindowSize(GetMonitorWidth(GetCurrentMonitor()), GetMonitorHeight(GetCurrentMonitor()));
-			int Timeout = SDL_AtomicGet(&Ticks)+300; //Set the timeout for 5 seconds.
+			int Timeout = Ticks+300; //Set the timeout for 5 seconds.
 			while(GetScreenHeight() != GetMonitorHeight(GetCurrentMonitor())) {
+				internal_clock();
 				BeginDrawing();
 				EndDrawing();
-				if(SDL_AtomicGet(&Ticks) >= Timeout) { //Default to windowed if fullscreen fails for whatever reason.
+				if(Ticks >= Timeout) { //Default to windowed if fullscreen fails for whatever reason.
 					goto FullScreenFailed;
 				}
 			}
@@ -51,20 +47,19 @@ void set_screen_mode() {
 	return;
 }
 
-static int internal_clock() {
-	SDL_SetThreadPriority(SDL_THREAD_PRIORITY_TIME_CRITICAL);
-	double NewTime = 0;
-	double OldTime = 0;
-	double Milliseconds = (1000.0/60)/1000.0;
-	double DeltaTime = 0;
-	while(GameGoing == true) {
-		NewTime = SDL_GetTicks()/1000.0f;
-		DeltaTime += (NewTime-OldTime)/Milliseconds;
-		OldTime = NewTime;
-		while(DeltaTime >= 1.0) {
-			SDL_AtomicAdd(&Ticks, 1);
-			DeltaTime--;
-		}
+double NewTime = 0;
+double OldTime = 0;
+double Milliseconds = (1000.0/60)/1000.0;
+double DeltaTime = 0;
+int Ticks = 0;
+
+int internal_clock() {
+	NewTime = SDL_GetTicks()/1000.0f;
+	DeltaTime += (NewTime-OldTime)/Milliseconds;
+	OldTime = NewTime;
+	while(DeltaTime >= 1.0) {
+		Ticks++;
+		DeltaTime--;
 	}
 	return(0);
 }
@@ -172,7 +167,6 @@ int main(int argc, char *argv[]) {
 
 	//Threading
 	AudioQueueBeingModified = SDL_CreateMutex();
-	SDL_AtomicSet(&Ticks, 0);
 	SDL_Thread *InternalClock = SDL_CreateThread(internal_clock, "Internal Clock", NULL);
 	SDL_Thread *AudioThread = SDL_CreateThread(audio, "Audio", NULL);
 	SDL_AtomicSet(&AudioInitializing, 0);