show_video_bitmap(3)

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

✨ show_video_bitmap β€” Allegro manual, bestie edition ✨

okay so this one's a function from the Allegro game programming library, and it's literally the page-flip moment your whole render loop has been waiting for. Let's get into it πŸ’…


🌸 NAME 🌸

show_video_bitmap β€” flips the hardware screen so it shows the video page you picked. Yep. That's the whole vibe. It's part of the Allegro game programming library πŸŽ€


✨ SYNOPSIS ✨

#include <allegro.h>

int show_video_bitmap(BITMAP *bitmap);

πŸ’– DESCRIPTION πŸ’–

So what this does is it attempts to page flip the hardware screen to show the video bitmap object you hand it. Two things about that bitmap, bestie, and they are not optional:

  • it must be the same size as the physical screen, like, exactly
  • and you should have gotten it by calling create_video_bitmap() (don't just grab any random BITMAP, okay? that's not the move πŸ™ˆ)

Now here's the slay part: Allegro handles all the vertical retrace synchronisation for you when it's page flipping. So you do not need to call vsync() before it. The way that it's already doing that job for you... iconic. πŸ‘‘

But β€” and this is the part that matters β€” that means show_video_bitmap() has the same time delay effects as vsync() by default. Same. Exact. Energy. ⏳

You can adjust that with the "disable_vsync" config key, which lives in the [graphics] section of allegro.cfg. Noted, filed, remembered πŸ’…

Example time, because this one's genuinely fun:

int current_page;
BITMAP *video_page[2];
...
/* Create pages for page flipping */
video_page[0] = create_video_bitmap(SCREEN_W, SCREEN_H);
video_page[1] = create_video_bitmap(SCREEN_W, SCREEN_H);
current_page = 0;
...
/* draw the screen and flip pages */
draw_screen(video_page[current_page]);
show_video_bitmap(video_page[current_page]);
current_page = (current_page+1)%2;
...

Look at that double-buffer bounce. (current_page+1)%2. The math is mathing. πŸ”₯


🫢 RETURN VALUE 🫢

  • zero β†’ success, we ate πŸ’–
  • non-zero β†’ failure, it's giving error 😭

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, no cap. this was Allegro version 4.4.3 β€” show_video_bitmap(3) β€” go forth and flip those pages, main character πŸŽ€βœ¨πŸ‘‘

πŸ“¦ where this page comes from