LibAlleg does not have a guide on framerate-independent game logic, which makes removing the FPS cap difficult. No worries, I could do multithreading.

Except for some ungodly reason, the renderer is hard-capped at 60 frames per second, agnostic to my own code. This is "120"

I only found this out the hard way when my timescale math inadvertently caused the publisher intro to be twice as long instead of just being double the framerate.

At that time I had not implemented a delta timer because I was relying on Allegro's event timers for pacing, so I had no way of viewing the framerate until I took this screenshot. You can probably imagine the hours I wasted trying to fix my code not realizing what was happening.

*sigh* time to contact the IRC again...

framerate-independent game logic

You do game logic on "ticks" of a fixed length, often between 1 and 10 ms depending on the type of game. You keep a running accumulator of "tick time" which is the length of a tick times the number of ticks that have been simulated so far. At the beginning of the frame you subtract the tick time from the actual current game time and divide that number by the tick length to get the number of ticks you need to run sequentially before starting the frame. Each tick execution adds one tick length to the tick time accumulator.

If you want to "fast forward" or "slow down" the game, you don't change the tick length, you just scale the tick accumulator and difference number, causing you to run ticks more or less often.

Running any sort of logic with variable time scales can create strange numerical heisenbugs.

the renderer is hard-capped at 60

It's very possibly blocking on frame presents which are locked to the refresh rate on your system.

Follow

@gentoobro After talking with some Allegro experts and clearing things up I had decided that the built-in event timer is good enough for managing game logic. It abstracts all of the math involving timings for me. The reason I use my own delta time math here for the renderer, instead of creating a second Allegro timer for it, is so that I have enough control over it to monitor render performance.

Other OpenGL software runs at any framerate just fine and I have VSync off on Picom (my X11 compositor) so it might be an internal limitation. Have not tested on Windows yet.

Sign in to participate in the conversation
Game Liberty Mastodon

Mainly gaming/nerd instance for people who value free speech. Everyone is welcome.