////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
// Create the main window
sf::Window App(sf::VideoMode(800, 600, 32), "SFML Events");
// Get a reference to the input manager associated to our window, and store it for later use
const sf::Input& Input = App.GetInput();
// Start main loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
// Escape key : exit
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
// Get some useless input states, just to illustrate the tutorial
bool LeftKeyDown = Input.IsKeyDown(sf::Key::Left);
bool RightButtonDown = Input.IsMouseButtonDown(sf::Mouse::Right);
bool JoyButton1Down = Input.IsJoystickButtonDown(0, 1);
unsigned int MouseX = Input.GetMouseX();
unsigned int MouseY = Input.GetMouseY();
int JoystickX = (int)Input.GetJoystickAxis(1, sf::Joy::AxisZ);
int JoystickY = (int)Input.GetJoystickAxis(1, sf::Joy::AxisY);
int JoystickPOV = (int)Input.GetJoystickAxis(1, sf::Joy::AxisPOV);
// Display window on screen
App.Display();
}
return EXIT_SUCCESS;
}
The window doesn't open, it says "Learning SFML has encountered a problem and needs to close." Any help would be very appreciated.
Last edited by lotios611 on Sat Dec 12, 2009 3:31 pm, edited 1 time in total.
lotios611 wrote:I did that, with the debug versions.
kk, what IDE are you using? Dev-C++, Code::Blocks, Visual?
also are you linking {sfml-system.a, sfml-graphics.a, sfml-window.a} in the library part and using SFML-DYNAMIC in the compiler settings part of your project options?
Debugger says: Unhandled exception at 0x7c809e8a in Learning SFML.exe: 0xC0000005: Access violation reading location 0x0073746e.
I don't have a gamepad or USB joystick plugged in.
I'm using SFML V 1.5.
The input isn't what's wrong, the program breaks at the part where it says
#include <SFML/Graphics.hpp>
using namespace sf; //This just makes it so you don't have to keep typing sf:: before everything.
int main()
{
RenderWindow App(VideoMode(1024, 768, 32), "SFML Graphics");
return 0;
}
Don't forget to link to sfml-graphics-d.lib in the linker->input section of your project properties, either.
#include <SFML/Graphics.hpp>
using namespace sf; //This just makes it so you don't have to keep typing sf:: before everything.
int main()
{
RenderWindow App(VideoMode(1024, 768, 32), "SFML Graphics");
return 0;
}
Don't forget to link to sfml-graphics-d.lib in the linker->input section of your project properties, either.
If you haven't solved this already, than just replace sf::Window App(sf::VideoMode(800, 600, 32), "SFML Events"); with RenderWindow like Bludklok said. Assuming this is where the error is coming in.