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 β thefovandaspect-ratioparameters toget_camera_matrixalso 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 π
persp_project(3alleg4)get_camera_matrix(3alleg4)ex3d(3alleg4)excamera(3alleg4)exquat(3alleg4)exscn3d(3alleg4)exstars(3alleg4)exzbuf(3alleg4)
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 ππ
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms