ALLEGRO_STATE(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ ALLEGRO_STATE ✨

okay bestie, welcome to the Allegro 5 API πŸ’– this one's short but it's important, so lock in 🫢


🌸 SYNOPSIS 🌸

typedef struct ALLEGRO_STATE ALLEGRO_STATE;

πŸ’… DESCRIPTION πŸ’…

So this is an opaque type, which is just a fancy way of saying "you don't get to peek inside, you just pass her around" πŸ™ˆ She gets handed off to al_store_state(3alleg5) and al_restore_state(3alleg5), and that's her whole job. Queen of minding her own business πŸ‘‘

The various state that Allegro keeps internally can be displayed like this:

global
    active system driver
        current config
per thread
    new bitmap params
    new display params
    active file interface
    errno
    current blending mode
    current display
        deferred drawing
    current target bitmap
        current transformation
        current projection transformation
        current clipping rectangle
        bitmap locking
        current shader

Look at that little family tree 🌳 iconic honestly.

ngl, here's the tea β˜•: in general, the only real global state is the active system driver. Everything else global-ish is actually per-thread, which means if your app is running multiple separate threads, they literally never interfere with each other ✨ bestie behaviour fr fr.

⚠️ Caveat though, don't get too comfy: that's except if there are objects accessed by multiple threads, of course. Usually you wanna minimize that though β€” and for the remaining cases, use the synchronization primitives described in the threads section, or the events described in the events section, to control inter-thread communication πŸ’€ don't just yolo it.

Allegro reference manual Β· ALLEGRO_STATE(3alleg5) β€” mwah, that's the whole page, ily, go forth and store/restore your state responsibly πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from