From 780878cad348c09c335af331fc3cd6c67ab5df87 Mon Sep 17 00:00:00 2001 From: Mia <81255505+Nils75owo@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:44:44 +0100 Subject: [PATCH] removed PLATFORM_SDL (#69) PLATFORM_SDL was hardcoded and the rest of the old DX8 code was removed long time ago. --- Hurrican/CMakeLists.txt | 1 - Hurrican/src/Console.cpp | 12 ------------ Hurrican/src/DX8Font.cpp | 2 -- Hurrican/src/DX8Graphics.cpp | 11 ++--------- Hurrican/src/DX8Graphics.hpp | 25 ++++++++----------------- Hurrican/src/DX8Input.hpp | 16 ++++++---------- Hurrican/src/DX8Joystick.hpp | 5 ++--- Hurrican/src/DX8Sprite.cpp | 2 -- Hurrican/src/DX8Texture.cpp | 7 +------ Hurrican/src/GegnerClass.hpp | 4 ---- Hurrican/src/Main.hpp | 6 ++---- Hurrican/src/Makefile | 2 +- Hurrican/src/Mathematics.hpp | 3 +-- Hurrican/src/SDLPort/texture.hpp | 1 + 14 files changed, 24 insertions(+), 73 deletions(-) diff --git a/Hurrican/CMakeLists.txt b/Hurrican/CMakeLists.txt index b28088c1..fdfbeacd 100644 --- a/Hurrican/CMakeLists.txt +++ b/Hurrican/CMakeLists.txt @@ -478,7 +478,6 @@ IF(FBO) ) ENDIF(FBO) -add_definitions(-DPLATFORM_SDL) add_definitions(-DENABLE_CONSOLE_COMMANDS) # make optional? OPTION(DISABLE_EXCEPTIONS "Disable exception handling to reduce binary size" OFF) diff --git a/Hurrican/src/Console.cpp b/Hurrican/src/Console.cpp index 5fa22836..e7a1c569 100644 --- a/Hurrican/src/Console.cpp +++ b/Hurrican/src/Console.cpp @@ -822,13 +822,7 @@ int ConsoleClass::GetIntFromBuffer(int index) { inline bool ConsoleClass::CONSOLE_COMMAND(const char* command) { #if defined(ENABLE_CONSOLE_COMMANDS) - -# if defined(PLATFORM_SDL) return strcmp(Buffer, command) == 0; -# else - return strcmp(_strlwr_s(Buffer), command) == 0; -# endif - #else return false; #endif @@ -836,13 +830,7 @@ inline bool ConsoleClass::CONSOLE_COMMAND(const char* command) { inline bool ConsoleClass::CONSOLE_COMMAND_ARG(const char* command, int len) { #if defined(ENABLE_CONSOLE_COMMANDS) - -# if defined(PLATFORM_SDL) return strncmp(Buffer, command, len) == 0; -# else - return strncmp(_strlwr_s(Buffer), command, len) == 0; -# endif - #else return false; #endif diff --git a/Hurrican/src/DX8Font.cpp b/Hurrican/src/DX8Font.cpp index 19952d2a..d2656a51 100644 --- a/Hurrican/src/DX8Font.cpp +++ b/Hurrican/src/DX8Font.cpp @@ -19,9 +19,7 @@ #include "Globals.hpp" #include "Logdatei.hpp" #include "Timer.hpp" -#if defined(PLATFORM_SDL) #include "SDLPort/texture.hpp" -#endif // PLATFORM_SDL #include "DX8Font.hpp" #include "DX8Graphics.hpp" #include "Gameplay.hpp" diff --git a/Hurrican/src/DX8Graphics.cpp b/Hurrican/src/DX8Graphics.cpp index 8538ef02..b3dcfd45 100644 --- a/Hurrican/src/DX8Graphics.cpp +++ b/Hurrican/src/DX8Graphics.cpp @@ -478,7 +478,7 @@ bool DirectGraphicsClass::SetDeviceInfo() { bool DirectGraphicsClass::TakeScreenshot(const char Filename[100], int screenx, int screeny) { -#if defined(PLATFORM_SDL) && SDL_VERSION_ATLEAST(2, 0, 0) +#if SDL_VERSION_ATLEAST(2, 0, 0) SDL_Surface *image = SDL_CreateRGBSurface(SDL_SWSURFACE, screenx, screeny, 24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0); glReadPixels(0, 0, screenx, screeny, GL_RGB, GL_UNSIGNED_BYTE, image->pixels); FlipSurface(image); @@ -664,7 +664,6 @@ void DirectGraphicsClass::DisplayBuffer() { ShowBackBuffer(); } -#if defined(PLATFORM_SDL) bool DirectGraphicsClass::ExtensionSupported(const char *ext) { if (strstr(glextensions, ext) != nullptr) { Protokoll << ext << " is supported" << std::endl; @@ -674,11 +673,9 @@ bool DirectGraphicsClass::ExtensionSupported(const char *ext) { Protokoll << ext << " is not supported" << std::endl; return false; } -#endif // DKS - Supports new TexturesystemClass and is now used for both GL and DirectX #if 0 -#if defined(PLATFORM_SDL) void DirectGraphicsClass::SetTexture( int32_t index ) { if (index >= 0) @@ -715,7 +712,6 @@ void DirectGraphicsClass::SetTexture( int32_t index ) #endif } } -#endif #endif // 0 void DirectGraphicsClass::SetTexture(int idx) { if (idx >= 0) { @@ -832,7 +828,6 @@ void DirectGraphicsClass::ShowBackBuffer() { #endif } -#if defined(PLATFORM_SDL) void DirectGraphicsClass::SetupFramebuffers() { /* Read the current window size */ #if SDL_VERSION_ATLEAST(2, 0, 0) @@ -1001,7 +996,7 @@ void DirectGraphicsClass::DrawCircle(uint16_t x, uint16_t y, uint16_t radius) { // Takes a SDL surface and flips it vertically // -------------------------------------------------------------------------------------- -#if defined(PLATFORM_SDL) && SDL_VERSION_ATLEAST(2, 0, 0) +#if SDL_VERSION_ATLEAST(2, 0, 0) void DirectGraphicsClass::FlipSurface(SDL_Surface* surface) { SDL_LockSurface(surface); @@ -1025,5 +1020,3 @@ void DirectGraphicsClass::FlipSurface(SDL_Surface* surface) { SDL_UnlockSurface(surface); } #endif - -#endif /* PLATFORM_SDL */ diff --git a/Hurrican/src/DX8Graphics.hpp b/Hurrican/src/DX8Graphics.hpp index 559b1cfb..0d0ed4b3 100644 --- a/Hurrican/src/DX8Graphics.hpp +++ b/Hurrican/src/DX8Graphics.hpp @@ -17,20 +17,13 @@ // Include Dateien // -------------------------------------------------------------------------------------- -#if defined(PLATFORM_SDL) -# include "SDL_port.hpp" -# if defined(USE_GL2) || defined(USE_GL3) -# include "cshader.hpp" -# if defined(USE_FBO) -# include "cfbo.hpp" -# endif /* USE_FBO */ -# endif /* USE_GL2 || USE_GL3 */ -#else -# include -# include -# include -# include -#endif +#include "SDL_port.hpp" +#if defined(USE_GL2) || defined(USE_GL3) +# include "cshader.hpp" +# if defined(USE_FBO) +# include "cfbo.hpp" +# endif /* USE_FBO */ +#endif /* USE_GL2 || USE_GL3 */ // -------------------------------------------------------------------------------------- // Defines @@ -133,7 +126,6 @@ class DirectGraphicsClass { void DisplayBuffer(); // Render den Buffer auf den Backbuffer // DKS - SetTexture is now used for both GL and DirectX, and uses new TexturesystemClass: void SetTexture(int idx); -#if defined(PLATFORM_SDL) bool ExtensionSupported(const char *ext); void SetupFramebuffers(); void ClearBackBuffer(); @@ -143,7 +135,6 @@ class DirectGraphicsClass { void DrawTouchOverlay(); void DrawCircle(uint16_t x, uint16_t y, uint16_t radius); #endif -#endif #endif inline BlendModeEnum GetBlendMode() const { return BlendMode; } @@ -154,7 +145,7 @@ class DirectGraphicsClass { inline SDL_Rect GetWindowView() const {return WindowView); } #endif -#if defined(PLATFORM_SDL) && SDL_VERSION_ATLEAST(2, 0, 0) +#if SDL_VERSION_ATLEAST(2, 0, 0) void FlipSurface(SDL_Surface* surface); #endif }; diff --git a/Hurrican/src/DX8Input.hpp b/Hurrican/src/DX8Input.hpp index 19c64096..664847f5 100644 --- a/Hurrican/src/DX8Input.hpp +++ b/Hurrican/src/DX8Input.hpp @@ -31,14 +31,12 @@ constexpr int MAX_MOUSEBUTTONS = 4; constexpr int DINPUT_BUFFERSIZE = 32; constexpr int MAX_KEYS = 256; -#if defined(PLATFORM_SDL) -# if SDL_VERSION_ATLEAST(2, 0, 0) -# define KeyDown(Taste) (TastaturPuffer[SDL_GetScancodeFromKey(Taste)] > 0) -# define KeyCode(Taste) (SDL_GetKeyFromScancode(static_cast(i))) -# else -# define KeyDown(Taste) (TastaturPuffer[Taste] > 0) -# define KeyCode(Taste) (Taste) -# endif +#if SDL_VERSION_ATLEAST(2, 0, 0) +# define KeyDown(Taste) (TastaturPuffer[SDL_GetScancodeFromKey(Taste)] > 0) +# define KeyCode(Taste) (SDL_GetKeyFromScancode(static_cast(i))) +#else +# define KeyDown(Taste) (TastaturPuffer[Taste] > 0) +# define KeyCode(Taste) (Taste) #endif // ForceFeedback Effekte @@ -138,9 +136,7 @@ class DirectInputClass { // -------------------------------------------------------------------------------------- extern DirectInputClass DirectInput; -#if defined(PLATFORM_SDL) extern const Uint8 *TastaturPuffer; -#endif extern bool UseForceFeedback; // ForceFeedback Fähigkeit nutzen ? #endif diff --git a/Hurrican/src/DX8Joystick.hpp b/Hurrican/src/DX8Joystick.hpp index 9b842023..33125639 100644 --- a/Hurrican/src/DX8Joystick.hpp +++ b/Hurrican/src/DX8Joystick.hpp @@ -20,9 +20,8 @@ constexpr int MAX_JOYSTICKBUTTONS = 128; // -------------------------------------------------------------------------------------- // Include Dateien // -------------------------------------------------------------------------------------- -#if defined(PLATFORM_SDL) -# include "SDL_port.hpp" -#endif + +#include "SDL_port.hpp" #include #include diff --git a/Hurrican/src/DX8Sprite.cpp b/Hurrican/src/DX8Sprite.cpp index a1c1584e..5dc3aef0 100644 --- a/Hurrican/src/DX8Sprite.cpp +++ b/Hurrican/src/DX8Sprite.cpp @@ -85,11 +85,9 @@ bool DirectGraphicsSprite::LoadImage(const char *Filename, int xs, int ys, int x #if defined(USE_PVRTC) || defined(USE_ETC1) char compresstex[256]; #endif -#if defined(PLATFORM_SDL) ()hresult; SDL_Rect dims; -#endif // zuerst eine evtl benutzte Textur freigeben delete_texture( itsTexture ); diff --git a/Hurrican/src/DX8Texture.cpp b/Hurrican/src/DX8Texture.cpp index 5a6a743d..8efd5da4 100644 --- a/Hurrican/src/DX8Texture.cpp +++ b/Hurrican/src/DX8Texture.cpp @@ -4,16 +4,11 @@ // abstracts away the details like the alpha textures needed by ETC1 compression. // It also unifies the interface that was once different between DX8 and SDL. -#if defined(PLATFORM_SDL) #include "SDLPort/SDL_port.hpp" -#endif +#include "SDLPort/texture.hpp" #include "DX8Texture.hpp" -#if defined(PLATFORM_SDL) -#include "SDLPort/texture.hpp" -#endif - #include "Gameplay.hpp" #include "Main.hpp" diff --git a/Hurrican/src/GegnerClass.hpp b/Hurrican/src/GegnerClass.hpp index b4cb1f88..bb575649 100644 --- a/Hurrican/src/GegnerClass.hpp +++ b/Hurrican/src/GegnerClass.hpp @@ -15,11 +15,7 @@ // Include Dateien // -------------------------------------------------------------------------------------- -#if defined(PLATFORM_SDL) #include "SDL_port.hpp" -#else -#include -#endif #include "DX8Sprite.hpp" #include diff --git a/Hurrican/src/Main.hpp b/Hurrican/src/Main.hpp index 8aa11fcd..8a989171 100644 --- a/Hurrican/src/Main.hpp +++ b/Hurrican/src/Main.hpp @@ -37,11 +37,9 @@ struct sCommandLineParams { char Params[256]; char *DataPath; char *SavePath; -#if defined(PLATFORM_SDL) uint16_t TexFactor; uint16_t TexSizeMin; bool AllowNPotTextureSizes; -#endif bool ShowFPS; bool VSync; uint8_t ScreenDepth; @@ -111,7 +109,7 @@ void ShowFPS(); // We will Swap values only for Big_Endian, Little_Endian should be unchanged // -------------------------------------------------------------------------------------- static inline uint32_t FixEndian(uint32_t x) { -#if defined(PLATFORM_SDL) && (SDL_BYTEORDER == SDL_BIG_ENDIAN) +#if SDL_BYTEORDER == SDL_BIG_ENDIAN return SDL_Swap32(x); #else return x; @@ -119,7 +117,7 @@ static inline uint32_t FixEndian(uint32_t x) { } static inline int32_t FixEndian(int32_t x) { -#if defined(PLATFORM_SDL) && (SDL_BYTEORDER == SDL_BIG_ENDIAN) +#if SDL_BYTEORDER == SDL_BIG_ENDIAN uint32_t val = SDL_Swap32(*reinterpret_cast(&x)); return *reinterpret_cast(&val); #else diff --git a/Hurrican/src/Makefile b/Hurrican/src/Makefile index 6e0c2088..41f9d796 100644 --- a/Hurrican/src/Makefile +++ b/Hurrican/src/Makefile @@ -18,7 +18,7 @@ TARGET := linux_GL1 endif -DEFINES := -DPLATFORM_SDL -DENABLE_CONSOLE_COMMANDS -DUSE_MODPLUG +DEFINES := -DENABLE_CONSOLE_COMMANDS -DUSE_MODPLUG ##################################### ####### *** OPTIONAL DEFINES: *** # diff --git a/Hurrican/src/Mathematics.hpp b/Hurrican/src/Mathematics.hpp index 0b4a654b..c17f1996 100644 --- a/Hurrican/src/Mathematics.hpp +++ b/Hurrican/src/Mathematics.hpp @@ -14,9 +14,8 @@ #define _MATHEMATICS_HPP_ #include #include -#ifdef PLATFORM_SDL + #include "SDLPort/SDL_port.hpp" -#endif // -------------------------------------------------------------------------------------- // Defines diff --git a/Hurrican/src/SDLPort/texture.hpp b/Hurrican/src/SDLPort/texture.hpp index d16cbdd3..7776c6ad 100644 --- a/Hurrican/src/SDLPort/texture.hpp +++ b/Hurrican/src/SDLPort/texture.hpp @@ -26,6 +26,7 @@ #define _TEXTURE_H_ #include +#include "DX8Texture.hpp" #include "SDL_port.hpp" struct image_t {