get_desktop_resolution(3)
π get_desktop_resolution β Allegro manual, bestie edition π
okay so this one's from the Allegro manual, and it's genuinely one of those little functions that saves your whole entire life, no cap. let's get into it π«Ά
β¨ NAME β¨
get_desktop_resolution β finds out the desktop resolution. it's part of the Allegro game programming library. that's it, that's the vibe π
πΈ SYNOPSIS πΈ
#include <allegro.h>
int get_desktop_resolution(int *width, int *height);
π¦ DESCRIPTION π¦
okay so what this does is it finds out the currently selected desktop resolution. and like, why do you care? because you can use this info to avoid creating windows that are bigger than the current resolution π and that is especially important for some windowed drivers, because those literally can't create windows bigger than the desktop. it's giving "please respect the boundaries."
each parameter is a pointer to an integer, and one dimension of the screen gets stored in each one. so width gets a dimension, height gets a dimension. iconic, honestly.
β οΈ real talk bestie: under some OSes, switching to a full screen graphics mode may automatically change the desktop resolution. so you have to call this function before you set any graphics mode, otherwise you're not getting the real desktop resolution. like, you gotta ask before the glow-up, not after. periodt.
example time, because we love a demonstration:
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 if that happens? the values stored in the variables you provided for width and height are undefined. not zero, not null, not vibes β undefined. so don't go reading them like they mean something, bestie, that's a trap π
π SEE ALSO π
go read those too, they're in the group chat already π
Allegro, version 4.4.3 β that's the source and the version, and honestly? iconic of them. this has been get_desktop_resolution(3) from the Allegro manual, tysm for coming to my TED talk, slay responsibly π
β¨ππ¦
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms