Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Additional Windows?  (Read 1088 times)

0 Members and 1 Guest are viewing this topic.

fatum

  • Newbie
  • *
  • Posts: 47
    • MSN Messenger - bowsers7@hotmail.com
    • AOL Instant Messenger - therealblah569
    • View Profile
    • http://boards.psynetfm.com
Additional Windows?
« on: September 04, 2011, 03:40:13 am »
I have this bit here in a separate source file:
Code: [Select]

#include "SFML/Graphics.hpp"
#include "WindowTest.h"

const int SCREEN_WIDTH = 550;
const int SCREEN_HEIGHT = 400;
const int SCREEN_BPP = 32;

sf::RenderWindow Window;

int WindowTest()
{
Window.Create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP), "LOL", !sf::Style::Resize | sf::Style::Close);

while (Window.IsOpened())
{
sf::Event event;
while (Window.PollEvent(event))
{
switch (event.Type)
{
case sf::Event::Closed:
Window.Close();
break;
}
}
}

return EXIT_SUCCESS;
}


I include it's header file, and I call "WindowTest();" whenever I'd like to open it.  However, currently this doesn't work too well.  The window does open, but it's occasionally a little shaky whenever I move it around.  I also can't close the first window until I close this window, and the first window's "Close" button blinks a little bit too.

Should I handle the second window's logical in a separate thread?  Or is there a better method to have multiple windows?

Thanks for any help!

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Additional Windows?
« Reply #1 on: September 04, 2011, 04:26:07 am »
You actually need to handle events for all windows opened in a queue kind of way.

So you just have all the windows in a list or something and do something like:

Code: [Select]
foreach w in windowList
        Process w Events


If you are going to stuck your code in a while loop that doesnt want to end, at least make sure all important code is in that loop. or better, dont do the loop, and invite the new windows into your main loop code as i said! :)

Hope it helps!

 

anything