diff options
-rw-r--r-- | debug.hpp | 107 | ||||
-rw-r--r-- | include/video.hpp | 7 | ||||
-rw-r--r-- | include/wrapsdl2.hpp | 4 | ||||
-rw-r--r-- | video.cpp | 12 |
4 files changed, 63 insertions, 67 deletions
@@ -4,72 +4,71 @@ #include <sstream> #ifdef DEBUG - #ifdef __builtin_strrchr - #define __FILENAME__ (\ - __builtin_strrchr(__FILE__, '/') ? \ - __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) + #define __FILENAME__ (\ + __builtin_strrchr(__FILE__, '/') ? \ + __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) - #define npdebug_fname(); { \ - std::cerr << "[" << __FILENAME__ << ":" << __LINE__ << "] "; \ - } + #define npdebug_prep(); { \ + std::cerr << "[" << __FILENAME__ \ + << ":" << __LINE__ \ + << ", " << __func__ \ + << "] " ; \ + } - #define npdebug(...); { \ - npdebug_fname(); \ - np::va_debug(__VA_ARGS__); \ - } - #else - #define npdebug(...); np::va_debug(__VA_ARGS__); - #endif + #define npdebug(...); { \ + npdebug_prep(); \ + np::va_debug(__VA_ARGS__); \ + } - namespace np { - template<typename... Args> - inline void va_debug(Args&... args) { - (std::cerr << ... << args) << std::endl; - } + namespace np { + template<typename... Args> + inline void va_debug(Args&... args) { + (std::cerr << ... << args) << std::endl; + } - template<typename T> - void range_debug(const T& t) { - range_debug("", t); - } + template<typename T> + void range_debug(const T& t) { + range_debug("", t); + } - template<typename T> - void range_debug(const std::string& msg, const T& t) { - std::string out; - for (auto elem : t) - out += elem += ", "; + template<typename T> + void range_debug(const std::string& msg, const T& t) { + std::string out; + for (auto elem : t) + out += elem += ", "; - npdebug(msg, out); - } + npdebug(msg, out); + } - template<typename T> - T inspect(const T& t) { - npdebug(t); - return t; - } + template<typename T> + T inspect(const T& t) { + npdebug(t); + return t; + } - template<typename T> - T inspect(const std::string& msg, const T& t) { - npdebug(msg, t); - return t; - } - } + template<typename T> + T inspect(const std::string& msg, const T& t) { + npdebug(msg, t); + return t; + } + } #else - #define npdebug(...) {} + #define npdebug(...) {} - namespace np { - template<typename... Args> - inline void va_debug(Args&... args) {} + namespace np { + template<typename... Args> + inline void va_debug(Args&... args) {} - template<typename T> - inline void range_debug(const T& t) {} + template<typename T> + inline void range_debug(const T& t) {} - template<typename T> - inline void range_debug(const std::string& msg, const T& t) {} + template<typename T> + inline void range_debug(const std::string& msg, const T& t) {} - template<typename T> - T inspect(const T& t) { return t; } + template<typename T> + T inspect(const T& t) { return t; } - template<typename T> - T inspect(const std::string& msg, const T& t) { return t; } - } + template<typename T> + T inspect(const std::string& msg, const T& t) { return t; } + } #endif diff --git a/include/video.hpp b/include/video.hpp index 3c2a238..2749d11 100644 --- a/include/video.hpp +++ b/include/video.hpp @@ -24,10 +24,9 @@ namespace wrapsdl2 { void open(); void close(); - - void show(); - void hide(); - void raise(); + inline void show() { SDL_ShowWindow(m_window); } + inline void hide() { SDL_HideWindow(m_window); } + inline void raise() { SDL_RaiseWindow(m_window); } // getters bool is_open(); diff --git a/include/wrapsdl2.hpp b/include/wrapsdl2.hpp index 847ed99..2f28890 100644 --- a/include/wrapsdl2.hpp +++ b/include/wrapsdl2.hpp @@ -9,11 +9,11 @@ namespace wrapsdl2 { void quit(void); namespace util { - constexpr bool sdl_bool(SDL_bool b) { + constexpr inline bool sdl_bool(SDL_bool b) { return b == SDL_TRUE; } - constexpr SDL_bool sdl_bool(bool b) { + constexpr inline SDL_bool sdl_bool(bool b) { return (b) ? SDL_TRUE : SDL_FALSE; } } @@ -39,9 +39,13 @@ window::window(const std::string& title, std::size_t width, std::size_t height) window::~window() { if (m_renderer != NULL) SDL_DestroyRenderer(m_renderer); + else + npdebug("warning: m_renderer is NULL") if (m_window != NULL) SDL_DestroyWindow(m_window); + else + npdebug("warning: m_window is NULL") } @@ -55,18 +59,12 @@ void window::close() { m_open = false; } -void window::show() { SDL_ShowWindow(m_window); } -void window::hide() { SDL_HideWindow(m_window); } -void window::raise() { SDL_RaiseWindow(m_window); } - bool window::is_open() { return m_open; } bool window::is_visible() { - std::uint32_t flags = SDL_GetWindowFlags(m_window); - - return flags & SDL_WINDOW_SHOWN; + return SDL_WINDOW_SHOWN & SDL_GetWindowFlags(m_window); } void window::update() { |