al_orthographic_transform(3alleg5)
β¨ al_orthographic_transform(3alleg5) β¨
okay bestie, welcome to the Allegro 5 API page for al_orthographic_transform, section 3alleg5 π this one is short but it's highkey important, so grab your matcha and let's go π
πΈ SYNOPSIS πΈ
#include <allegro5/allegro.h>
void al_orthographic_transform(ALLEGRO_TRANSFORM *trans,
float left, float top, float n,
float right, float bottom, float f)
π¦ DESCRIPTION π¦
So what this does is it takes the transformation you hand it and combines it with an orthographic transformation β one that maps the screen rectangle onto the left/top and right/bottom coordinates you gave it. Slay π
n/f is the z range, and here's the tea: anything outside that range gets clipped. Normally -1/1 is totally fine, because all your 2D graphics are gonna have a z coordinate of 0 anyway. No thoughts, head empty, z = 0 β¨
BUT β and this is the part where you need to pay attention, bestie β if you for example do al_draw_rectangle(0, 0, 100, 100) and then rotate around the x axis (aka "towards the screen"), you gotta make sure your z range allows values from -100 to 100, or that rotated rectangle is gonna get clipped. π Don't let it happen to you.
Also, if you're using a depth buffer, the z range is literally what decides your depth resolution. Example time: if you have a 16 bit depth buffer, there are only 65536 discrete depth values. So if your near/far is set to -1000000/1000000, most of the z positions wouldn't result in separate depth values, which could lead to artifacts. It's giving cursed render ngl π
The result of applying this transformation to coordinates is that your visible coordinates get normalized into the cube from -1/-1/-1 to 1/1/1. Such a transformation is mostly useful for passing it to al_use_projection_transform(3alleg5) β go check that function for an example use, iykyk π
lowkey a whole vibe, but also: get your z range right or your pretty shapes get chopped. that's the warning, fr fr π
β SINCE β
5.1.3
π«Ά SEE ALSO π«Ά
and that's the whole page, bestie! π this came straight out of the Allegro reference manual β al_orthographic_transform(3alleg5) β so if you cite it, that's who to thank. go forth and project responsibly ππ
π¦ 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