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

Author Topic: Window does not stay open  (Read 1409 times)

0 Members and 1 Guest are viewing this topic.

totalwar235

  • Newbie
  • *
  • Posts: 11
    • View Profile
Window does not stay open
« on: February 07, 2011, 02:33:23 am »
i have been experimenting with SFML and my recent project compiles perfectly fine but it does not stay open.

Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");
sf::Event Event;
sf::Input Input;
sf::Input &rInput = Input;

int Start_Menu();

int main()
{
App.Create(sf::VideoMode(800, 600, 32), "SFML Window");

bool Running = true;
while (Running)
{
    App.Display();
while (App.IsOpened())
{

Start_Menu();
}

}

return EXIT_SUCCESS;

}

int Start_Menu()
{


const sf::Input& Input = App.GetInput();

unsigned int Start_X = Input.GetMouseX(), Start_Y = Input.GetMouseY();

        if (Event.Type == sf::Event::Closed)
{
        App.Close();
}

     
// Escape key pressed
        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
{
App.Close();
}

return 0;
}


i put all the sf::(ect) up at the top so i do not have to call it in both functions.

i am running a 64bit vista if that is any help[/code]

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Window does not stay open
« Reply #1 on: February 07, 2011, 02:36:12 am »
Your code is a big mess really, nothing is supposed to work right :)

Why do you create the window twice? And globally doesnt seem particularly right.

You're not processing events at all.

Please read the tutorials a little better :)