VIRTUAL_W(3alleg4)

πŸ’– VIRTUAL_W, VIRTUAL_H πŸ’–

okay bestie, so this is a page from the Allegro manual β€” yes, the Allegro game programming library, the one that makes your little game go brrr on screen πŸŽ€ β€” and today we're talking about two global defines that tell you how big your screen situation actually is.


✨ SYNOPSIS ✨

#include <allegro.h>

#define VIRTUAL_W;

#define VIRTUAL_H;

πŸ¦‹ DESCRIPTION πŸ¦‹

so, VIRTUAL_W and VIRTUAL_H are global defines that hand you back the width and height of the virtual screen respectively. that's it. that's the whole job. πŸ’…

⚠️ and if the screen hasn't been initialised yet? they give you zero. like, nothing. no screen, no numbers, just a sad little 0. so don't go trusting them before you've actually set up your graphics mode, okay? 😭

here's the example they give, and it's lowkey iconic:

char buf[100];
...
uszprintf(buf, sizeof(buf),
          "The virtual screen size is %d x %d pixels",
          SCREEN_W, SCREEN_H);

see how it's stuffing the screen size into a buffer with uszprintf? main character energy fr fr 🌸


πŸ‘‘ SEE ALSO πŸ‘‘

like, if you're here you probably also wanna peek at those. iykyk 🫢


and that's the whole vibe, bestie! this was Allegro, version 4.4.3, living in the alleg4 manual section. go forth and measure your screens responsibly πŸ’–βœ¨πŸŽ€πŸ¦‹