Drawing text with shadow in OpenGL + FTGL -


i'm drawing text in opengl using ftgl library , works fine, add shadow text. tried drawing same text black color , draw text above normal color (pseudocode):

glcolor3f(0, 0, 0); // outline color drawtext(x-1, y-1, str); drawtext(x+1, y-1, str); drawtext(x+1, y+1, str); drawtext(x-1, y+1, str); glcolor3f(1, 1, 1); // primary color drawtext(x,y,str); 

but have draw text 5 times , still not good.

i on screenshot

text shadow

there lot of ways achieve - higher quality others.

here's do:

  1. render text in-memory grayscale pixmap.
  2. perform gaussian blur on (probably using fast library such qimageblitz or imagemagick). blur radius should 2-3px.
  3. apply steep tone-curve blurred image, luminance range [0.0, 0.9] mapped 0.0. makes stop being blurry, , result "fattened" version of text. tone curve should this:

    alt text

  4. render shadow, in black (using appropriate blending mode emulate alpha-blending). render regular yellow text on top of (with small offset of choice).

also, can use different tone-curves depending on how soft shadow want. linear tone-curve give soft shadow.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -