get_desktop_resolution(3alleg4)
β¨ get_desktop_resolution β¨
okay bestie, welcome to the allegro4 corner of the manual π this one's called get_desktop_resolution and it's literally just "hey, what resolution is the desktop rn?" β and it's from the Allegro game programming library, iykyk π
πΈ NAME πΈ
get_desktop_resolution β finds out the desktop resolution. Allegro game programming library. no cap, that's the whole job π«Ά
π¦ SYNOPSIS π¦
#include <allegro.h>
int get_desktop_resolution(int *width, int *height);
π DESCRIPTION π
So like, this function finds out the currently selected desktop resolution. Why do you care? Because you can use this info to avoid creating windows that are bigger than the current resolution β and honestly that's such a main character move. It's especially important for some windowed drivers that literally can't create windows bigger than the desktop. not their fault, they're just built different π
Each parameter is a pointer to an integer, and one dimension of the screen gets stored in each one. width in *width, height in *height, slay π
β οΈ Under some OSes, switching to a full screen graphics mode may automatically change the desktop resolution. The way that means you have to call this function before setting any graphics mode in order to retrieve the real desktop resolution. Don't skip this step bestie, it's giving "I forgot and now my numbers are lies" π
Example, because examples are iconic:
int width, height;
allegro_init();
...
if (get_desktop_resolution(&width, &height) == 0) {
/* Got the resolution correctly */
}
β RETURN VALUE β
Returns zero on success π or a negative number if this information is not available or does not apply. And in that case? The values stored in the variables you provided for width and height are undefined β like, genuinely undefined, not "undefined but probably fine". Do not trust them. Periodt π
π SEE ALSO π
okay that's the whole vibe check, go forth and not make windows bigger than the desktop π§π
Allegro, version 4.4.3 β that's the version and it's the one this page is from, and the date? it's on the original footer line next to the manual name get_desktop_resolution(3alleg4), so consider this your lil' sign-off: Allegro version 4.4.3, get_desktop_resolution(3alleg4), mwah π bye bestie, drink water π
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms