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 - Toxicshadow

Pages: [1]
1
Graphics / Re: Loading an image fail
« on: August 31, 2012, 05:52:22 am »
Posting the answer for future reference:

In order for the image to work, you have to have the image where your source is, not where the exe compiles.
In Code::Blocks your folders look like:

Source             <- Image and source .cpp files go here
Source\bin\Debug       <- Exe compiles here
Source\obj\Debug       <- Main.o is here, but irrelevant to this topic.
 

Sorry if this is considered necroing, just posting this for future reference for anyone else who was confused.

2
Graphics / Re: Loading an image fail
« on: August 25, 2012, 09:58:54 am »
Well you then probably hacen't read enough... ;)
You've already found the cause and your uncertenty about the images location says it all. Unfortunatly you didn't state what IDE you're using.
E.g. in VS you have to place the resources next to the project file.
Generally speaking the application will search for the resource in the working directory, if your IDE has such an option, then you probably should check its path.

Note: This forum has a code=cpp tag, so please make use of it. ;)
Sorry about the code=cpp thing. Also I'm using Code::Blocks. My image is in Source\bin\Debug. This is also where I placed the dlls and where CB compiles the debug exe to.

3
Graphics / Loading an image fail
« on: August 25, 2012, 05:58:26 am »
First: I did do a search and did find other topics containing the same issue, however they didn't help in fixing my problem.


I'm completely new to sfml, and completely lost. I looked at the official tutorial on rendering graphics with the graphics package. Managed to get a black screen. After that I looked at a different tutorial on actually getting an image to render, and all that happens is a quick 1frame white screen and then it closes and returns that it cant open the image file when I have the file in the location I *think* it should go(Source->Bin->Debug, with the debug exe) My image's name is 'ball.png'

My code looks like:

#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>

using namespace sf;

int main()
{
    // Create the main rendering window
    sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "SFML Graphics");
    sf::Image Ball;
    if (!Ball.LoadFromFile("ball.png"))
        return 1;
    sf::Sprite SprBall;
    SprBall.SetImage(Ball);
    SprBall.SetPosition(100.0f, 30.0f);

    // Start game loop
    while (Window.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (Window.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                Window.Close();
        }

        // Clear the screen (fill it with some random color)
        Window.Clear(sf::Color(23, 98, 137));
        //Drawing the Ball
        Window.Draw(SprBall);
        // Display window contents on screen
        Window.Display();
    }

    return EXIT_SUCCESS;
}
 
Thanks for any/all help given :)

Edit: Oh and sorry if it looks very messy, its a mix of 2 different tutorials.

Pages: [1]
anything