Game Development Reference
In-Depth Information
Listing 6-22. Setting the Text for Rendering
void SetText(char[] Text)
{
String TextStr = new String(Text);
TextStr = TextStr.toLowerCase();
m_Text = TextStr.toCharArray();
for (int i = 0; i < m_Text.length; i++)
{
BillBoardFont Character = FindBillBoardCharacter(m_Text[i]);
if (Character != null)
{
m_TextBillBoard[i] = Character;
}
else
{
Log.e("CHARACTER SET ERROR" , "SETTEXT ERROR , " + m_Text[i] + "
NOT FOUND!!!!!");
}
}
}
The DrawFontToComposite() function copies the bitmap image in the BillBoardFont object Obj into
the bitmap image on the BillBoard object Composite , starting at location X , Y. The width of the
destination texture in the Composite variable is also tested to make sure that the source texture fits
into the destination texture. (See Listing 6-23.)
Listing 6-23. Drawing a Font from the Character Set to a BillBoard Object
void DrawFontToComposite(BillBoardFont Obj, int X, int Y, BillBoard Composite)
{
Texture TexSource = Obj.GetTexture(0);
Bitmap BitmapSource = TexSource.GetTextureBitMap();
int BitmapSourceWidth = BitmapSource.getWidth();
Texture TexDest = Composite.GetTexture(0);
Bitmap BitmapDest = TexDest.GetTextureBitMap();
int BitmapDestWidth = BitmapDest.getWidth();
// Put Sub Image on Composite
int XEndTexture = X + BitmapSourceWidth;
if (XEndTexture >= BitmapDestWidth)
{
Log.e("BillBoardCharacterSet::DrawFontToComposite" , "ERROR Overwriting Dest Texture,
Last X Position To Write = " + XEndTexture + ", Max Destination Width = " + BitmapDestWidth);
}
else
{
TexDest.CopySubTextureToTexture(0, X, Y, BitmapSource);
}
}
 
Search WWH ::




Custom Search