Enable display of pictures without having them to

add to materials.dat (fixes bug 1781997).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1224 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2007-08-27 13:11:06 +00:00
parent 40799d02bd
commit b26d4f6db8
4 changed files with 32 additions and 20 deletions

View File

@ -60,6 +60,8 @@ GameManager::~GameManager()
//-----------------------------------------------------------------------------
void GameManager::run()
{
const GLuint TITLE_SCREEN_TEXTURE =
material_manager->getMaterial("st_title_screen.rgb")->getIndex();
while(!m_abort)
{
// Run input processing.
@ -129,7 +131,7 @@ void GameManager::run()
// usleep(2000);
#endif
//Draw the splash screen
glBindTexture(GL_TEXTURE_2D,material_manager->getMaterial("st_title_screen.rgb")->getIndex());
glBindTexture(GL_TEXTURE_2D,TITLE_SCREEN_TEXTURE);
glBegin ( GL_QUADS ) ;
glColor3f (1, 1, 1 ) ;

View File

@ -87,7 +87,7 @@ Material::Material ()
}
//-----------------------------------------------------------------------------
Material::Material ( char *fname, char *description )
Material::Material (const char *fname, char *description )
{
m_texname = new char [ strlen ( fname ) + 1 ] ;
strcpy ( m_texname, fname ) ;
@ -95,19 +95,21 @@ Material::Material ( char *fname, char *description )
init () ;
m_clamp_tex = parseBool ( & description ) ? UCLAMP : 0 ;
m_clamp_tex += parseBool ( & description ) ? VCLAMP : 0 ;
m_transparency = parseBool ( & description ) ;
m_alpha_ref = parseFloat ( & description ) ;
m_lighting = parseBool ( & description ) ;
m_sphere_map = parseBool ( & description ) ;
m_friction = parseFloat ( & description ) ;
m_ignore = parseBool ( & description ) ;
m_zipper = parseBool ( & description ) ;
m_resetter = parseBool ( & description ) ;
m_collideable = parseBool ( & description ) ;
if(strlen(description)>0)
{
m_clamp_tex = parseBool ( & description ) ? UCLAMP : 0 ;
m_clamp_tex += parseBool ( & description ) ? VCLAMP : 0 ;
m_transparency = parseBool ( & description ) ;
m_alpha_ref = parseFloat ( & description ) ;
m_lighting = parseBool ( & description ) ;
m_sphere_map = parseBool ( & description ) ;
m_friction = parseFloat ( & description ) ;
m_ignore = parseBool ( & description ) ;
m_zipper = parseBool ( & description ) ;
m_resetter = parseBool ( & description ) ;
m_collideable = parseBool ( & description ) ;
}
install () ;
}
@ -157,7 +159,7 @@ void Material::install ()
if ( m_texname != NULL && m_texname [ 0 ] != '\0' )
{
std::string fn=std::string("images")+DIR_SEPARATOR+m_texname;
m_state -> setTexture ( loader->getPath(fn.c_str()).c_str(), !(m_clamp_tex & UCLAMP),
m_state -> setTexture ( loader->getPath(fn).c_str(), !(m_clamp_tex & UCLAMP),
!(m_clamp_tex & VCLAMP) );
m_state -> enable ( GL_TEXTURE_2D ) ;
}

View File

@ -54,7 +54,7 @@ class Material
public:
Material () ;
Material ( char *fname, char *description ) ;
Material (const char *fname, char *description ) ;
~Material ();

View File

@ -187,7 +187,6 @@ Material *MaterialManager::getMaterial ( const char* fname )
char basename [ 1024 ] ;
strcpy ( basename, fn ) ;
free(fname_copy);
/* Remove last trailing extension. */
@ -231,13 +230,22 @@ Material *MaterialManager::getMaterial ( const char* fname )
if ( *fn2 == '.' )
*fn2 = '\0' ;
fflush(stdout);
if ( strcmp ( basename, basename2 ) == 0 )
{
free(fname_copy);
return m_materials[i] ;
}
}
}
return NULL ;
// Add the material: the material constructor adds the material
// to (this) material_manager.
Material* m=new Material(fn,"");
// Since fn is a pointer into fname_copy, fname_copy must be freed
// here, not earlier.
free(fname_copy);
return m ;
}
//=============================================================================