Beispiel #1
0
static bool FontLoader_LoadPage ( int id, const char *pageFile )
{
	SURFACE *psurf;

	if ( id > cur_pFont->pagecnt )
		return false;
	if(cur_fontdir[0]==0)
		psurf = loadtga ( ( char * ) pageFile );
	else
	{
		char fullname[1024];
		strcpy(fullname,cur_fontdir);
		strcat(fullname,pageFile);
		psurf = loadtga ( fullname );
	}

	if ( psurf == 0 )
	{
		return false;
	}

	cur_pFont->surfs[id] = psurf;

	if ( psurf->bpp == 8 )
	{
		EGL_COLOR rgb=MAKE_COLORREF(0,0,0);

		//black & white(text)
		if ( ( cur_pFont->alphaChnl == 0 ) && ( cur_pFont->redChnl == 4 ) && ( cur_pFont->greenChnl == 4 ) && ( cur_pFont->blueChnl == 4 ) )
		{
			rgb = MAKE_COLORREF ( 0xff, 0xff, 0xff );
		}
		//white & black(text)
		else if ( ( cur_pFont->alphaChnl == 0 ) && ( cur_pFont->redChnl == 3 ) && ( cur_pFont->greenChnl == 3 ) && ( cur_pFont->blueChnl == 3 ) )
		{
			rgb = MAKE_COLORREF ( 0, 0, 0 );
		}
		psurf->pixtype = PIX_FMT_A000;//only alpha
		psurf->pal->colors[0] = rgb; //white
	}

	return true;
}
Beispiel #2
0
bool TextureManager::loadtexture(std::string fname, std::string name)
{
        if ( fname.length() == 0 || name.length() == 0 ) return false;
        if ( textureexists(name) ) return false; // texture name has to be unique
        // TODO handle file types other than targa
        TGAFILE tgafile; // will scope out and delete the image data
        if ( !loadtga(fname.c_str(), &tgafile) )
                return false;
         // create texture
        textures[name] = new Texture(tgafile.imageData, tgafile.imageWidth, tgafile.imageHeight);
        return true;
}