SFML community forums

Help => Window => Topic started by: Prominence256 on December 21, 2010, 08:44:25 pm

Title: App crashed on Window::Close()
Post by: Prominence256 on December 21, 2010, 08:44:25 pm
I just started with SFML 1.6 and I'm trying to go through the official tutorials. I'm currently on the window-events (http://sfml-dev.org/tutorials/1.6/window-events.php) one. I'm using Visual Studio 2010, and my problem is that my program crashes when it's told to close. VS gives me the error:
Quote from: "Visual Studio"
Run-Time Check Failure #2 - Stack around the variable 'app' was corrupted.
This is my code:
Code: [Select]
int main(int argc, char** argv)
{
Window app(VideoMode(768, 512, 32), "SFML Window");
const Input& input = app.GetInput();

while (app.IsOpened())
{
Event events;
while (app.GetEvent(events))
{
if ((events.Type == Event::Closed) || // X is clicked
((events.Type == Event::KeyReleased) && (events.Key.Code == Key::Escape))) // Esc is released
app.Close();
}

// Arrow Keys
bool LeftKeyDown = input.IsKeyDown(Key::Left);
bool RightKeyDown = input.IsKeyDown(Key::Right);
bool UpKeyDown = input.IsKeyDown(Key::Up);
bool DownKeyDown = input.IsKeyDown(Key::Down);
// Mouse
bool LeftDown = input.IsMouseButtonDown(Mouse::Left);
bool MiddleDown = input.IsMouseButtonDown(Mouse::Middle);
bool RightDown = input.IsMouseButtonDown(Mouse::Right);
unsigned int MouseX = input.GetMouseX();
unsigned int MouseY = input.GetMouseY();

app.Display();
}
return 0;
}
Title: App crashed on Window::Close()
Post by: Laurent on December 21, 2010, 11:52:48 pm
Have you recompiled SFML?
Title: App crashed on Window::Close()
Post by: Prominence256 on December 22, 2010, 03:45:44 am
I'm actually using the VS 2008 download.
Title: App crashed on Window::Close()
Post by: Laurent on December 22, 2010, 07:52:35 am
So you must first recompile SFML.
Title: App crashed on Window::Close()
Post by: model76 on December 22, 2010, 02:37:54 pm
Maybe you could provide a VS 2010 version? It seems like a fair amount of new users have this issue...
Title: App crashed on Window::Close()
Post by: Laurent on December 22, 2010, 03:24:06 pm
I will, for the next versions of SFML.
Title: App crashed on Window::Close()
Post by: Prominence256 on December 22, 2010, 11:07:38 pm
I'm trying to use VS's batch build to recompile SFML, but when I do it doesn't create any of the regular .lib's like sfml-window.lib or sfml-system.lib
Title: App crashed on Window::Close()
Post by: Laurent on December 23, 2010, 08:06:07 am
The batch build is not supposed to work for VS 2010.
Title: App crashed on Window::Close()
Post by: Prominence256 on December 24, 2010, 10:39:22 pm
I recompiled it all and now it's working great, thanks. :D