Re: [Plib-devel] User defined texture formats
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2000-05-10 22:24:43
|
Trent Gamblin wrote: > > * Steve Baker <sjb...@ai...> wrote: > > OK - but I don't think this is the place to load textures. > > > > Shouldn't this just be the (existing) ssgGetAppState callback? > > I'm really confused. Is there any code or examples that use > ssgGetAppState to load a different image format? An example would be > really helpful. Well, my TUx game (http://tuxaqfh.sourceforge.net) uses the ssgGetAppState callback - but not to load different image formats. Check out 'material.cxx'. However, it goes like this: * You set up a function as the callback. * Whenever the loader needs to create an ssgState, it calls your function with the name of the texture. * In your function, you allocate (or choose a pre-allocated) ssgState and populate it (which could include loading the texture for it). * If you return a valid ssgState, the loader will use it for that leaf. * If you return NULL, the loader will create one for you. The deal is (IMHO) that loading textures whenever an input file tells you to is pretty inefficient. Most games are likely to load MANY models - and this can easily result in multiple copies of the texture being loaded - which is VERY wasteful. Also, there is frequently a need to attach user data to an ssgState because your game needs to know other things about the polygon than just the more obvious visual properties. My Tux game stores the coefficient of friction for example, so that our Penguin Pal can slide down icy slopes. Since the needed information isn't in the model file anywhere, it's necessary for the game code to somehow maintain a table of what properties belong to what materials. I pre-load all the textures I think I'm going to need, create a bunch of ssgSimpleState objects - one for each pre-designed material. Then when a model is loaded, if the texture map in the file agrees with the name of the map on one of my pre-defined materials, it gets that - otherwise I let the loader set it up. -- Steve Baker http://web2.airmail.net/sjbaker1 sjb...@ai... (home) http://www.woodsoup.org/~sbaker sj...@ht... (work) |