SFML community forums

Help => General => Topic started by: Wnt2bsleepin on February 27, 2013, 03:18:54 pm

Title: Pathing issues for resources
Post by: Wnt2bsleepin on February 27, 2013, 03:18:54 pm
Hello, I am developing a simple game and I want to load images to use a textures. I am able to get it to load from Visual Studio on Windows fine, but I do not know where to place the files in OSX using XCode.

Here is the line of code that I am using to load the file.

texture.loadFromFile("splashscreen.png")

I realize that the pathing is different, so is there anyway to detect the OS and use the path that fits? Thank you for any help.
Title: Re: Pathing issues for resources
Post by: Gan on February 27, 2013, 03:23:53 pm
When loading resources on Mac you need to have the ResourcePath class and you pretty much just append the resource path to the file you're looking for.
And to detect version, I think you can use an #ifdef statement.
Title: Re: Pathing issues for resources
Post by: Wnt2bsleepin on February 27, 2013, 04:04:19 pm
So it's not as simple as having it in the same directory as the executing app? I hope this doesn't hurt my compatibility between platforms too much.

Are there any tutorials on how to do so? Most of the ones I am seeing are for Objective-C and iPhone development.
Title: Re: Pathing issues for resources
Post by: Hiura on February 27, 2013, 05:20:50 pm
When you create your SFML project using the provided templates for Xcode 4 you get a nice example with comments that basically explain how it works. Simply use the provided function to get the resource path from your application bundle. (no obj-c knowledge required)

Now, a quick note about cross-platform applications : the provided `resourcePath` function only works on Mac OS X but you can add specific implementations for Linux/Windows.