EDIT: Unless there is something wrong with my FPS calculation, it seems like a blank screen will give me around 3000 to 5000 FPS, but if I draw even one small bit of text, it drops down to 20 FPS. Drawing a line does not seem to affect FPS.
I've only just now noticed that with each call to al_draw_text() my FPS drops dramatically. I noticed it when I had flashing "Press Enter" text, whenever the text was visible, an object that followed my mouse stuttered.
I can't think of anything that I might have done to cause this problem. I tried adding several more lines to draw "Main Menu" over and over and with each draw the FPS cut in half for each draw.
I believe this is all the applicable code:
Thanks for the help!
]]>Are you loading your fonts before al_create_display? They might be memory bitmaps. Show font and display creation code. All video bitmaps are attached to a display and if you haven't created a display you don't have anything to attach it to so they're memory bitmaps.
Or your problem is something else. What version of Allegro are you using? What platform are you on? What's your compiler?
]]>Thanks for the help! I would not have figured this out if you hadn't have brought up memory/video bitmaps!
EDIT2: I added "al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP);" before loading fonts and the problem disappeared! I'm guessing Allegro is defaulting to memory bitmaps for some reason? Or something I've done has changed the bitmap flags. Also I've just now noticed that lines 65 and 67 are using al_set_new_bitmap_flags rather than al_set_new_display_flags(). I haven't tested it yet, but I'm guessing that is the culprit.
I'm using Allegro 5.2.2 from NuGet in MSVC Express 2015. Windows 10.
The display is created inside "engine->draw_engine->init()", and then near the end of my game initialization I load a font to draw the FPS with
Here is essentially the program entry for my game:
And here is my disaster of window initialization!
I'm going to quickly write up a minimal program to see if I can recreate the issue.
EDIT: I've created a barebones program and I can call al_draw_text several hundred times per frame and still get 1000+ FPS using the exact same FPS calculation I am in my game. I must have done something wrong somewhere.
It's a good idea to initialize every addon before creating a display. Do that all in a single init function once before you use your engine. You call init, and then you create a font. In init you create a display, so the font should be attached to a display.
Also I've just now noticed that lines 65 and 67 are using al_set_new_bitmap_flags rather than al_set_new_display_flags(). I haven't tested it yet, but I'm guessing that is the culprit.
Yes, that's a problem. You should be calling al_set_new_display_flags there. Calling al_set_new_bitmap_flags with display flags is an error. There's a separate set of flags.
]]>