PDA

View Full Version : Outlined OpenGl text like Google earth



potatosoftware
06-27-2011, 02:33 AM
Please is there a library or facility to draw outlined text like Google earth does ?

(Please tell me even if you know a commercial library)

Thank you in advance.
http://www.blogcdn.com/mobile.engadget.com/media/2010/02/google-earth-android.jpg

A.Conz
06-27-2011, 03:56 AM
try (windows only) wglusefontoutlines

potatosoftware
06-28-2011, 03:47 AM
Hi thanks so much, ok but i did not try this yet, but i looked into sample code and could not see a parameter specifying the extra color for the font outline.

after examination i concluded the function name is illusionary

A.Conz
06-28-2011, 06:42 AM
that's not true. with that func i can create wonderful things like these.

A.Conz
06-28-2011, 06:45 AM
try using the func combining WGL_FONT_POLYGONS with WGL_FONT_LINES and there u can have your font outline

Ilian Dinev
06-28-2011, 02:47 PM
Draw the text 2 times (actually 9 or 10)
first, 8 or 9 times with black color, and offsets {-1;0;1} pixels
then, finally draw the text in white color.

Before:


void DrawShadowed(int x,int y,const char* text){
DrawText(x,y,text,0xFFFFFF);
}

After:



void DrawShadowed(int x,int y,const char* text){
for(int i=-1;i<=1;i++)
for(int j=-1;j<=1;j++)
DrawText(x+i,y+j,text,0x000000);
DrawText(x,y,text,0xFFFFFF);
}




Alternatives use blurred versions of the font-texture, or precalculated outlined font-textures (which don't look good sometimes)

mbentrup
06-29-2011, 12:33 AM
If you want to use font textures, you should read this paper:

http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf

With a simple fragment shader you can render the interior and the outlines in a single pass.

tksuoran
06-29-2011, 03:31 AM
You can render text glyphs using textured quads with (premultiplied) alpha blending. You need separate alpha and colour (or luminance) channels. Texels that are "in" the glyph you can have white colour and alpha 1.0. At outline you can have black colour, alpha 1.0. Beyond outline, where you should see through, have colour black, alpha 0.0.

You can generate this kind of font textures easily with a free tool from here: http://www.angelcode.com/products/bmfont/

Alfonse Reinheart
06-29-2011, 05:26 AM
Premultiplied alpha? Sorry, but Valve wins. They're stuff is so far beyond premultiplied alpha that it's not funny.

potatosoftware
07-01-2011, 06:45 AM
Jesus Christ! I am still struggling to make the text show up at a specific 3 position. Too impatient to see what it can give.

potatosoftware
07-01-2011, 06:47 AM
@mbentrup
the text pictures in that document are just so crazy!
But with no source code or example applications I can inspire from, it makes me just more sad.

Ffelagund
07-03-2011, 01:29 PM
If you ONLY want render text like in the google earth's image, use a bitmap with all characters into. It's far the easiest, faster (and simplest) way to render text, moreover if you have to render tons of characters. Dont try a very high quality and gpu eater method if you dont need to.

This way doesn't even need shaders, so it's up to choose a fast or a HQ method. It depends on your needs.