diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 5e07a02..79c9b6f 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -794,7 +794,7 @@ static bool sdlVideoModeOK(int disp, const int w, const int h, const int bpp) { if(!w && !h) return true; -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) SDL_DisplayMode mode; const int modecount = SDL_GetNumDisplayModes(disp); for (int i = 0; i < modecount; i++) { @@ -915,7 +915,7 @@ This build is not yet final, and as such there are a couple things lacking. They SDL_Init(SDL_INIT_VIDEO); if (fullscreen && !sdlVideoModeOK(user.video.displayindex, user.video.resx, user.video.resy, user.video.bits)) { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) SDL_DisplayMode mode, closest; mode.format = 0; mode.driverdata = 0; diff --git a/Aquaria/Network.cpp b/Aquaria/Network.cpp index 4bd27ce..9fe2350 100644 --- a/Aquaria/Network.cpp +++ b/Aquaria/Network.cpp @@ -154,7 +154,7 @@ static void init() if(!worker) { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) worker = SDL_CreateThread(_NetworkWorkerThread, "network", NULL); #else worker = SDL_CreateThread(_NetworkWorkerThread, NULL); diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 1bc504f..8d6c420 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -916,7 +916,7 @@ luaFunc(loadfile_caseinsensitive) } } -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) #define LUAAPI_HAS_CLIPBOARD luaFunc(os_setclipboard) { @@ -9513,7 +9513,7 @@ luaFunc(pe_isRunning) luaFunc(getPerformanceCounter) { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) luaReturnNum((lua_Number)SDL_GetPerformanceCounter()); #else luaReturnNum((lua_Number)SDL_GetTicks()); @@ -9522,7 +9522,7 @@ luaFunc(getPerformanceCounter) luaFunc(getPerformanceFreq) { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) luaReturnNum((lua_Number)SDL_GetPerformanceFrequency()); #else luaReturnNum((lua_Number)1000); diff --git a/BBGE/ActionInput.cpp b/BBGE/ActionInput.cpp index 8264c6f..9432b6d 100644 --- a/BBGE/ActionInput.cpp +++ b/BBGE/ActionInput.cpp @@ -140,7 +140,7 @@ std::string getInputCodeToUserString(unsigned int k, size_t joystickID) // It's just confusing to see Y instead of Z with a german keyboard layout... if(k && k < KEY_MAXARRAY) { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) pretty = SDL_GetScancodeName((SDL_Scancode)k); const SDL_Keycode kcode = SDL_GetKeyFromScancode((SDL_Scancode)k); if(kcode != SDLK_UNKNOWN) diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index c9df22d..ce68297 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -175,7 +175,7 @@ void Core::onWindowResize(int w, int h) updateWindowDrawSize(w, h); bool reloadRes = false; -#ifndef BBGE_BUILD_SDL2 +#if !SDL_VERSION_ATLEAST(2,0,0) reloadRes = true; // SDL1.2 loses the GL context on resize, so all resources must be reloaded #endif @@ -542,7 +542,7 @@ void Core::init() unsigned sdlflags = SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK; quitNestedMainFlag = false; -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) // Haptic is inited separately, in Jostick.cpp, when a joystick is actually plugged in sdlflags |= SDL_INIT_GAMECONTROLLER; #else @@ -616,7 +616,7 @@ bool Core::getKeyState(int k) void Core::initJoystickLibrary() { -#ifndef BBGE_BUILD_SDL2 +#if !SDL_VERSION_ATLEAST(2,0,0) detectJoysticks(); #endif @@ -736,7 +736,7 @@ void Core::enumerateScreenModesIfNecessary(int display /* = -1 */) { if(display == -1) { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) if(window) display = window->getDisplayIndex(); else @@ -754,7 +754,7 @@ void Core::enumerateScreenModes(int display) _lastEnumeratedDisplayIndex = display; screenModes.clear(); -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) screenModes.push_back(ScreenMode(0, 0, 0)); // "Desktop" screen mode SDL_DisplayMode mode; @@ -1283,7 +1283,7 @@ void Core::onEvent(const SDL_Event& event) } else if (focus) { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) unsigned kidx = event.key.keysym.scancode; #else unsigned kidx = event.key.keysym.sym; @@ -1298,7 +1298,7 @@ void Core::onEvent(const SDL_Event& event) { if (focus) { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) unsigned kidx = event.key.keysym.scancode; #else unsigned kidx = event.key.keysym.sym; @@ -1326,7 +1326,7 @@ void Core::onEvent(const SDL_Event& event) } break; -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) case SDL_MOUSEWHEEL: { diff --git a/BBGE/FmodOpenALBridge.cpp b/BBGE/FmodOpenALBridge.cpp index be79eb8..1e415da 100644 --- a/BBGE/FmodOpenALBridge.cpp +++ b/BBGE/FmodOpenALBridge.cpp @@ -183,7 +183,7 @@ std::list OggDecoder::decoderList; void OggDecoder::startDecoderThread() { stop_thread = false; -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) decoderThread = SDL_CreateThread((int (*)(void *))decode_loop, "OggDecoder", NULL); #else decoderThread = SDL_CreateThread((int (*)(void *))decode_loop, NULL); diff --git a/BBGE/GameKeys.h b/BBGE/GameKeys.h index 45b032f..edd01ba 100644 --- a/BBGE/GameKeys.h +++ b/BBGE/GameKeys.h @@ -1,9 +1,10 @@ #ifndef BBGE_GAME_KEYS_H #define BBGE_GAME_KEYS_H +#include #include "BBGECompileConfig.h" -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) #include @@ -120,7 +121,7 @@ #define KEY_MAXARRAY SDL_NUM_SCANCODES -#else // BBGE_BUILD_SDL2 +#else // begin SDL1 // ------------- SDL 1.2 code path ----------------- @@ -239,6 +240,6 @@ #define KEY_MAXARRAY SDLK_LAST -#endif // BBGE_BUILD_SDL2 +#endif // end SDL1 #endif // BBGE_GAME_KEYS_H diff --git a/BBGE/Joystick.cpp b/BBGE/Joystick.cpp index 373d28c..f68a369 100644 --- a/BBGE/Joystick.cpp +++ b/BBGE/Joystick.cpp @@ -31,13 +31,13 @@ unsigned Joystick::GetNumJoysticks() Joystick::Joystick() { stickIndex = -1; -# ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) sdl_controller = NULL; sdl_haptic = NULL; if(!SDL_WasInit(SDL_INIT_HAPTIC)) if(SDL_InitSubSystem(SDL_INIT_HAPTIC) < 0) debugLog("Failed to init haptic subsystem"); -# endif +#endif sdl_joy = NULL; buttonBitmask = 0; deadZone1 = 0.3f; @@ -61,7 +61,7 @@ Joystick::~Joystick() { shutdown(); -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) if(SDL_WasInit(SDL_INIT_HAPTIC)) SDL_QuitSubSystem(SDL_INIT_HAPTIC); #endif @@ -82,7 +82,7 @@ bool Joystick::init(int stick) stickIndex = stick; numJoyAxes = 0; - #ifdef BBGE_BUILD_SDL2 + #if SDL_VERSION_ATLEAST(2,0,0) if (SDL_IsGameController(stick)) { sdl_controller = SDL_GameControllerOpen(stick); @@ -110,7 +110,7 @@ bool Joystick::init(int stick) if (sdl_joy) { - #ifdef BBGE_BUILD_SDL2 + #if SDL_VERSION_ATLEAST(2,0,0) const char *n = SDL_JoystickName(sdl_joy); name = n ? n : ""; SDL_JoystickGUID jg = SDL_JoystickGetGUID(sdl_joy); @@ -153,7 +153,7 @@ bool Joystick::init(int stick) void Joystick::shutdown() { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) if (sdl_haptic) { SDL_HapticClose(sdl_haptic); @@ -185,7 +185,7 @@ void Joystick::rumble(float leftMotor, float rightMotor, float time) { if (core->joystickEnabled) { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) if (sdl_haptic) { const float power = (leftMotor + rightMotor) / 2.0f; @@ -237,7 +237,7 @@ void Joystick::update(float dt) { if (core->joystickEnabled && sdl_joy && stickIndex != -1) { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) if (!SDL_JoystickGetAttached(sdl_joy)) { debugLog("Lost Joystick"); @@ -284,7 +284,7 @@ void Joystick::update(float dt) buttonBitmask = 0; -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) if (sdl_controller) { for (unsigned i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++) @@ -317,7 +317,7 @@ bool Joystick::anyButton() const unsigned Joystick::getNumAxes() const { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) return sdl_controller ? SDL_CONTROLLER_AXIS_MAX : numJoyAxes; #else return numJoyAxes; @@ -364,7 +364,7 @@ const char *Joystick::getAxisName(unsigned axis) const { if(axis >= numJoyAxes) return NULL; -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) if(sdl_controller) return SDL_GameControllerGetStringForAxis((SDL_GameControllerAxis)axis); #endif @@ -373,7 +373,7 @@ const char *Joystick::getAxisName(unsigned axis) const const char *Joystick::getButtonName(unsigned btn) const { -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) if(sdl_controller) return SDL_GameControllerGetStringForButton((SDL_GameControllerButton)btn); #endif diff --git a/BBGE/Joystick.h b/BBGE/Joystick.h index 3e4bddb..4a9bef4 100644 --- a/BBGE/Joystick.h +++ b/BBGE/Joystick.h @@ -3,8 +3,9 @@ #include #include +#include -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) #include #include #endif @@ -79,10 +80,10 @@ private: std::string name; std::string guid; -# ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) SDL_GameController *sdl_controller; SDL_Haptic *sdl_haptic; -# endif +#endif }; diff --git a/BBGE/OSFunctions.cpp b/BBGE/OSFunctions.cpp index cc5b637..c5721ad 100644 --- a/BBGE/OSFunctions.cpp +++ b/BBGE/OSFunctions.cpp @@ -66,7 +66,7 @@ void initIcon(void *screen) SDL_SysWMinfo wminfo; SDL_VERSION(&wminfo.version) -#ifdef BBGE_BUILD_SDL2 +#if SDL_VERSION_ATLEAST(2,0,0) SDL_GetWindowWMInfo((SDL_Window*)screen, &wminfo); HWND hwnd = wminfo.info.win.window; #else diff --git a/win/vc90/Aquaria.vcproj b/win/vc90/Aquaria.vcproj index 1b96696..358f75c 100644 --- a/win/vc90/Aquaria.vcproj +++ b/win/vc90/Aquaria.vcproj @@ -43,7 +43,7 @@ AdditionalOptions="/MP" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\glpng";"$(SolutionDir)\..\ExternalLibs\libogg\include";"$(SolutionDir)\..\ExternalLibs\libvorbis\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\BBGE";"$(SolutionDir)\..\ExternalLibs\lua-5.1.4\src";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\tinyxml2";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" MinimalRebuild="false" BasicRuntimeChecks="0" RuntimeLibrary="3" @@ -126,7 +126,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\glpng";"$(SolutionDir)\..\ExternalLibs\libogg\include";"$(SolutionDir)\..\ExternalLibs\libvorbis\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\BBGE";"$(SolutionDir)\..\ExternalLibs\lua-5.1.4\src";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\tinyxml2";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;NDEBUG;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2" + PreprocessorDefinitions="WIN32;NDEBUG;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;BBGE_BUILD_VFS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" StringPooling="true" ExceptionHandling="0" RuntimeLibrary="0" diff --git a/win/vc90/BBGE.vcproj b/win/vc90/BBGE.vcproj index c0c88fd..87cf036 100644 --- a/win/vc90/BBGE.vcproj +++ b/win/vc90/BBGE.vcproj @@ -44,7 +44,7 @@ AdditionalOptions="/MP" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\glpng";"$(SolutionDir)\..\BBGE";"$(SolutionDir)\..\ExternalLibs\zlib";"$(SolutionDir)\..\ExternalLibs\png";"$(SolutionDir)\..\ExternalLibs\libogg\include";"$(SolutionDir)\..\ExternalLibs\libvorbis\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\ExternalLibs\tinyxml2";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" MinimalRebuild="false" BasicRuntimeChecks="0" RuntimeLibrary="3" @@ -117,7 +117,7 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\glpng";"$(SolutionDir)\..\BBGE";"$(SolutionDir)\..\ExternalLibs\zlib";"$(SolutionDir)\..\ExternalLibs\png";"$(SolutionDir)\..\ExternalLibs\libogg\include";"$(SolutionDir)\..\ExternalLibs\libvorbis\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\ExternalLibs\tinyxml2";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs"" - PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1" StringPooling="true" ExceptionHandling="0" RuntimeLibrary="0"