SET_PROJECTION_VIEWPORT(3alleg4)

✨ set_projection_viewport ✨

okay bestie, so this one is from the Allegro game programming library manual, section 3alleg4, and it's literally called set_projection_viewport β€” aka the lil function that sets the viewport used to scale the output of persp_project(). πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

void set_projection_viewport(int x, int y, int w, int h);

πŸ¦‹ DESCRIPTION πŸ¦‹

So what this does: it sets the viewport used to scale the output of the persp_project() function. That's it, that's the job. πŸ’–

You pass in the dimensions of the screen area you want to draw onto β€” and like, typically? That's gonna be 0, 0, SCREEN_W, and SCREEN_H. Classic. The whole screen, no notes. ✨

Also!! do not forget to pass an appropriate aspect ratio to get_camera_matrix later. I'm serious, bestie, don't skip that part. πŸ™ˆ

The width and height you specify here will determine how big your viewport is in 3d space. So like, the way this plays out: if an object in your 3D space is w units wide, it will fill the complete screen when you run into it (i.e., if it has a distance of 1.0 after the camera matrix was applied). πŸ‘‘

ok but real talk β€” the fov and aspect-ratio parameters to get_camera_matrix also apply some scaling, so this isn't always completely true. just so you know. πŸ€·β€β™€οΈ

And here's the lil secret trick: if you pass -1/-1/2/2 as parameters, no extra scaling will be performed by the projection. periodt. πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘


k that's the whole page, you ate it 🫢 this was Allegro version 4.4.3, set_projection_viewport(3alleg4), and that's the vibe check for today β€” go draw something cute in 3D, bestie πŸ’œπŸŽ€