Resolving error trying to load image using ofImage

I’m trying to run the included example for the ofxMSAPhysics addon (source here: https://github.com/memo/ofxMSAPhysics/tree/master/example), and I have gotten everything going except for a single loadImage call to bring in a transparent PNG of a ball.

The error I get in the console reads:
[ error ] ofImage: loadImage(): couldn’t load image from “ball.png”

I have added this image to my project in CodeBlocks using both Project > Add files and by adding it’s directory to my Search directories in the Build options, but neither seems to help. Following some vaguely relevant advice found through searches I moved the loadImage call to other functions, but couldn’t resolve the error.

I’m not sure quite what is going on, nor how to fix it. Any ideas?

I’m using oF v0.8.4 and CodeBlocks 12.11 on a Win7 machine.

RESOLVED!

The example has the “ball.png” image in a folder named “data” at the same level as the “src” folder, but it looks like this data folder actually needs to be inside of a folder named “bin”. Noticed this while running another example that had the folders set up this way. Just moved the file/folder and it worked (better)!

Hi there!

On the Xcode setup guide you can read the following bin is where your finished runnable app will end up, as well as your data folder which is for assets like images, sound files, etc.”

This is true, by default. If you want to change it, you can do ofSetDataPathRoot.

The CodeBlocks setup guide does not state this. Heck, looking at that Xcode guide there is quite a lot that is not mentioned in the Codeblocks guide, let alone with pretty GIFs and formatting.

The example for the MSA library had the data folder in the wrong spot, but being a beginner I had no idea and just assumed that such a popular addon would’ve gotten it right and that I was doing something wrong. Just pure luck that I happened to be playing with other examples and was curious where their images were stored.

I totally understand your frustration. In the beginning there’s a lot to absorb, just keep hanging. :smile: Usually, I think you get more examples and resources for Mac OS users.

You’ll also notice that the example does not have things like configs, workspaces, et cetera. This is just to keep it light. It’s a pretty common practice. Keep that in mind, for future findings on GitHub.

Any questions, just come to the forum. Glad to help.

Hey no biggie, haha. I’ve been a “beginner” for a few years now with oF, trying and failing several times to get started. Lots and lots of stumbling blocks, mostly stemming from not owning any Macs and not knowing anyone in real-life that knows what oF is and can teach me the basics offline. If I could afford a Mac or if I lived in NYC (and could afford the schools that the core devs teach at) I would probably have a smoother experience, lol.

This time around I seem to be having a better time, so I must be learning something!

All of the other add-ons I’ve installed so far worked great and had everything in the right spot, it was just this particular add-on that had the data folder in an unusual spot. Now I know!

1 Like