I am very new to the SFML libraries, I have been reading through the tutorials and decided to play around with it to see how it worked. Everything was working fantastically! I fixed my linker issues, Everything was running smoothly...
Until I Cleared the screen and drew a shape.
After I put in those two instructions the window now only stays open for a second then closes.
I am using SFML 1.6 with Windows Visual C++ 2008 Express edition.
Here is the code
#include "stdafx.h"
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
using namespace sf;
using namespace std;
int main(){
RenderWindow App(VideoMode(800,600,32), "Tutorial");
Shape rect = Shape::Rectangle (0, 0, 10, 10, Color::Red);
int NumberLoops = 0;
while(true) {
Event handle;
while(App.GetEvent(handle))
{
cout << "Next loop has been made, It has looped" << NumberLoops << "times";
NumberLoops++;
cout << endl;
if(handle.Key.Code == Key::Back || handle.Type == Event::Closed) {
App.Close();
cout << "Window closed";
cout << endl;
}
if(handle.Type == Event::MouseButtonPressed) {
cout << "Mouse button pressed?";
cout << endl;
}
if(handle.Type == Event::MouseButtonReleased) {
cout << "Mouse button released";
cout << endl;
}
}
App.Clear();
App.Draw(rect);
App.Display();
}
return EXIT_SUCCESS;
}
If I get rid of App.Clear(); and App.Draw(rect); It will run fine without closing, But apparently those two members of the RenderWindow class doesn't like my IDE very much.
Where have I gone wrong?
If it helps anything, this is what it says on the debug window when it closes.
STATUS_STACK_BUFFER_OVERRUN encountered
The thread 'Win32 Thread' (0x1e94) has exited with code -1073740791 (0xc0000409).
The thread 'Win32 Thread' (0x1f08) has exited with code -1073740791 (0xc0000409).
The thread 'Win32 Thread' (0x1e68) has exited with code -1073740791 (0xc0000409).
The thread 'Win32 Thread' (0xec) has exited with code -1073740791 (0xc0000409).
The program '[7824] Testing_sfml.exe: Managed' has exited with code -1073740791 (0xc0000409).
The program '[7824] Testing_sfml.exe: Native' has exited with code -1073740791 (0xc0000409).