I'm making a set of functions to produce console-like output for SDL. The font is made from a binary mask but I am having problems getting it to display properly. Heres an example of it printing the string"0123456789ABCDE" :
http://i92.photobucket.com/albums/l1...l/deleteme.png
Its partly readable but somethings definitely wrong. The constructor for the class takes a character map, and the data. This is run here in my prog:
Code:
BitText txt( "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"mprtxpmckccccmmp`acg~mp`e`pmaeiq~aa~oom`pmego}ppm~``acgomppmppmmppn`ak"
"cipp~pp}pp}pp}mpooopm}ppppp}~oo}oo~~oo}ooompoorpnppp~pppmcccccm~aaaqqk"
"pqswsqpoooooo~pztppppppxtrppmpppppm}pp}ooomppptrn}pp}sqpmpom`pm~cccccc"
"ppppppmpppppicppppttippicipppppiccc~`acgo~" );
Heres what the constructor does with it:
Code:
BitText::BitText(const char* char_map, const char* char_data)
{
int len = (int)strlen(char_map);
map = new char[len];
strcpy(map, char_map);
len = (int)strlen(char_data);
data = new char[len];
strcpy(data, char_data);
col = 0xFFFFFFFF;
}
And heres the function to print text to the screen:
Code:
void BitText::Print(Uint16 x_pos, Uint16 y_pos, const char* text)
{
int x, y, bit, pos;
char* ptr;
for(int i=0; i<(int)strlen(text); i++)
{
//Get the coresponding character in the character map
for(ptr=map, pos=0; *ptr; ptr++, pos++)
if(*ptr == text[i]) break;
//Get the characters data start point
ptr = data +(pos*7);
//Draw character
for(y=0; y<7; y++)
{
bit=16;
for(x=0; x<5; x++, bit >>= 1)
if(*ptr & bit)
WritePixel(x_pos+x, y_pos+y, this->col);
ptr++; //Move to data byte holding next scanline of the character
}
x_pos+=6;
}
}
I'm pretty sure the mistake is in this last function. Can someone see whats going wrong here? I can't Hopefully thats all the relevant code here.