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

Author Topic: Pathing issues for resources  (Read 1413 times)

0 Members and 1 Guest are viewing this topic.

Wnt2bsleepin

  • Guest
Pathing issues for resources
« 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.
« Last Edit: February 27, 2013, 03:21:11 pm by Wnt2bsleepin »

Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: Pathing issues for resources
« Reply #1 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.

Wnt2bsleepin

  • Guest
Re: Pathing issues for resources
« Reply #2 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.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Pathing issues for resources
« Reply #3 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.
SFML / OS X developer