Exemple #1
0
void gtprintf(const Font& fnt, const Pixmap& texture, char *fmt, ...)
{
   va_list ap;
   uint32 x, y;
   int len;
   char ch;
   Pixmap *glyph;

   va_start(ap, fmt);
   vsprintf(gtBuffer, fmt, ap);
   va_end(ap);
   len = strlen(gtBuffer);

   for(int i = 0; i < len; i++)
   {
      ch = gtBuffer[i];
      if(ch == '\n')      gtY += fnt.nl_height;
      else if(ch == '\r') gtX = 0;
      else
      {
         glyph = fnt.find_glyph(ch);
         glyph->draw(gtX, gtY);
         gtX += glyph->width();
         if(gtX > 799)
         {
            gtX = 0;
            gtY += fnt.nl_height;
         }
      }
   }
}