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

Author Topic: Problems loading images when I split program into modules  (Read 2066 times)

0 Members and 1 Guest are viewing this topic.

KasHKoW

  • Newbie
  • *
  • Posts: 41
    • View Profile
Problems loading images when I split program into modules
« on: June 25, 2011, 08:31:43 am »
I have a program that I split into two modules with a header.

I'm new to the whole modules/headers thing. I started to use it because my code is now > 300 lines and daunting to look at. I suspect it to get to > 800 lines, this helps in the long run.

Anyhow, when it works, it's all consolidated into one source file. When I give a header... I put all Class declarations in the header file. I include SFML/Graphics.hpp and any #defines I have for the program. The first source module has all the definitions for the class declarations, while the second has all the main function. It compiles but it spits out an error while trying to load an Image. What's bizarre about this error is that the name of the image is a directory + image.

Anyone know why this is happening?


Failed to load image "gameImages/Pong/b1.jpg". Reason : Unable to open file

Cuban-Pete

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Problems loading images when I split program into modules
« Reply #1 on: June 25, 2011, 10:21:22 am »
are you sure the image is really there? and by there I mean were your .exe is located and than in the map gameImages -> Pong

KasHKoW

  • Newbie
  • *
  • Posts: 41
    • View Profile
Problems loading images when I split program into modules
« Reply #2 on: June 26, 2011, 02:31:54 am »
the file is home/ken/Documents/SFML/gameImages/Pong/b1.jpg

or something of that nature...

I'm positive that the actual image is in that file absolute path. As when I consolidate the code into one large file, it works perfectly.

Also, I don't get what you're fully saying. Should the file be in the folder that the game binary is in?

Cuban-Pete

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Problems loading images when I split program into modules
« Reply #3 on: June 26, 2011, 10:15:10 am »
you are using the function LoadFromFile(), right?

so if it says LoadFromFile("b1.jpg"), that means that the image b1 is in the same folder as your .exe (the game binary).

lets say your exe is in the folder 'program', than if the function says LoadFromFile("images/1.jpg"), that means the image must be in 'program/images/' folder.

 

anything