diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..787b137 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Ignore files generated by cmake +CMakeCache.txt +CMakeFiles/ +Makefile +cmake_install.cmake +libSDL2pp.so diff --git a/SDL2pp/Exception.cc b/SDL2pp/Exception.cc index 18cf4d4..b5d2cb0 100644 --- a/SDL2pp/Exception.cc +++ b/SDL2pp/Exception.cc @@ -28,6 +28,9 @@ namespace SDL2pp { Exception::Exception(const char* what) : what_(what), sdl_error_(SDL_GetError()) { } +Exception::~Exception() noexcept { +} + const char* Exception::what() const noexcept { return what_; } diff --git a/SDL2pp/Exception.hh b/SDL2pp/Exception.hh index 4f46890..d4ffc8e 100644 --- a/SDL2pp/Exception.hh +++ b/SDL2pp/Exception.hh @@ -33,6 +33,7 @@ private: public: Exception(const char* what = ""); + virtual ~Exception() noexcept; const char* what() const noexcept; const char* GetSDLError() const noexcept; }; diff --git a/SDL2pp/Point.hh b/SDL2pp/Point.hh index 29b932c..eebce42 100644 --- a/SDL2pp/Point.hh +++ b/SDL2pp/Point.hh @@ -45,7 +45,7 @@ private: public: Point(int x, int y); - ~Point(); + virtual ~Point(); static Point Null(); diff --git a/SDL2pp/Rect.hh b/SDL2pp/Rect.hh index 262d719..2a28f25 100644 --- a/SDL2pp/Rect.hh +++ b/SDL2pp/Rect.hh @@ -37,7 +37,7 @@ private: public: Rect(int x, int y, int w, int h); - ~Rect(); + virtual ~Rect(); static Rect Null(); diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index c9612ad..312598b 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -170,7 +170,7 @@ void Renderer::DrawRects(const Rect* rects, int count) { void Renderer::FillRect(int x1, int y1, int x2, int y2) { SDL_Rect rect = {x1, y1, x2 - x1 + 1, y2 - y1 + 1}; - if (SDL_RenderDrawRect(renderer_, &rect) != 0) + if (SDL_RenderFillRect(renderer_, &rect) != 0) throw Exception("SDL_RenderFillRect failed"); } @@ -183,7 +183,7 @@ void Renderer::FillRect(const Point& p1, const Point& p2) { void Renderer::FillRect(const Rect& r) { if (r.IsNull()) return; - if (SDL_RenderDrawRect(renderer_, r.Get()) != 0) + if (SDL_RenderFillRect(renderer_, r.Get()) != 0) throw Exception("SDL_RenderFillRect failed"); } diff --git a/SDL2pp/Renderer.hh b/SDL2pp/Renderer.hh index 430caa2..ab4a8f8 100644 --- a/SDL2pp/Renderer.hh +++ b/SDL2pp/Renderer.hh @@ -42,7 +42,7 @@ private: public: Renderer(Window& window, int index, Uint32 flags); - ~Renderer(); + virtual ~Renderer(); Renderer(const Renderer& other) = delete; Renderer(Renderer&& other) = delete; diff --git a/SDL2pp/SDL.hh b/SDL2pp/SDL.hh index f923da8..cb5edb0 100644 --- a/SDL2pp/SDL.hh +++ b/SDL2pp/SDL.hh @@ -29,7 +29,7 @@ namespace SDL2pp { class SDL { public: SDL(Uint32 flags); - ~SDL(); + virtual ~SDL(); SDL(const SDL& other) = delete; SDL(SDL&& other) = delete; diff --git a/SDL2pp/Texture.hh b/SDL2pp/Texture.hh index af55895..905e036 100644 --- a/SDL2pp/Texture.hh +++ b/SDL2pp/Texture.hh @@ -38,7 +38,7 @@ private: public: Texture(Renderer& renderer, Uint32 format, int access, int w, int h); - ~Texture(); + virtual ~Texture(); Texture(const Texture& other) = delete; Texture(Texture&& other) = delete; diff --git a/SDL2pp/Window.hh b/SDL2pp/Window.hh index afda315..86ee456 100644 --- a/SDL2pp/Window.hh +++ b/SDL2pp/Window.hh @@ -34,7 +34,7 @@ private: public: Window(const char* title, int x, int y, int w, int h, Uint32 flags); - ~Window(); + virtual ~Window(); Window(const Window& other) = delete; Window(Window&& other) = delete;