change Window to RenderWindow

This commit is contained in:
Josh Holtrop 2012-11-02 23:07:05 -04:00
parent 95bab5a823
commit f3770d1c89
3 changed files with 36 additions and 3 deletions

View File

@ -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())

View File

@ -1,6 +1,7 @@
#include <math.h>
#include "Client.h"
#include "Types.h"
#include <SFGUI/SFGUI.hpp>
/* 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()

View File

@ -4,7 +4,7 @@
#include <map>
#include <list>
#include <SFML/Window.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics.hpp>
#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<sf::Window> m_window;
refptr<sf::RenderWindow> m_window;
sf::Clock m_clock;
Map m_map;
sf::Uint8 m_current_player;