Example #1
0
void DefBillb(int i, unsigned int glyph)
{
#if 0
	//BillboardT t;
	int i = NewBillbT();
	if(i < 0)
		return -1;
#endif

	BillboardT* t = &g_billbT[i];
	t->on = true;

#if 0
	char rawtex[64];
	StripPathExtension(tex, rawtex);
	strcpy(t->name, rawtex);
	char texpath[128];
	sprintf(texpath, "billboards/%s", rawtex);
	FindTextureExtension(texpath);
	//CreateTexture(t.tex, texpath);
	QueueTexture(&t->tex, texpath, true, true);
#elif 0
	QueueTexture(&t->tex, tex, true, true);
#else
	t->glyph = glyph;
#endif
	//g_billbT.push_back(t);
	//return g_billbT.size() - 1;
	//return i;
}
Example #2
0
void LoadFont(int id, const char* fontfile)
{
    CFont* f = &g_font[id];
	char texfile[128];
	char raw[64];
	StripPathExtension(fontfile, raw);
	sprintf(texfile, "fonts/%s", raw);
    f->tex = CreateTexture(texfile);
    f->width = g_texwidth;
    f->height = g_texheight;

	char fullfont[128];
	sprintf(fullfont, "fonts/%s.fnt", raw);
    
    //FILE* fp = fopen(fullfont, "r");
	CFile fp(fullfont);

    //if(!fp)
	//if(fp.fsize <= 0)
	if(!fp.mFile)
    {
        LOGE("Error loading font %s", fontfile);
        return;
    }
    
    //fseek(fp, 0, SEEK_END);
	//fp.seekend();
    //int size = fp.tell(); //ftell(fp);
    //rewind(fp);
	//fp.seek(0);
	//int size = fp.fsize;
	int size = fp.remain();
    
    //char* file = (char*)fp.data; //new char[size];
	char* file = new char[size+1];
    fp.read((void*)file, size);
	file[size] = '\0';
    //fclose(fp);
    
    //NSLog(@"%s", file);

	//LOGI("font %s size=%d", fontfile, size);
	//LOGI("%s", file);
    
    int i;
    string substr;
    int x, y, w, h, j;
    
    for(i = 0; i<size; i++)
    {
        substr = "";
        
        //skip whitespace
        for(; i<size; i++)
            if(file[i] != ' ' && file[i] != '\n' && file[i] != '\r' && file[i] != '\t')
                break;
        
        //write directive
        for(; i<size; i++)
        {
            if(file[i] == ' ' || file[i] == '\n' || file [i] == '\r' || file[i] == '\t' || file[i] == '=')
                break;
            
            substr += file[i];
        }
        
        i++;
        
        if(!stricmp(substr.c_str(), "[HGEFONT]"))
            continue;
        else if(!stricmp(substr.c_str(), "Bitmap"))
        {
            //skip the file name
            for(; i<size; i++)
                if(file[i] == ' ' || file[i] == '\n' || file [i] == '\r' || file[i] == '\t')
                    break;
            continue;
        }
        else if(!stricmp(substr.c_str(), "Char"))
        {
            substr = "";
            
            for(; i<size; i++)
            {
                if(file[i] == '\n' || file [i] == '\r')
                    break;
                
                substr += file[i];
            }
            
            FSub(substr.c_str(), j, x, y, w, h);
            
            CGlyph* g = &f->glyph[j];
            g->x = x;
            g->y = y;
            g->w = w;
            g->h = h;
        }
    }
    
    f->gheight = f->glyph['A'].h;
    
    delete [] file;
    LOGI("%s.fnt", fontfile);
}