Improved black border effect for title font

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4531 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-01-24 16:48:13 +00:00
parent f2e2a37407
commit 3920dfe101
4 changed files with 19 additions and 6 deletions

View File

@@ -178,12 +178,15 @@ void IrrDriver::initDevice()
#if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR >= 7)
video::SMaterial& material2D = m_video_driver->getMaterial2D();
material2D.setFlag(video::EMF_ANTI_ALIASING, true);
for (unsigned int n=0; n<MATERIAL_MAX_TEXTURES; n++)
{
material2D.TextureLayer[n].BilinearFilter = true;
//material2D.TextureLayer[n].TextureWrap = ETC_CLAMP_TO_EDGE;
material2D.TextureLayer[n].TextureWrapU = ETC_CLAMP_TO_EDGE;
material2D.TextureLayer[n].TextureWrapV = ETC_CLAMP_TO_EDGE;
material2D.TextureLayer[n].LODBias = 8.0f;
}
material2D.AntiAliasing=video::EAAM_FULL_BASIC;
//m_video_driver->enableMaterial2D();

View File

@@ -27,6 +27,8 @@ ScalableFont::ScalableFont(IGUIEnvironment *env, const io::path& filename)
m_fallback_font_scale = 1.0f;
m_fallback_kerning_width = 0;
m_black_border = false;
#ifdef _DEBUG
setDebugName("ScalableFont");
#endif
@@ -517,7 +519,7 @@ void ScalableFont::draw(const core::stringw& text, const core::rect<s32>& positi
video::SColor color, bool hcenter, bool vcenter, const core::rect<s32>* clip)
{
if (!Driver) return;
if (m_shadow)
{
m_shadow = false; // avoid infinite recursion
@@ -677,10 +679,10 @@ void ScalableFont::draw(const core::stringw& text, const core::rect<s32>& positi
}
}
if (fallback[n])
if (m_black_border)
{
// draw black border
static video::SColor black(255,0,0,0);
video::SColor black(color.getAlpha(),0,0,0);
video::SColor black_colors[] = {black, black, black, black};
for (int x_delta=-2; x_delta<=2; x_delta++)
@@ -695,10 +697,13 @@ void ScalableFont::draw(const core::stringw& text, const core::rect<s32>& positi
black_colors, true);
}
}
}
if (fallback[n])
{
// draw text over
static video::SColor orange(255, 255, 100, 0);
static video::SColor yellow(255, 255, 220, 15);
static video::SColor orange(color.getAlpha(), 255, 100, 0);
static video::SColor yellow(color.getAlpha(), 255, 220, 15);
video::SColor title_colors[] = {yellow, orange, orange, yellow};
driver->draw2DImage(texture,
dest,
@@ -720,6 +725,8 @@ void ScalableFont::draw(const core::stringw& text, const core::rect<s32>& positi
void ScalableFont::lazyLoadTexture(int texID)
{
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
// load texture
SpriteBank->setTexture(texID, Driver->getTexture( m_texture_files[texID].m_file_name ));

View File

@@ -46,6 +46,8 @@ class ScalableFont : public IGUIFontBitmap
void lazyLoadTexture(int texID);
public:
bool m_black_border;
ScalableFont* m_fallback_font;
float m_fallback_font_scale;
int m_fallback_kerning_width;

View File

@@ -216,6 +216,7 @@ void init(IrrlichtDevice* device_a, IVideoDriver* driver_a, AbstractStateManager
sfont2->m_fallback_kerning_width = 15;
sfont2->setScale(title_text_scale);
sfont2->setKerningWidth(-18);
sfont2->m_black_border = true;
g_title_font = sfont2;