Jump to content
  • Advertisement
sjhalayka

OpenGL ES Using Xcode results in file not found error

This topic is 489 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement

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

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

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!