Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a game with Allegro 5 that has a loop. I'd like to make the program write onto the screen, how much time the loop has ended. These are the rounds of a turn-based game, obviously. I use the al_draw_textf function for it, which works perfectly, but I put it into the loop. Its consequence is obviously that the number is written on the same place all the time.

To prevent it, I should delete it at the beginning of every loop. Sadly, I couldn't find any functions in Allegro Manual that does it. How can I do that then?

share|improve this question
up vote 0 down vote accepted

Typically, you would do a Clear Screen before starting your subsequent Draws, otherwise all your drawings would remain on screen and overlap.

With Allegro, you will need to clear the bitmap you are drawing to before you draw to the screen. I haven't used Allegro in a very long time, so I may be wrong about this.

share|improve this answer
I've never used bitmaps in Allegro, my game contains only rectangles with different colours - yet. Anyway, I can't use al_clear_to_color, because I defined most of the graphic elements before the loop begins, and when it starts, the mentioned function clears the already defined elements. Also, I don't want to redraw every elements in every rounds, because that'd make the program way too slow. – Zoltán Schmidt May 23 '13 at 14:39
Its an old post and everything... But I had the need to correct this: Allegro 5 recommends to clear the screen every time you draw as it is hardware accelerated, there is no need to try to preserve previous surface drawings as current graphics card fill rates are high enough to support this – rlam12 Sep 21 '15 at 14:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.