screen(3alleg4)
π screen π
okay bestie, so this is a page from the Allegro manual β the game programming library β and today's main character is screen. yes, lowercase, yes, iconic. let's go π«Ά
β¨ NAME β¨
screen β the global pointer to the screen hardware video memory. Allegro game programming library. she's famous, she's everywhere, she's literally the whole display. π
πΈ SYNOPSIS πΈ
#include <allegro.h>
extern BITMAP *screen;
that's it. that's the girl. one pointer, zero drama (well, mostly).
π¦ DESCRIPTION π¦
so screen is a global pointer to a bitmap, sized VIRTUAL_W x VIRTUAL_H. it gets created for you by set_gfx_mode(), and it represents the hardware video memory. periodt. β¨
here's the tea though β only a part of that bitmap is actually visible, and that visible part is sized SCREEN_W x SCREEN_H. normally it's the top-left corner of the bigger virtual screen, so if you're not into hardware scrolling or page flipping, you can literally just ignore the extra invisible virtual size of the bitmap. not your problem, bestie. π
want to move that visible window around to other parts of the screen bitmap? call scroll_screen(). easy.
β οΈ and listen β initially the clipping rectangle is limited to the physical screen size. so if you wanna draw onto a larger virtual screen space outside that rectangle, you're gonna have to adjust the clipping yourself. no shortcuts, no cap.
π examples, because we love a visual π
for example, to draw a pixel onto the screen you would write:
putpixel(screen, x, y, color);
or, if you wanna implement a double-buffered system:
/* Make a bitmap in RAM. */
BITMAP *bmp = create_bitmap(320, 200);
/* Clean the memory bitmap. */
clear_bitmap(bmp);
/* Draw onto the memory bitmap. */
putpixel(bmp, x, y, color);
/* Copy it to the screen. */
blit(bmp, screen, 0, 0, 0, 0, 320, 200);
like. hello?? blit to screen and suddenly you're on the actual display. main character energy fr fr. π₯
π¨ the warnings section (read this, i'm begging) π¨
Warning: be very careful when using this pointer at the same time as any bitmaps created by the create_video_bitmap() function β go read the description of that function for the more detailed info, she explains it better than i can. π
and never β like, never never β try to destroyscreenwithdestroy_bitmap(). do not do it. it is not yours to destroy. she's the screen. you're just living in it. π
π SEE ALSO π
go read those too, they're all connected, iykyk π
okay that's the whole page, mwah π this was Allegro, version 4.4.3, and yes this little love letter is signed screen(3alleg4) β take care of her, she's holding up your entire window. bye bestie!! πβ¨
π¦ 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