summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-01-29 16:35:58 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2011-01-29 16:35:58 +0100
commit1737d135e358f4f5c4be1e2895d8f0ad667dec3c (patch)
tree89793d9696516bac2b924346d367077e578d08ef
parentfab20efb604948d2b61de319f60bffe9f0b8592c (diff)
Added fullscreen switch.
-rw-r--r--application.cpp12
-rw-r--r--application.h3
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();