PDA

View Full Version : Texture Loader



Japanime03
12-19-2002, 04: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

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

If you are asking about file importers, then try Devil
http://openil.sourceforge.net/links.php

and recompile for your needs.

V-man

NordFenris
12-19-2002, 04: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, "../");
#endif


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.