persp_project(3)
π persp_project β Allegro manual, bestie edition π
okay so this is persp_project(3) from the Allegro manual β the game programming library, yes that one β and it's here to turn your fancy little 3d point into an actual spot on your 2d screen. it's giving "math but make it wearable". no cap. β¨
π SYNOPSIS π
#include <allegro.h>
void persp_project(fixed x, fixed y, fixed z, fixed *xout, fixed *yout);
void persp_project_f(float x, float y, float z, float *xout, float *yout);
two flavors, same energy: one for the fixed girlies, one for the float girlies. pick your fighter π
π¦ DESCRIPTION π¦
so basically: you hand over a 3d point (x, y, z), and this function projects it into 2d screen space, dropping the result right into (*xout, *yout). it uses the scaling parameters you already set by calling set_projection_viewport() β so like, if you didn't call that first, that's on you bestie, the vibes were established earlier. π«Ά
it projects from the normalized viewing pyramid, which is the aesthetic where:
- the camera sits at the origin, facing along the positive z axis
xruns left/rightyruns up/downzincreases with depth into the screen (deeper = more z, iykyk)
the camera has a 90 degree field of view. literally. which means:
- points on the planes
x=zand-x=zmap onto the left and right edges of the screen - the planes
y=zand-y=zmap to the top and bottom of the screen
so if you want a different field of view, or a different camera location, the move is: transform all your objects with an appropriate viewing matrix. iconic behavior. for example β to get the effect of panning the camera 10 degrees to the left, you rotate all your objects 10 degrees to the right. same result, different path, that's just how it is. π
not me explaining camera panning as a transformation glow-up π it's the same thing, just applied to your objects instead of your camera. periodt.
π SEE ALSO π
and that's the whole page, bestie! this beauty comes to you from Allegro, version 4.4.3 β go forth and project your little 3d points into the world, you main character πβ¨π
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms