Texture Path Problem

Posts: 2
Joined: 2008.12
Post: #1

I'm having an issue loading textures in c++. Specifically, I'm having an issue getting the path to the texture. From what I've read, this code should get me a c string to the path:

CFBundleRef mainBundle;
    CFURLRef textureFile;    
    char texturePath[1024];    

    mainBundle = CFBundleGetMainBundle();
    textureFile = CFBundleCopyResourceURL(mainBundle, CFSTR("placeholder"), CFSTR("tga"), NULL);
    if( textureFile ) {
        CFStringRef str = CFURLCopyFileSystemPath( textureFile, kCFURLPOSIXPathStyle );
        CFStringGetCString( str, texturePath, 1024, kCFStringEncodingASCII );

But it doesn't quite work. The full path is clipped. texturePath is missing the last like 50 characters. The function returns true, which means there was plenty of space in the buffer, so it is not a size issue.

Alternatively, I've tried this, which returns a null pointer.
const char* texturePathPtr = CFStringGetCStringPtr(str, kCFStringEncodingASCII) ;
Any ideas?
Thanks in advance.

Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
You should use CFURLGetFileSystemRepresentation() and PATH_MAX to size the array ( dunno if that's *the* problem with your code, but it's *a* problem Wink )
Quote this message in a reply
Posts: 2
Joined: 2008.12
Post: #3
CFURLGetFileSystemRepresentation did the trick. Thanks.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  opengl es strange 16bit texture scale problem spuckfunkel 6 14,401 Aug 14, 2011 10:44 PM
Last Post: headkaze
  SOIL image library problem or texture lib problem hippocoder 12 14,267 Mar 22, 2010 08:51 PM
Last Post: Frank C.
  Verify that a touch/drag was along a path BangTickBoom 3 4,513 Jun 10, 2009 03:29 PM
Last Post: MattDiamond
  Small size texture problem kendric 3 4,298 Mar 25, 2009 06:40 PM
Last Post: kendric