From f3770d1c895ee5f5e3f86831b6113cd51168e50f Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 2 Nov 2012 23:07:05 -0400 Subject: [PATCH] change Window to RenderWindow --- src/client/Client-gl.cc | 2 +- src/client/Client.cc | 33 +++++++++++++++++++++++++++++++++ src/client/Client.h | 4 ++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/client/Client-gl.cc b/src/client/Client-gl.cc index 9caabb9..cd282c0 100644 --- a/src/client/Client-gl.cc +++ b/src/client/Client-gl.cc @@ -73,7 +73,7 @@ bool Client::create_window(bool fullscreen, int width, int height) : sf::Style::Resize | sf::Style::Close; sf::ContextSettings cs = sf::ContextSettings(0, 0, 0, OPENGL_CONTEXT_MAJOR, OPENGL_CONTEXT_MINOR); - m_window = new sf::Window(mode, "Treacherous Terrain", style, cs); + m_window = new sf::RenderWindow(mode, "Treacherous Terrain", style, cs); m_window->setMouseCursorVisible(false); grab_mouse(true); if (!initgl()) diff --git a/src/client/Client.cc b/src/client/Client.cc index 0f06686..8d364e9 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -1,6 +1,7 @@ #include #include "Client.h" #include "Types.h" +#include /* TODO: this should be moved to common somewhere */ #define MAX_SHOT_DISTANCE 250.0 @@ -93,6 +94,37 @@ void Client::run(bool fullscreen, int width, int height, std::string pname) m_clock.restart(); recenter_cursor(); +#if 0 + sfg::SFGUI sfgui; + sfg::Label::Ptr label = sfg::Label::Create("Label Test"); + sfg::Window::Ptr window(sfg::Window::Create()); + window->SetTitle("SFGUI window"); + window->Add(label); + sfg::Desktop desktop; + desktop.Add(window); + + sf::Event event; + + while (m_window->isOpen()) + { + while (m_window->pollEvent(event)) + { + desktop.HandleEvent(event); + + if (event.type == sf::Event::Closed) + { + m_window->close(); + } + } + + desktop.Update(m_clock.restart().asSeconds()); + m_window->clear(); + sfgui.Display(*m_window); + m_window->display(); + } +#endif + +//#if 0 double last_time = 0.0; while (m_window->isOpen()) { @@ -168,6 +200,7 @@ void Client::run(bool fullscreen, int width, int height, std::string pname) // temporary for now. otherwise this thread consumed way too processing sf::sleep(sf::seconds(0.005)); // 5 milli-seconds } +//#endif } void Client::recenter_cursor() diff --git a/src/client/Client.h b/src/client/Client.h index 4b77503..d983e6b 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "refptr.h" #include "Map.h" #include "Shot.h" @@ -46,7 +46,7 @@ class Client bool m_mouse_grabbed; double m_player_dir_x; double m_player_dir_y; - refptr m_window; + refptr m_window; sf::Clock m_clock; Map m_map; sf::Uint8 m_current_player;