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 πŸ“