So, I have two windows, they both work, they issue is when I tried to interact with the second window while it is above the first window, as soon as I move the first window away, then click back to the seconds window I can interact with it without any problems. My code is below.
//Declare both RenderWindows
sf::RenderWindow F1Menu;
sf::RenderWindow MainWin;
//Create the Main Window
MainWin.create(sf::VideoMode(800, 600), "SFML 2D");
sf::View MainView(sf::FloatRect(0, 0, 1600, 1200));
MainView.setViewport(sf::FloatRect(0, 0, 1, 1));
MainWin.setView(MainView);
//Loop while either window is open.
while (MainWin.isOpen() || F1Menu.isOpen())
{
sf::Event Event;
//Main Window got an event
if (MainWin.pollEvent(Event))
{
switch (Event.type)
{
case sf::Event::Closed:
MainWin.close();
break;
case sf::Event::Resized:
MainView.reset(sf::FloatRect(0.f, 0.f, MainWin.getSize().x, MainWin.getSize().y));
MainWin.setView(MainView);
break;
case sf::Event::KeyPressed:
if (Event.key.code == sf::Keyboard::F1)
//Create the second window when F1 is pressed.
F1Menu.create(sf::VideoMode(200, 500), "SFML 2D - F1 Menu");
else if (Event.key.code == sf::Keyboard::Escape)
MainWin.close();
break;
}
}
//Second Window got an event.
if (F1Menu.pollEvent(Event))
{
switch (Event.type)
{
case sf::Event::Closed:
F1Menu.close();
break;
}
}
//The Main window is the top window
if (MainWin.isOpen())
{
MainWin.clear();
MainWin.display();
}
//Second Window is top window.
if (F1Menu.isOpen())
{
F1Menu.clear();
F1Menu.display();
}
}
EDIT::::
Here is the link to a stack overflow question
http://stackoverflow.com/questions/27350714/managing-multiple-renderwindows-in-sfml/27351325?noredirect=1#comment43156853_27351325 I posted, it has a couple of important discussions, like what we have tried.
The most important part in there is when I discover that if I move the executable to another computer it works as expected.
Here are some specs on what I am compiling on, where the problem persists, I believe it may be a bug between the OS/Compiler and SFML:
- Windows XP 32-bit (Yes I know it is no longer supported, I have another computer, I use for everyday use.)
- Visual C++ 2010 32-bit
- 3GB Ram
Program Does work on the following system:
- MAC OSX 10.9.5 64-bit
- 4GB Ram
- I have not used XCode to compile, I used the same executable, but ran it under wine.
Should I try to update my Drivers? Can I on WinXP?
EDIT 2::::
After further investigation, it Does Not work on the Mac, but I can move the window. It seems they cannot poll events at the same time.