View Full Version : Texture Loader

12-19-2002, 03:56 AM
hey does anyone know how to program a texture loader for the MAC OS X operating system. I am trying to load a file for my particle engine, but it doesn't seem to work so far... If anyone could help, it would be wonderful! Thanx

12-19-2002, 06:01 AM
glTexImageXD are typically used to upload textures, or use the subcopy version.

If you are asking about file importers, then try Devil

and recompile for your needs.


12-19-2002, 03:26 PM
On X, you will probably bump into some problems loading the file if you use fopen(). This, because you really cannot know the path to your application (it differs depending if you run it thru LaunchCFMApp, Project Builder, Finder or CodeWarrior), can be fixed by using Bundle Services. The following code gets the path to your bundle, and then you should...

char basePath [256];
#if defined(__APPLE__) | | defined(MACOSX)
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef url = CFBundleCopyBundleURL(mainBundle);
CFStringRef cfStr = CFURLCopyPath(url);
(const char *)basePath = CFStringGetCStringPtr(cfStr, CFStringGetSystemEncoding());
strcat (basePath, "../");

Then, if you want to use fopen to open "texture.tga", you need to do this:

char filepath [512];
strcat (filepath, basePath);
strcat (filepath, "texture.tga");
theFile = fopen (filepath, "r+");

This procedure is enough to make anyone want to use File Services, and possibly even QuickTime.