From 490b13eecc71ba7d3f327004c967efadab0d577e Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 6 Nov 2019 22:25:54 +1000
Subject: Haiku fixes


diff --git a/src/game/game.cpp b/src/game/game.cpp
old mode 100755
new mode 100644
index a5edbaf..45e1e2c
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -200,8 +200,11 @@ void InitGame()
 	GameExperience = (GameConfig().Profile[CurrentProfile].Experience - GameConfig().Profile[CurrentProfile].ByMissionExperience[CurrentMission]) * 1.0f;
 
 	// grab mouse control for both - windows and fullscren mode (need this for multi-monitor systems)
+#ifdef __HAIKU__
+	SDL_SetRelativeMouseMode(SDL_TRUE);
+#else
 	SDL_SetWindowGrab(vw_GetSDLWindow(), SDL_TRUE);
-
+#endif
 
 	// сбрасываем все кнопки мыши
 	vw_ResetMouseButtons();
@@ -349,7 +352,11 @@ void RealExitGame()
 	vw_ReleaseParticleSystem(Shild2);
 
 	// release mouse control
+#ifdef __HAIKU__
+	SDL_SetRelativeMouseMode(SDL_FALSE);
+#else
 	SDL_SetWindowGrab(vw_GetSDLWindow(), SDL_FALSE);
+#endif
 }
 
 //------------------------------------------------------------------------------------
@@ -547,7 +554,11 @@ void DrawGame()
 			SetShowGameCursor(true);
 
 			// release mouse control
+#ifdef __HAIKU__
+			SDL_SetRelativeMouseMode(SDL_FALSE);
+#else
 			SDL_SetWindowGrab(vw_GetSDLWindow(), SDL_FALSE);
+#endif
 			SDL_WarpMouseInWindow(vw_GetSDLWindow(), LastMouseXR, LastMouseYR);
 		}
 		// плавно возвращаем игре сокрость
@@ -563,7 +574,11 @@ void DrawGame()
 			GameMenuStatus = eGameMenuStatus::GAME_MENU;
 
 			// grab mouse control for both - windows and fullscren mode (need this for multi-monitor systems)
+#ifdef __HAIKU__
+			SDL_SetRelativeMouseMode(SDL_TRUE);
+#else
 			SDL_SetWindowGrab(vw_GetSDLWindow(), SDL_TRUE);
+#endif
 			SDL_WarpMouseInWindow(vw_GetSDLWindow(), LastMouseXR, LastMouseYR);
 		}
 		// останавливаем игру
diff --git a/src/main.cpp b/src/main.cpp
index cc55f81..87555cf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -97,6 +97,11 @@ static bool VideoConfig(bool FirstStart)
 	}
 
 	if (FirstStart) {
+#ifdef __HAIKU__
+		ChangeGameConfig().Width = 1024;
+		ChangeGameConfig().Height = 600;
+		ChangeGameConfig().Fullscreen = false;
+#else
 		if (!DetectFullscreenSize().empty()) {
 			ChangeGameConfig().Width = DetectFullscreenSize().back().Width;
 			ChangeGameConfig().Height = DetectFullscreenSize().back().Height;
@@ -106,6 +111,7 @@ static bool VideoConfig(bool FirstStart)
 			ChangeGameConfig().Height = DetectWindowSizeArray().back().Height;
 			ChangeGameConfig().Fullscreen = false;
 		}
+#endif
 		return true;
 	}
 
@@ -151,6 +157,14 @@ static bool CheckOpenGLCapabilities(bool FirstStart)
 	}
 
 	if (FirstStart) {
+#ifdef __HAIKU__
+		ChangeGameConfig().UseGLSL120 = false;
+		ChangeGameConfig().ShadowMap = 0;
+		ChangeGameConfig().MSAA = 0;
+		ChangeGameConfig().CSAA = 0;
+		ChangeGameConfig().MaxPointLights = 1;
+		ChangeGameConfig().AnisotropyLevel = 0;
+#else
 		if (vw_DevCaps().OpenGL_3_0_supported) {
 			ChangeGameConfig().UseGLSL120 = true;
 			ChangeGameConfig().ShadowMap = 1;
@@ -165,6 +179,7 @@ static bool CheckOpenGLCapabilities(bool FirstStart)
 			ChangeGameConfig().CSAA = 4;
 			ChangeGameConfig().MaxPointLights = 6;
 		}
+#endif
 	}
 
 	// NOTE in future, use std::clamp (since C++17)
-- 
2.23.0

