From 25eaa06826f5df55021ea4809f5971aba634dabc Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 19 May 2020 01:33:42 +0200 Subject: [PATCH] Fixed Macros, Fixed Post-Build action --- SDLU/Util.hpp | 8 ++------ SDLU/graphics/RenderWindow.cpp | 12 ++++++------ SDLU_Example/CMakeLists.txt | 15 ++++----------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/SDLU/Util.hpp b/SDLU/Util.hpp index 35732da..eba6604 100644 --- a/SDLU/Util.hpp +++ b/SDLU/Util.hpp @@ -9,12 +9,8 @@ #define IS_NULLPTR( x ) (x == nullptr) -// TODO: Find fix for this, the original doesnt compile under gcc -#define RETURN_IF_NULLPTR( x ) { if(IS_NULLPTR(x)) return; } -#define RETURN_IF_NOT_NULLPTR( x ) { if(!IS_NULLPTR(x)) return; } - -#define RETURN_IF_NULLPTR_ARG( x, v ) { if(IS_NULLPTR(x)) return v; } -#define RETURN_IF_NOT_NULLPTR_ARG( x, v ) { if(!IS_NULLPTR(x)) return v; } +#define RETURN_IF_NULLPTR( x, ... ) { if(IS_NULLPTR(x)) return __VA_ARGS__; } +#define RETURN_IF_NOT_NULLPTR( x, ... ) { if(!IS_NULLPTR(x)) return __VA_ARGS__; } typedef uint8_t Uint8; typedef int8_t Int8; diff --git a/SDLU/graphics/RenderWindow.cpp b/SDLU/graphics/RenderWindow.cpp index eddedb6..9393333 100644 --- a/SDLU/graphics/RenderWindow.cpp +++ b/SDLU/graphics/RenderWindow.cpp @@ -63,13 +63,13 @@ namespace sdlu bool RenderWindow::IsOpen() { - RETURN_IF_NULLPTR_ARG(m_pWindow, false); + RETURN_IF_NULLPTR(m_pWindow, false); return (!SDL_GetWindowID(m_pWindow) ? false : true); } bool RenderWindow::PollEvent(SDL_Event* event) { - RETURN_IF_NULLPTR_ARG(m_pWindow, false); + RETURN_IF_NULLPTR(m_pWindow, false); // Handle events before the user in case a derived // class decides to block the event. while (SDL_PollEvent(event)) @@ -93,7 +93,7 @@ namespace sdlu Vector2i RenderWindow::GetPosition() { - RETURN_IF_NULLPTR_ARG(m_pWindow, Vector2i()); + RETURN_IF_NULLPTR(m_pWindow, Vector2i()); int x = 0, y = 0; SDL_GetWindowPosition(m_pWindow, &x, &y); @@ -116,7 +116,7 @@ namespace sdlu Vector2u RenderWindow::GetSize() { - RETURN_IF_NULLPTR_ARG(m_pWindow, Vector2u()); + RETURN_IF_NULLPTR(m_pWindow, Vector2u()); int x = 0, y = 0; SDL_GetWindowSize(m_pWindow, &x, &y); @@ -139,7 +139,7 @@ namespace sdlu std::string RenderWindow::GetTitle() { - RETURN_IF_NULLPTR_ARG(m_pWindow, ""); + RETURN_IF_NULLPTR(m_pWindow, ""); return SDL_GetWindowTitle(m_pWindow); } @@ -182,7 +182,7 @@ namespace sdlu if (diff < 1000 / m_oFramerate) { - SDL_Delay(1000 / m_oFramerate - diff); + SDL_Delay(static_cast(1000 / m_oFramerate - diff)); } } diff --git a/SDLU_Example/CMakeLists.txt b/SDLU_Example/CMakeLists.txt index 68b7e9d..a27877a 100644 --- a/SDLU_Example/CMakeLists.txt +++ b/SDLU_Example/CMakeLists.txt @@ -15,14 +15,7 @@ target_link_libraries(${PNAME} SDL2main ) -if(WIN32) - add_custom_command(TARGET ${PNAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $/SDL2d.dll $ - ) -else() - add_custom_command(TARGET ${PNAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $/libSDL2-2.0.so $ - ) -endif() \ No newline at end of file +add_custom_command(TARGET ${PNAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ +) \ No newline at end of file