Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - captaindarkness

Pages: [1]
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:
 #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;
 }

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! :)

2
Graphics / Re: loadFromFile issues
« on: September 28, 2013, 02:59:34 pm »
I did the tutorial on how to get it working and i'm guessing that if i got the Green cirle in the installation tutorial to work that the debug and release was working.

3
Graphics / [SOLVED] loadFromFile issues
« on: September 28, 2013, 12:34:07 pm »
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;
}

Pages: [1]