al_use_projection_transform(3alleg5)
β¨ al_use_projection_transform β¨
okay bestie, so this one's from the Allegro 5 API (that's the 3alleg5 manual, iykyk) and it's literally about telling your bitmaps how to see the world π
πΈ SYNOPSIS πΈ
#include <allegro5/allegro.h>
void al_use_projection_transform(const ALLEGRO_TRANSFORM *trans)
π¦ DESCRIPTION π¦
So what this does is set the projection transformation that all your drawing operations on the target bitmap are gonna use. And the cute part? every bitmap keeps its own projection transformation β they're all main characters with their own vibe, no sharing π«Ά
Every drawing operation you do after this call gets transformed using this transformation. periodt.
And if you wanna go back to the default behaviour, 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);
That orthographic transformation up there is the default projection transform. the blueprint. the og. π
Now for the β¨fine printβ¨ that you cannot skip, bestie:
- This function does nothing if there is no target bitmap. nothing. not a single thing. π
- It also does nothing if the bitmap is a memory bitmap β meaning memory bitmaps always use an orthographic transform like the snippet above. they're committed to the ortho lifestyle.
- Note that the projection transform will be reset to default if a video bitmap is converted to a memory bitmap.
- Also, if the bitmap in question is the backbuffer, its projection transformation will be reset to default if it is resized.
- And lastly β when you draw a memory bitmap to a video bitmap with a custom projection transform, that transformation will be ignored. it's as if the projection transform of the target bitmap got temporarily reset to default. rude, but true π
One more lil thing about the parameter: it's passed by reference as an optimization, so we skip the overhead of stack copying. And the reference will not be stored in the Allegro library, so it is totally safe to pass references to local variables. no dangling nonsense here, we're responsible π
β SINCE β
5.1.9 β she's been here a minute π
π SEE ALSO π
al_get_current_projection_transform(3alleg5)al_perspective_transform(3alleg5)al_orthographic_transform(3alleg5)
and that's the whole thing bestie!! sourced straight from the Allegro reference manual, page al_use_projection_transform(3alleg5) β go forth and transform ur projections, ily, slay ππβ¨
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms