- Online Community Forums » Programming Questions » AL5 + OpenGL - al_draw_text not working?

This thread is locked; no one can reply to it. rss feed Print
AL5 + OpenGL - al_draw_text not working?
Member #14,419
July 2012

Firstly: I'm confused about al_set_current_opengl_context() and what its purpose is. I'm not sure what the documentation is trying to say about it - its very vague saying that I "might need it" but gives no indication as to why, or when not to use it, etc...

Secondly: if I specifically set a target bitmap, will OpenGL not render to that bitmap?

I don't know where my target bitmap is when I'm rendering with OpenGL without setting a target, although when I flip_display it works fine - everything renders as expected. But when I use al_draw_text, regardless if I set_target_bitmap to backbuffer or not, it doesnt show up. I'm accustomed to simply setting target bitmap to display backbuffer but the al_set_current_opengl_context() manual entry has me confused about whether or not this is even available when using OpenGL?

I thought this may just be an issue with the projection matrix, so I disabled all of that but it still doesn't display anything...

I'm sure its another bonehead misunderstanding on my part...

Member #14,983
March 2013

Hi I'm also new to AL5+OpenGL but got that "al_draw_text" problem solved last day:

To draw 2D stuff you must first configure both matrix.

1 //at initialization code: 2 int resX=640, resY=480; 3 ALLEGRO_FONT* arialFont=al_load_ttf_font("arial.ttf", 18, 0);//copy arial.ttf or whatever to your exe folder 4 5 //at drawing routine: 6 //configure matrix to draw 2D STUFF 7 glMatrixMode(GL_PROJECTION); 8 glLoadIdentity(); 9 glOrtho(0.0, resX, resY, 0.0, -1.0, 10.0); 10 glMatrixMode(GL_MODELVIEW); 11 glLoadIdentity(); 12 glDisable(GL_CULL_FACE); 13 14 al_draw_text(arialFont,al_map_rgb(44, 117, 250 ), 50, 50, ALLEGRO_ALIGN_LEFT,"my text out"); 15 16 al_wait_for_vsync(); 17 al_flip_display(); 18 al_clear_to_color(al_map_rgb(0, 0, 0)); 19 //....

About the other issue you talk about... I can't help you sorry.

Erin Maus
Member #7,537
July 2006

al_set_current_opengl_context is only necessary if you create multiple OpenGL contexts, where one or more of them is "forward compatible," and need to switch between them. This means using OpenGL 3 or greater.

So, are you using an OpenGL 3 forward compatible context? E.g., do you pass ALLEGRO_OPENGL_3_0 to al_set_new_display_flags, and if so, do you also pass ALLEGRO_OPENGL_FORWARD_COMPATIBLE? If the answer is no, then do not worry about that method.

ItsyRealm, a quirky 2D/3D RPG where you fight, skill, and explore in a medieval world with horrors unimaginable.
they / she

Go to: