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 - noah.i.rivera

Pages: [1]
1
General / Re: Problem Loading External Files - CodeBlocks
« on: August 19, 2013, 07:33:26 pm »
I set up a debug build target, which I should've done in the first place, I discovered that my 8-bit png wouldn't load. I've tried several other png and gif files and the program reads them fine.

After doing a bit of research on "-L", and link and include paths, I was able to compile the program within the command line. Thanks for the info, as it was indeed very simple.

Quote
Yes, but it would involve low-level OS specific functions. A simpler solution is to package resources in an external file.
Could you recommend some commonly used methods and/or tutorials on how to package external resources?

I really appreciate your help. I haven't delved deeper into "true" software development is largely due to lack of knowledge on what to look for and inadequate documentation. I think it's fantastic that you're able to personally help out.

2
General / Problem Loading External Files - CodeBlocks
« on: August 19, 2013, 09:15:49 am »
Hello,

I'm rather experienced programming-wise. I am completely new, however, to IDEs, linking, and other such facets of software development. I've recently found out about SFML and decided to use it to learn about such processes.

My OS is Windows 8 64-bit, and I am using SFML with MinGW in CodeBlocks.
I've had experience using the command line MinGW g++ compile, and would've actually prefered using SFML in that, but learning about linking and other such things seemed was becoming a headache to figure out. So, instead, I set up SFML to work within CodeBlocks.

I've set up a test project, using only a Release build, which can compile and run fine. My problem, however, is figuring out how to access external files with SFML. I'm trying to run code provided on the SFML website, but am having problems loading an image.

Here is my code:
int main()
{
    sf::RenderWindow window(sf::VideoMode(320, 320), "Test");

    sf::Texture texture;
    if (!texture.loadFromFile("image.png"))
        return -1;

    sf::Sprite sprite;
    sprite.setTexture(texture);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(sprite);
        window.display();
    }

    return 0;
}

The process is always terminated with status -1, so I'm assuming loadFromFile is always returning false.

My project directory is:
C:\Users\<name>\Documents\CodeBlocks Projects\Test

I've put "image.png" in:
"C:\Users\<name>\Documents\CodeBlocks Projects\Test\"

as well as in:
C:\Users\<name>\Documents\CodeBlocks Projects\Test\bin\Release\

but the program still throws the error.

I've tried to do research, and the only thing I thought would be the problem would be CodeBlock's "working directory" for the project, which I've tried setting to "bin\Release", but I have not met any success. Aside from that, my search did not yield that helped me fix the problem.

Am I using the function incorrectly, or is there some setting I missed somewhere?

Also, is there a way, using CodeBlocks, that I can package and access files, such as images, within the executable itself?

Thanks for any help,
Noah

Pages: [1]
anything