Re: [Plib-devel] Exposed bitmap loaders in SSG?
Brought to you by:
sjbaker
From: steve <sjb...@ai...> - 2007-01-06 14:56:40
|
Jan Reucker wrote: > Hello! > > In August 2005 I wrote to this list asking what you'd think about > exposing the bitmap loader functions from SSG. This would allow > PLIB users to use these loaders for more than only texture loading, > or it would simplify writing more complex texture classes for > SSG. During the last 1.5 years I didn't find the time to start the > project for which I needed this, but now it would really come in > handy. Yeah - I've been thinking for a long time that we could use a proper set of image loaders somewhere in PLIB...and if we had them it would make sense to change the SSG texture map loaders to use them. But if we are going to do this - let's think carefully up-front and do it properly. If you want to take on this task, I think you should start a new PLIB library component (plibImage with a 'pi' prefix or something) - get it all up and working as a stand-alone thing (probably copying/stealing code from SSG to do that). When it's all running and reliable, we could just switch SSG over to using it. This would mean zero changes to SSG until we are ready to do the switch. One thing though - we need to be careful about adding external dependencies. Relative lack of external dependancies is one of the things people really value about PLIB and we don't want to lose that. I'd like to avoid having PLIB require libjpeg, libpng and a bunch of other libXXX's before it'll compile. Whilst you can rely on those being present in Linux these days, they aren't always there under Windows and MacOSX. On the other hand, we don't want to copy the code from those libraries into PLIB (thereby causing a code-fork for those projects) and we CERTAINLY don't want to be writing and maintaining our own JPEG and PNG loaders! I think we should consider dynamically loading those libraries (using dlopen/dlsym/dlclose) on-demand so that PLIB will still build and run without any external image libraries if the user only wants to use '.rgb' images. The system should have a 'piInit()' call that goes out and looks for available libXXX's (where 'XXX' is png, jpeg, gif, tif, etc) and posts a list of available loaders that one can easily query from the application level. eg piInit() ; if ( piHaveLoaderFor ( "png" ) ) image = piImageFactory ( "myimage.png" ) ; else if ( piHaveLoaderFor ( "jpg" ) ) // Urgh - lower quality! image = piImageFactory ( "myimage.jpg" ) ; else ulSetError ( UL_FATAL, "Can't load myimage because both" " libpng and libjpeg are missing" ) ; |