fixup_datafile(3)
β¨ fixup_datafile(3) β¨
okay bestie, welcome to the Allegro manual π this one's short but she is IMPORTANT, so pay attention fr fr
πΈ NAME πΈ
fixup_datafile β Fixes truecolor images in compiled datafiles. Allegro game programming library.
like. the name literally tells you what it does. iconic behaviour honestly π
π¦ SYNOPSIS π¦
#include <allegro.h>
void fixup_datafile(DATAFILE *data);
one function, one argument, zero drama π
π DESCRIPTION π
okay so here's the tea β if you're using compiled datafiles (those are the ones produced by the dat2s and dat2c utilities, iykyk) on a platform that doesn't support constructors β which, rn, is literally any non GCC-based platform β OR if your datafiles contain truecolor images, then you MUST call this function. Once. After you set the video mode you're gonna be using. No cap, it's mandatory in those cases π«Ά
what does it do for you, queen? two things:
- makes sure the datafiles are properly initialised, in that first no-constructors case
- converts the color values into the appropriate format, in the truecolor case
and the way it handles all that? it deals with flipping between RGB and BGR formats, and it converts between different color depths whenever that can be done without changing the size of the image. which specifically means:
- changing
15<->16-bithicolor β for both bitmaps AND RLE sprites β¨ - changing
24<->32-bittruecolor β for RLE sprites π«
β οΈ okay this next bit is the important warning, do NOT skip it. You can only call this once and expect it to work correctly. Because after the call, theDATAFILEyou fixed up is permanently converted to whatever the current component ordering is for your screen mode. If you callfixup_datafileagain, the function just assumes you've got a freshly loaded datafile. It literally cannot "undo" the previous conversion. there is no take-backsies π
so what if your program supports changing resolution and/or color depth during runtime? bestie, you've got two choices and only two π
- Call
fixup_datafile()just once and hope that the component ordering and bit depth doesn't change when the screen mode changes. (unlikely. be so fr π) - Or, you can reload your datafiles whenever the screen mode changes. much safer energy β¨
π SEE ALSO π
and that's the whole page bestie, you ate that π this was the Allegro manual, version 4.4.3, and yeah that's the source right there β Allegro itself, serving looks since forever π go set your gfx mode and call your fixup function, but like... only once ππβ¨
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms