Hi, i'm new to SFML and C++(somewhat).(Using Visual Studio 2012)
I'm getting issues when i try to load a image because I have no idea where the code will try and load the image.
I tried to give the complete path but didn't work.
An error I get:
Unhandled exception at 0x77DF1F34 (msvcr100.dll) in 2D platformer.exe: 0xC0000005: Access violation reading location 0x00491000.
I tried using the Tutorial on the site but not sure what els to do.
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(1280, 720), "SFML works!");
sf::CircleShape shape(50.f); //size of circle
shape.setFillColor(sf::Color::Green);
window.setTitle("First Game");
window.setVerticalSyncEnabled(true);
window.setFramerateLimit(32);
sf::Texture texture;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
//---------------------Arrow keys----------------------
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
cout << "Left"<< endl;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
cout << "Right"<< endl;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
cout << "Up"<< endl;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
cout << "Down"<< endl;
}
if(!texture.loadFromFile("9452.jpg")){
cout << "Error" << endl;
}
//----------------------------------------------------
window.clear();
texture.create(50,50);
window.display();
}
return 0;
}