1
Graphics / Re: loadFromFile issues
« on: September 29, 2013, 02:43:35 pm »
UPDATE:
So i found this really good Guide on how to install SFML. http://sfmlcoder.wordpress.com/2011/05/18/creating-a-first-sfml-project/
Really good and when I try to run this:
I get no Error which I take as the file was located without any problems, though it doesn't show it in the window which might be that i'm missing something.
EDIT:
Made a Sprite and got the image loaded
Thanks for the help!
So i found this really good Guide on how to install SFML. http://sfmlcoder.wordpress.com/2011/05/18/creating-a-first-sfml-project/
Really good and when I try to run this:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "First SFML Project");
sf::Texture texture;
texture.loadFromFile("C:/Users/username/Documents/Visual Studio 2012/Projects/SFML project/img/9452.jpg");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
}
}
//---------------------Arrow keys----------------------
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
}
//-----------------------------------------------------
if(!texture.loadFromFile("C:/Users/username/Documents/Visual Studio 2012/Projects/SFML project/img/9452.jpg")){
}
window.clear(sf::Color(0, 255, 255));
texture.create(50,50);
window.display();
}
return 0;
}
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "First SFML Project");
sf::Texture texture;
texture.loadFromFile("C:/Users/username/Documents/Visual Studio 2012/Projects/SFML project/img/9452.jpg");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
}
}
//---------------------Arrow keys----------------------
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
}
//-----------------------------------------------------
if(!texture.loadFromFile("C:/Users/username/Documents/Visual Studio 2012/Projects/SFML project/img/9452.jpg")){
}
window.clear(sf::Color(0, 255, 255));
texture.create(50,50);
window.display();
}
return 0;
}
I get no Error which I take as the file was located without any problems, though it doesn't show it in the window which might be that i'm missing something.
EDIT:
Made a Sprite and got the image loaded
Thanks for the help!