diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-01-29 16:35:58 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-01-29 16:35:58 +0100 |
commit | 1737d135e358f4f5c4be1e2895d8f0ad667dec3c (patch) | |
tree | 89793d9696516bac2b924346d367077e578d08ef | |
parent | fab20efb604948d2b61de319f60bffe9f0b8592c (diff) |
Added fullscreen switch.
-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(); |