sjhalayka

OpenGL ES Using Xcode results in file not found error

Recommended Posts

sjhalayka    3

I'm using Xcode on Mac OS X, and I've added a file called 'peacock.tga' into my project. I can't seem to open that file (using fopen) however. Is there anything special that I need to do in order for the file to be readable?

Edited by sjhalayka

Share this post


Link to post
Share on other sites
jpetrie    13102

You need to make sure you use the correct path to the file. If you're just creating a regular, console-type application, the .tga is probably not being copied to the output directory of the executable. If you're creating an OS X bundle, you probably want to ensure the .tga is packaged into the bundle and that you use a path to where the file ends up in the Resources subdirectory of the bundle.

Share this post


Link to post
Share on other sites
Promit    13246

If you're porting and building a Mac OSX bundle app, you've have some file handling rework ahead of you. First, I recommend that you add your assets as references rather than directly in the project. This is because XCode will preserve folder structure for referenced folders, while flattening file hierarchies that are directly included in the project. Second, you will need to follow these instructions to get a real file path:

https://stackoverflow.com/questions/8768217/how-can-i-find-the-path-to-a-file-in-an-application-bundle-nsbundle-using-c

You'll be able to use fopen as normal after that. While we're on the topic, I'll point out that this approach will not work on Android, where you have to go through explicit platform-specific IO APIs to load content embedded in your app.

Share this post


Link to post
Share on other sites
sjhalayka    3

Thank you for the replies.

I managed to get it working using this code:

	    
    NSString *fileRoot = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"peacock.tga"];
	    tga_32bit_image peacock_img;
    peacock_img.load([fileRoot UTF8String]);
	

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now