diff options
-rw-r--r-- | application.cpp | 12 | ||||
-rw-r--r-- | application.h | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/application.cpp b/application.cpp index 47049c9..1ab1333 100644 --- a/application.cpp +++ b/application.cpp @@ -15,9 +15,14 @@ Application::~Application() { } +void Application::create_window(unsigned int w, unsigned int h, bool fs) { + window->Create(sf::VideoMode(w, h, 32), "Foo", sf::Style::Resize | sf::Style::Close | (fs ? sf::Style::Fullscreen : 0)); +} + void Application::init_window(unsigned int w, unsigned int h, bool fs) { - renderwindow = new sf::RenderWindow(sf::VideoMode(w, h, 32), "Foo"); + renderwindow = new sf::RenderWindow(); window = renderwindow; + create_window(w, h, fs); window->UseVerticalSync(true); @@ -67,6 +72,11 @@ void Application::event_keypress(sf::Key::Code key) { case sf::Key::Escape: quit(); break; + case sf::Key::F: + fullscreen = !fullscreen; + create_window(1024, 768, fullscreen); + init(); + break; default: break; } diff --git a/application.h b/application.h index 1b0d099..74a2633 100644 --- a/application.h +++ b/application.h @@ -8,13 +8,16 @@ class Application { private: sf::Window* window; bool please_quit; + bool fullscreen; protected: + void create_window(unsigned int w, unsigned int h, bool fs = false); void init_window(unsigned int w, unsigned int h, bool fs = false); virtual void event(const sf::Event& e); virtual void event_keypress(Key::Code key); + virtual void init() = 0; virtual void update() = 0; void swap(); |