Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [AllegroGL] Transparent textout

Credits go to Bob for helping out!
This thread is locked; no one can reply to it. rss feed Print
[AllegroGL] Transparent textout
anto80
Member #3,230
February 2003
avatar

Hello all.

I'd like to display dynamic transparent text using AllegroGL.

I have searched inside the Allegro.cc search engine (keywords GL transparent text) but found nothing.

The piece of code is displaying the correct text, but with full opacity (alpha seems to be 255) whereas other GL sprites in my code can be displayed with correct transparency. What can I do?

glLoadIdentity();

glTranslatef(50.0, 50.0, 0.0);  
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  
allegro_gl_printf(fontGl, 0, 0, 0, 
    makeacol_depth(32, 255,255,255, 128), "TOTO");

allegro_gl_flip();

___________
Currently working on his action/puzzle game CIPHER PUSHER : Blocks/Vortexes/Seafood! Facebook - Twitter - webpage

Bob
Free Market Evangelist
September 2000
avatar

You should use allegro_gl_printf_ex(), and set the alpha channel value through glColor(). Also, did you call glEnable(GL_BLEND)?

--
- Bob
[ -- All my signature links are 404 -- ]

anto80
Member #3,230
February 2003
avatar

Quote:

Also, did you call glEnable(GL_BLEND)?

Yes, and moreover, as I said, other transparent (sprites) work.

Quote:

You should use allegro_gl_printf_ex(), and set the alpha channel value through glColor().

Thank you. I'll try and update the code here.

[edit]
Works perfectly! Thanks again!

The code is:

unsigned char cr, cg, cb, ca;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4ub(cr, cg, cb, ca);    
allegro_gl_printf_ex(f, 0, 0, 0, "%s", szBuf);

___________
Currently working on his action/puzzle game CIPHER PUSHER : Blocks/Vortexes/Seafood! Facebook - Twitter - webpage

Go to: