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 πβ¨ππ¦
π¦ 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