AL_USE_PROJECTION_TRANSFORM(3)
π 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