Hey There,
I've got some issue with the program i'm currently coding. No error at all, but the window doesn't react to any event. Here's the concerned code :
main.cpp
#include <iostream> // mostly for debug
#include <cstdlib> // for atoi()
#include <SFGUI/SFGUI.hpp>
#include <SFML/System.hpp>
#include <SFML/Network.hpp>
#include "ServerWindow.hpp"
#include "constants.hpp"
int main(int argc, char* argv[]) {
#ifdef DEBUG
std::cout << "DEBUG : Pour desactiver les messages de debug, retirer la definition de DEBUG et la remplacer par #define RELEASE dans constants.hpp" << std::endl << std::endl;
std::cout << "DEBUG : Initialisation de l'interface graphique." << std::endl;
sf::Clock debugClock;
#endif // DEBUG
ServerWindow window;
window.initialize();
#ifdef DEBUG
std::cout << "DEBUG : Interface graphice initialisee avec succes en " << debugClock.getElapsedTime().asSeconds() << " secondes." << std::endl;
#endif // DEBUG
window.setActive(false); // cause we use threads
sf::Thread guiThread(&ServerWindow::go, &window);
guiThread.launch();
return EXIT_SUCCESS;
}
ServerWindow's go method (ServerWindow inherits sf::RenderWindow)
void ServerWindow::go() {
setActive(true);
o_running = true;
this->resetGLStates(); // else we wouldn't see anything
this->setFramerateLimit(60); // because it's enough
o_clock.restart();
// main loop
while(this->isOpen()) {
// event handling
while(this->pollEvent(o_event)) {
// sfgui event handling
o_desktop.HandleEvent(o_event);
// closing
if(o_event.type == sf::Event::Closed) {
o_running = false;
this->close();
}
}
o_desktop.Update(o_clock.restart().asSeconds());
this->clear(sf::Color::Black);
// bad but necessary
o_sfgui.Display(*(const_cast<ServerWindow*>(this)));
this->display();
}
}
As you can see, I use SFGUI but I don't think it's related to the problem, since I can't even close the window, which is a regular sfml event.
Thanks in advance !