//----------------------------------------------------------------//
void MOAIStaticGlyphCache::SetImage ( MOAIFont& font, MOAIImage& image ) {

	this->ClearTextures ();

	u32 width = image.GetWidth ();
	u32 height = image.GetHeight ();

	if ( !( width && height )) return;

	u32 totalTextures = ( height / width ) + 1;
	this->mTextures.Init ( totalTextures );
	
	u32 y = 0;
	for ( u32 i = 0; i < totalTextures; ++i ) {
		
		MOAITexture* texture = new MOAITexture ();
		this->mTextures [ i ] = texture;
		
		u32 textureHeight = height - y;
		textureHeight = textureHeight > width ? width : textureHeight;
		
		texture->Init ( image, 0, y, width, textureHeight, font.GetFilename ());
		texture->SetFilter ( GL_LINEAR, GL_LINEAR );
		
		y += textureHeight;
	}
}
Ejemplo n.º 2
0
//----------------------------------------------------------------//
void MOAIGlyphCachePage::AffirmCanvas ( MOAIFont& font ) {
	
	if ( !this->mImageTexture ) {
		
		this->mImageTexture = new MOAIImageTexture ();
		this->mImageTexture->Init ( MAX_TEXTURE_SIZE, this->mRows.mSize, this->mColorFormat, USPixel::TRUECOLOR );
		this->mImageTexture->SetDebugName ( font.GetFilename ());
		this->mImageTexture->SetFilter ( GL_LINEAR, GL_LINEAR );
		this->mImageTexture->ClearBitmap ();
	}
	else if ( this->mImageTexture->MOAIImage::GetHeight () < this->mRows.mSize ) {
		
		USIntRect rect;
		rect.Init ( 0, 0, MAX_TEXTURE_SIZE, this->mRows.mSize );
		this->mImageTexture->ResizeCanvas ( *this->mImageTexture, rect );
		this->mImageTexture->Invalidate ();
	}
}