screen(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

✨ screen(3) ✨

okay bestie, welcome to the Allegro manual πŸ’– this one's short but it's load-bearing, so pay attention fr fr


🌸 NAME 🌸

screen β€” a global pointer to the screen hardware video memory, from the Allegro game programming library πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

extern BITMAP *screen;

πŸ‘‘ DESCRIPTION πŸ‘‘

So. screen is a global pointer to a bitmap, and it's sized VIRTUAL_W x VIRTUAL_H. It gets created by set_gfx_mode(), and it literally is the hardware video memory. main character energy, honestly πŸ’…

Only a part of this bitmap is actually visible, and that part is sized SCREEN_W x SCREEN_H. Normally that visible part is just the top left corner of the bigger virtual screen β€” so if you're not into hardware scrolling or page flipping, you can completely ignore the extra invisible virtual size of the bitmap. no thoughts, head empty, it's fine 🫢

Wanna move that visible window to other parts of the screen bitmap? Call scroll_screen(). ✨

Also important: at the start, 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. yes really πŸ™ˆ


🌈 Examples bestie, because examples eat every time 🌈

Wanna draw a single pixel onto the screen? Boom:

putpixel(screen, x, y, color);

Wanna implement a double-buffered system? Say less:

/* 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);

⚠️ Warning, and I need you to actually read this one: be very careful when you use this pointer at the same time as any bitmaps made by the create_video_bitmap() function β€” check the description of that function for the detailed tea. And never try to destroy it with destroy_bitmap(). not even once. not even a little. πŸ’€

πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page, bestie β€” this was Allegro version 4.4.3, brought to you by the Allegro crew, from the screen(3) era. slay, go draw some pixels, ily πŸŒΈπŸ’–βœ¨

πŸ“¦ where this page comes from