[Plib-devel] loading textures and ssgTexturePath(path)
Brought to you by:
sjbaker
From: Olivier A <oli...@wa...> - 2004-10-24 12:34:55
|
Neither ssgSimpleState::setTexture(file) nor ssgLoadTexture(file) use the path set by ssgTexturePath(path) to load texture files. As the path is not addded, these functions load 'file' from the current working directory, which is not the same among the OS, or the windowing system used (GLUT, pw, ...). I think it is a bug (but I am not sure): In some examples, e.g. ssg/water, the program set the path to "data" with a call to ssgTexturePath and loads textures by simply calling ssgSimpleState::setTexture("pattern.rgb"), ... but the the SGI texture loader does not look for the file in the "data" folder. I suggest the following patch in ssgLoadTexture.cxx: in the function: bool ssgLoadTexture ( const char * filename, ssgTextureInfo* info ) just after the "if ( *extn != '.' )" block: +++ char buff[1024]; +++ _ssgCurrentOptions->makeTexturePath(buff, filename); +++ const char *filepath = buff; and replacing 'filename' by 'filepath' thereafter (3 occurences). The problem is that I am not sure this patch is compatible with model loaders, which use a ssgLoaderOptions class... (A quick search shows that it is only redondant). Another way is to modify the following method of ssgSimpleState in ssg.h: virtual void setTexture ( const char *fname, int _wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE ) by applying the same patch as above, and perhaps moving the code in ssg.cxx. Olivier A. |