[AllegroGL] Transparent textout
anto80

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();

Bob

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

anto80
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);

Thread #587439. Printed from Allegro.cc