set_projection_viewport(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

✨ set_projection_viewport ✨

okay bestie, so this one lives in the Allegro manual, aka the game programming library of your dreams πŸ’–, and it's a <pink>set_projection_viewport(3)</pink> situation. what does it do? it sets the viewport used to scale the output of persp_project(). that's it, that's the girl. πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, set_projection_viewport() sets the viewport that gets used to scale the output of the persp_project() function. you pass in the dimensions of the screen area you wanna draw onto, and ngl that's typically gonna be 0, 0, SCREEN_W, and SCREEN_H. no cap. πŸŽ€

✨ pro tip from me to you: don't forget to pass an appropriate aspect ratio to get_camera_matrix later. the way that these two are besties... iykyk 🫢

now here's the tea β˜• β€” the width and height you specify here determine how big your viewport is in 3d space. so 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. the fov and aspect-ratio parameters to get_camera_matrix also apply some scaling though, so this isn't always completely true). lowkey important, highkey iconic. πŸ’€

and listen β€” if you pass -1/-1/2/2 as parameters, no extra scaling will be performed by the projection. literally zero. none. periodt. πŸ‘‘


🌈 SEE ALSO 🌈


and that's the whole vibe, bestie πŸ’–βœ¨ this cutie came straight out of Allegro, version 4.4.3, and it's the set_projection_viewport(3) page. go forth and scale your viewport, you absolute main character πŸŒŸπŸŽ€πŸ¦‹

πŸ“¦ where this page comes from