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

Author Topic: Loading an image with OS X  (Read 3377 times)

0 Members and 1 Guest are viewing this topic.

dotty

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Loading an image with OS X
« on: January 15, 2012, 03:42:20 pm »
Hello, this might end up being an embarrassing question. I'm new to XCODE and C++, but I'm learning quickly (I have a programming background, so just learning how c++ does things is the biggest issue I'm having at the moment).

I'm having difficulty using texture.LoadFromFile(). My main main.cpp file is stored under playground/ and under here I have a folder called "assets" and within that I have an image "sprite.png". I'm trying to load this with XCODE, I use texture.LoadFromFile("assets/sprite.png") and return -1 if it fails to load the file. This always exit's the program saying it can't load the file in quesion. Is there anything else I need to do to load this file?

Thanks!

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Loading an image with OS X
« Reply #1 on: January 15, 2012, 03:50:41 pm »
It doesn't matter where the main.cpp file is located, but where the project is located.
So if your project was above the playground folder then you should load "playground/assets/sprite.png".
TGUI: C++ SFML GUI

dotty

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Loading an image with OS X
« Reply #2 on: January 15, 2012, 03:55:52 pm »
The folder where everything is stored is called "playground", and inside that I have "assets", so i would assume that LoadFromFile("assets/sprtie.png") would work, but it doesnt.

Does XCODE require me to load the file into XCODE or something like that?

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
Loading an image with OS X
« Reply #3 on: January 15, 2012, 04:09:15 pm »
I don't know anything about XCODE, but does it work when you pass the complete pathname?
TGUI: C++ SFML GUI

dotty

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Loading an image with OS X
« Reply #4 on: January 15, 2012, 04:11:03 pm »
It works with the full path (/Users/me/Documents/sfml/playground/assets/sprite.png")

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Loading an image with OS X
« Reply #5 on: January 15, 2012, 04:52:54 pm »
Want to play movies in your SFML application? Check out sfeMovie!

 

anything