TGB Anti-Aliased Font
by Alexandre Ribeiro de Sa · 05/06/2009 (3:37 pm) · 7 comments
gTexManager.h : Line 368
Include
gTexManager.cc : Line 1479
Include
gFont.cc : Line 186
Replace
gFont.cc : Line 433
Replace
gNewFont.cc : Line 636
Replace
gNewFont.cc : Line 958
Replace
Compile both TGBGame and TorqueGameBuilder with our new code.
Include
void setFilterLinear();
gTexManager.cc : Line 1479
Include
void TextureHandle::setFilterLinear()
{
if (object)
{
object->filterNearest = true;
if(object->texGLName != 0)
{
glBindTexture(GL_TEXTURE_2D, object->texGLName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
}
}gFont.cc : Line 186
Replace
mTextureSheets[i].setFilterNearest();To
mTextureSheets[i].setFilterLinear();
gFont.cc : Line 433
Replace
mTextureSheets[i].setFilterNearest();To
mTextureSheets[i].setFilterLinear();
gNewFont.cc : Line 636
Replace
handle.setFilterNearest();To
handle.setFilterLinear();
gNewFont.cc : Line 958
Replace
mTextureSheets.last().setFilterNearest();To
mTextureSheets.last().setFilterLinear();
Compile both TGBGame and TorqueGameBuilder with our new code.
About the author
now with an iPod :D
Recent Blogs
• My Country, My Name - Part I• T2.5D! Part Deux
• T2D to T"3D"
• memo_ando
• Playable alpha in Sao Paulo
#2
DO NOT USE WITH TGEA! I don't know what can happen!
05/06/2009 (5:46 pm)
No, this resource is just for the Torque Game Builder (2D) t2dTextComponent...DO NOT USE WITH TGEA! I don't know what can happen!
#3
05/06/2009 (6:56 pm)
Well it would take porting to get this in TGEA but in a nutshell it would smooth out the edges of the font so it looks smoothe and not jagged. It looks like this could drop in TGE though or am i wrong?
#4
05/07/2009 (7:12 am)
Isn't this code enabling bilinear filtering? The fonts are already antialised.
#5
Antialiasing happens when you minify; http://en.wikipedia.org/wiki/Anti-aliasing
Biliner filtering is only meaningful when you magnify; http://en.wikipedia.org/wiki/Bilinear_filtering
Normally the font renderer draws fonts so that there is exactly one pixel of font data for each pixel on-screen. Nearest will give you more correct results in this scenario.
But if you are using fonts in fancy rendering scenarios (like as a T2D scene object where it is scaled/rotated) then this won't work right and you'll want to turn on bilinear filtering.
05/07/2009 (3:13 pm)
Manoel is right. Bilinear filtering is not the same as antialiasing.Antialiasing happens when you minify; http://en.wikipedia.org/wiki/Anti-aliasing
Biliner filtering is only meaningful when you magnify; http://en.wikipedia.org/wiki/Bilinear_filtering
Normally the font renderer draws fonts so that there is exactly one pixel of font data for each pixel on-screen. Nearest will give you more correct results in this scenario.
But if you are using fonts in fancy rendering scenarios (like as a T2D scene object where it is scaled/rotated) then this won't work right and you'll want to turn on bilinear filtering.
#6
First, how the T2DTextObject for Torque Game Buildes work, this component use a texture map with the characters to draw the text, something like NeHe's 2D Texture Font.
Ok, this isn't a problem, this a great solution if you like to create some effects in your texts, but the great problem is the filter, by default the filter is the nearest neighbor and the result is very, very, very and very disgusting, and to create a text with a good resolution you will need a giant texture, and like Ben said, you can rotate and scale this component and the result is a BIG disaster too!!!
Second, now about this resource, I made this resource just to say what you need to do to change the filter to Bilinear, and yes, I know, this isn't a real anti-aliasing, but with this filter you can write some text in a good resolution (in many screen resolutions) with a "small" texture with a nice result with rotation and scale...
And remember, this resource is just for the Torque Game Builder, the 2D engine... Thanks for all the comments and I hope I've solved some questions about this resource, but if you have some, please, post here :)
05/09/2009 (8:10 pm)
Hello everyone, ok, I'll try to explain what I mean with "Anti-Aliasing".First, how the T2DTextObject for Torque Game Buildes work, this component use a texture map with the characters to draw the text, something like NeHe's 2D Texture Font.
Ok, this isn't a problem, this a great solution if you like to create some effects in your texts, but the great problem is the filter, by default the filter is the nearest neighbor and the result is very, very, very and very disgusting, and to create a text with a good resolution you will need a giant texture, and like Ben said, you can rotate and scale this component and the result is a BIG disaster too!!!
Second, now about this resource, I made this resource just to say what you need to do to change the filter to Bilinear, and yes, I know, this isn't a real anti-aliasing, but with this filter you can write some text in a good resolution (in many screen resolutions) with a "small" texture with a nice result with rotation and scale...
And remember, this resource is just for the Torque Game Builder, the 2D engine... Thanks for all the comments and I hope I've solved some questions about this resource, but if you have some, please, post here :)
#7
very useful resource, it is exactly what I was searching for. :-)
I just modified a parameter in the setFilterLinear method from
to
Many thanks for sharing.
01/08/2010 (8:58 am)
Hi Alexandre,very useful resource, it is exactly what I was searching for. :-)
I just modified a parameter in the setFilterLinear method from
object->filterNearest = true;
to
object->filterNearest = false;
Many thanks for sharing.

Torque Owner DreamPharaoh
Gods and Nemesis