request_refresh_rate(3alleg4)

✨ request_refresh_rate β€” the manual page, but make it cute ✨

okay bestie, pull up a chair, we're reading the request_refresh_rate(3alleg4) page from the Allegro manual together and honestly? it's giving "small function, big opinions" πŸ’… this one lives in the Allegro game programming library, and it's the lil guy you call when you want your game to run at a specific refresh rate. no cap.


🌸 NAME 🌸

request_refresh_rate β€” requests a specific refresh rate during graphic mode switch. Allegro game programming library.

like. that's the whole job description. she requests. she does not guarantee. we'll get to that 😭


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

void request_refresh_rate(int rate);

that's it. one function, one int, zero drama (until the hardware says no).


πŸ’– DESCRIPTION πŸ’–

So here's the tea πŸ“: request_refresh_rate asks that the next call to set_gfx_mode() try to use the refresh rate you specified, if possible.

And babes, underline "if possible" like three times, because:

  • not all drivers are able to control this at all πŸ™ˆ
  • and even when they can, not all rates will be possible on all hardware
  • so the actual settings may differ from what you requested

it's not a demand, it's a request. hence the name. the function was honest with you from day one, we love a self-aware queen πŸ‘‘

After you call set_gfx_mode(), you can use get_refresh_rate() to find out what was actually selected. that's your vibe check on reality. do not skip it, fr fr.

At the moment only the DOS VESA 3.0, X DGA 2.0 and some Windows DirectX drivers support this function. so if you're on something else, she's just out here asking nicely into the void 🌈

The speed is specified in Hz, eg. 60, 70. and to return to the normal default selection, pass a rate value of zero. that's your "never mind, forget I said anything" button πŸŽ€

Example, because we're visual learners:

request_refresh_rate(60);
if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0)
   abort_on_error("Couldn't set graphic mode!");
if (get_refresh_rate() != 60)
   abort_on_error("Couldn't set refresh rate to 60Hz!");

see how she requests 60, sets the mode, and then checks with get_refresh_rate()? that's the whole personality of this function in four lines. iconic behavior, truly. main character energy but make it defensive programming πŸ’€βœ¨

⚠️ real talk though: never assume your rate landed. always ask get_refresh_rate() what actually happened, because the hardware might've picked something else entirely and you'd never know.

πŸ”₯ SEE ALSO πŸ”₯

go read those next, they're the other two-thirds of this friend group 🫢


and that's the page!! this whole thing came out of Allegro version 4.4.3, so shoutout to the Allegro girlies for keeping the request_refresh_rate(3alleg4) lore alive 🌟 k bye, go set your refresh rate bestie πŸ’œ