fixup_datafile(3alleg4)
π fixup_datafile π
okay bestie, welcome to the Allegro manual, and today's main character is fixup_datafile from the Allegro game programming library. she's a glow-up artist for your datafiles and she does not miss. π¦
β¨ NAME β¨
fixup_datafile β fixes truecolor images in compiled datafiles. (Allegro game programming library, if that wasn't obvious from the vibe. π
)
β¨ SYNOPSIS β¨
#include <allegro.h>
void fixup_datafile(DATAFILE *data);
β¨ DESCRIPTION β¨
so here's the tea. π if you're using compiled datafiles β the ones made by the dat2s and dat2c utilities β on a platform that doesn't support constructors (as of right now, that's any non GCC-based platform), OR if your datafiles have truecolor images in them, you must call this function once after you set the video mode you're gonna be using. no cap, it's required.
what does she actually do tho? two things, and she's iconic for both:
- she makes sure the datafiles get properly initialised β that's the non-constructor-platform situation.
- she converts the color values into the appropriate format β that's the truecolor-images situation.
she handles flipping between RGB and BGR formats, and converting between different color depths whenever that can be done without changing the size of the image. and when exactly is that possible, you ask? π
- changing 15<->16-bit hicolor for both bitmaps and RLE sprites, and
- 24<->32-bit truecolor for RLE sprites.
β οΈ MAJOR WARNING, bestie, read this twice: 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 for your screen mode is. so if you callfixup_datafileagain, the function just assumes you've got a freshly loaded datafile sitting there. she cannot "undo" the previous conversion. it's done. it's forever. periodt. π
so what if your program supports changing resolution and/or color depth while it's running? (main character behavior, honestly. π) you've got two choices:
- call
fixup_datafile()just once and hope that the component ordering and bit depth doesn't change when the screen mode changes β which is, and I quote, unlikely. π - reload your datafiles whenever the screen mode changes. slay. that one actually works.
β¨ SEE ALSO β¨
that's the whole page, babe. π brought to you by Allegro, version 4.4.3 β go fix up your datafiles and go off. πβ¨π«Ά
π¦ 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