RE: [Plib-devel] User defined texture formats
Brought to you by:
sjbaker
From: Dave M. <Dav...@dy...> - 2000-05-10 17:11:51
|
> > I did a cvs commit which adds a leaf creation hook to ssgLoadAC.cxx > > OK - but I don't think this is the place to load textures. > Shouldn't this just be the (existing) ssgGetAppState callback? > > Whenever the loader allocates a new ssgState, it calls that callback > with the name of the texture map - you can then either share an > existing ssgState or allocate a new one - complete with correctly > loaded texture map. > Here is the source from ssgIO.cxx: ssgLeaf* _ssgCreateFunc ( ssgCreateData* data ) { ssgVtxTable *vtab = 0 ; if ( data ) { vtab = new ssgVtxTable ( data->gltype, data->vl, data->nl, data->tl, data->cl ) ; vtab -> setCullFace ( data -> cull_face ) ; //an old hack if ( _ssgGetAppState != NULL && data -> tfname && data -> tfname[0] != 0 ) { delete data -> st ; data -> st = 0 ; ssgState* st = _ssgGetAppState ( data -> tfname ) ; vtab -> setState ( st ) ; } else if ( data -> st != NULL ) { ssgSimpleState *st = data -> st ; char filename [ 1024 ] ; _ssgMakePath ( filename, _ssgTexturePath, data->tfname ) ; GLuint texture_handle = _ssgShareTexture ( filename ) ; if ( texture_handle ) { /* Don't change the order of these two statements! */ st -> setTexture ( texture_handle ) ; st -> setTextureFilename ( filename ) ; st -> enable ( GL_TEXTURE_2D ) ; } else st -> disable ( GL_TEXTURE_2D ) ; st = _ssgShareState ( st ) ; vtab -> setState ( st ) ; } } else { _ssgShareReset () ; } return vtab ; } I agree that using ssgGetAppState will allow you to load other texture formats. But I think it should be phased out because: - ssgGetAppState has no access to the original ssgSimpleState - the leaf creation function is a more general solution - the redundancy will confuse new users of PLIB - removing ssgGetAppState will simplify the default _ssgCreateFunc --Dave McClurg |