AL_USE_PROJECTION_TRANSFORM(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

πŸ’… al_use_projection_transform(3) β€” Allegro 5 API

okay bestie so this one lives in the Library Functions Manual, and it's genuinely iconic ✨ it's your projection-transform setter and it's about to make your drawing ops look right.


✨ NAME ✨

al_use_projection_transform β€” the Allegro 5 API function that sets the projection transformation your drawing ops get to live in πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro5/allegro.h>

void al_use_projection_transform(const ALLEGRO_TRANSFORM *trans)

🌸 DESCRIPTION 🌸

So here's the tea β˜• β€” this function sets the projection transformation that gets used for the drawing operations on the target bitmap. And yes, every single bitmap keeps its own projection transformation, no sharing, no cap πŸ’…

Every drawing operation after you call this gets transformed using this transformation. main character energy for your whole render pass, honestly.

Now, if you wanna go back to default behavior, you call this function with an orthographic transform, like so:

ALLEGRO_TRANSFORM trans;
al_identity_transform(&trans);
al_orthographic_transform(&trans, 0, 0, -1.0, al_get_bitmap_width(bitmap),
                          al_get_bitmap_height(bitmap), 1.0);

al_set_target_bitmap(bitmap);
al_use_projection_transform(&trans);

And that orthographic transformation right up there? That is the default projection transform. periodt πŸ’–


now for the ✨fine print✨ because there is a LOT and you need to hear it πŸ‘‘

  • This function does nothing if there is no target bitmap. literally nothing. πŸ™ˆ
  • It also does nothing if the bitmap is a memory bitmap β€” i.e. memory bitmaps always use an orthographic transform like the snippet above. no notes.
  • Note that the projection transform will be reset to default if a video bitmap is converted to a memory bitmap. 😭
  • Additionally, if the bitmap in question is the backbuffer, its projection transformation will be reset to default if it is resized.
  • Lastly (okay last one, promise 🫢), when you draw a memory bitmap to a video bitmap with a custom projection transform, this transformation will be ignored β€” i.e. it'll be as if the projection transform of the target bitmap was temporarily reset to default.

🧚 one more thing β€” the parameter is passed by reference as an optimization to avoid the overhead of stack copying. and ngl the best part: the reference will not be stored in the Allegro library, so it is totally safe to pass references to local variables. slay πŸ’œ

⭐ SINCE ⭐

5.1.9 β€” vintage, but make it fashion πŸŽ€


πŸ”₯ SEE ALSO πŸ”₯

go read those too, they're friends of this function fr fr πŸ’–


πŸ’« and that's the whole page bestie πŸ’« this one's straight from the Allegro reference manual (the al_use_pro...n_transform(3) entry β€” yes the header truncates it, she's mysterious like that πŸ’…). no cap, go transform something. πŸ¦‹πŸŒΈπŸ‘‘

πŸ“¦ where this page comes from
  • arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms