I have a game displayed on a fullscreen window that works fine. In this game i have an options button. When you click it, i want a second window(non fullscreen) to pop up and the fullscreen window to be unresponsive until you close the other. So in main.cpp i have a standard window loop:
main.cpp
static sf::RenderWindow window(sf::VideoMode(1152,864),"Palindromo test",sf::Style::Fullscreen);
int main()
{
window.setVerticalSyncEnabled(true);
menu = new Menu(&window);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
window.clear(sf::Color::White);
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
case sf::Event::MouseMoved:
menu->mousemoved();
break;
case sf::Event::MouseButtonPressed:
menu->mouseclicked();
break;
case sf::Event::KeyPressed:
if (event.key.code == sf::Keyboard::Escape)
exit(0);
break;
}
}
menu->display();
window.display();
}
return 0;
}
Menu is a class i created. So menu->mouseclicked() checks if some button of menu was clicked; if you click the options button this executes:
void Obutton::clicked()
{
sf::RenderWindow owindow(sf::VideoMode(800,600),"Options",sf::Style::Close);
owindow.setVerticalSyncEnabled(true);
while (owindow.isOpen())
{
sf::Event event;
while (owindow.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
owindow.close();
break;
}
}
owindow.clear(sf::Color::Blue);
owindow.display();
}
}
My problem is that when i click the Obutton(options button), in my first computer, the game just freezes. In my other computer, a non-responsive transparent window pops up. After about 10-20 seconds it gets blue as desired and responds, but if you click outside it, it gets non-responsive, this time for ever, even if you click on it again. So i close it with the task manager. Why isn't it working? Do i need to activate the pop-up or something? Thanks.