diff --git a/SDL2pp/Window.cc b/SDL2pp/Window.cc index 6ddf9f3..ce9f064 100644 --- a/SDL2pp/Window.cc +++ b/SDL2pp/Window.cc @@ -26,8 +26,8 @@ namespace SDL2pp { -Window::Window(const char* title, int x, int y, int w, int h, Uint32 flags) { - if ((window_ = SDL_CreateWindow(title, x, y, w, h, flags)) == nullptr) +Window::Window(const std::string& title, int x, int y, int w, int h, Uint32 flags) { + if ((window_ = SDL_CreateWindow(title.c_str(), x, y, w, h, flags)) == nullptr) throw Exception("SDL_CreateWindow failed"); } @@ -64,6 +64,10 @@ int Window::GetHeight() const { return h; } +void Window::SetTitle(const std::string& title) { + SDL_SetWindowTitle(window_, title.c_str()); +} + SDL_Window* Window::Get() const { return window_; } diff --git a/SDL2pp/Window.hh b/SDL2pp/Window.hh index e46de2e..5ceb894 100644 --- a/SDL2pp/Window.hh +++ b/SDL2pp/Window.hh @@ -22,6 +22,8 @@ #ifndef SDL2PP_WINDOW_HH #define SDL2PP_WINDOW_HH +#include + #include #include @@ -35,7 +37,7 @@ private: SDL_Window* window_; public: - Window(const char* title, int x, int y, int w, int h, Uint32 flags); + Window(const std::string& title, int x, int y, int w, int h, Uint32 flags); virtual ~Window(); Window(const Window& other) = delete; @@ -47,6 +49,8 @@ public: int GetWidth() const; int GetHeight() const; + void SetTitle(const std::string& title); + SDL_Window* Get() const; };