0

I have a problem with my Allegro 5 code. It has three, sections, a section that checks for inputs, then a section that runs every 1/30th of a second with a timer, and a graphics drawing section.

The program begins, spawns all the objects on the screen (5 objects) as bitmaps, and then the timed section updates the bitmap's width values so they appear to 'spin'. In reality they are 'squishing'.

There is no issue with the code, it runs just fine for about 100 cycles, and then the bitmaps appear to noticeably slow down, and then get slower until the program has eaten all the memory and you have to hold the power button down on the computer. It takes a few hours to get that bad, however.

I am not loading the bitmaps before the display is created. I am telling it to use openGL and I have verified that it is drawing on the GPU. I would post the code but it is 800 lines (There are lots of other functions implemented in the game.)

I am using C and Code::Blocks.

Pulling my hair out, can't find anyone else having the same issue as me. Any help appreciated.

Here is a video of the program running: https://youtu.be/BgMRDJ9Vq8w

Alex

Alex W
  • 1
  • 1

1 Answers1

0

Right! The issue was simple. Inside the main loop I was calling the following 7,200 times a minute.

char pathtofont[300]="data/fixed_font.tga";

al_init_font_addon();

GLOBAL_FONT = al_load_font(pathtofont, 0, 0);

These lines are the contents of GFX_InitFont();

GFX_InitFont(); Moved just outside main loop

Alex W
  • 1
  • 1
  • We're glad you were able to solve your own problem, but if this thread is to be useful to anyone else in the future it needs to have details about what was going wrong and what your solution did to fix it, otherwise it's just taking up space – Willis Hershey Apr 18 '22 at 14:59
  • have it deleted then. – Alex W Apr 18 '22 at 19:20
  • I'd rather the post be edited to make it useful – Willis Hershey Apr 18 '22 at 19:27
  • I am sorry but I don't have time. If I was searching for this problem, I would have found it by the question key words and been able to make a fast deduction from the posts. I hope others having problems with Allegro 5 taking a performance penalty can do the same. Again my apologies. – Alex W Apr 18 '22 at 20:33