clip3d_f(3alleg4)

πŸ’– clip3d_f πŸ’–

okay bestie, so this is clip3d_f from the Allegro manual β€” the game programming library, you know the one. it clips polygons with floating point math and honestly? it's giving geometry gatekeeper. πŸ¦‹


✨ NAME ✨

clip3d_f β€” clips the polygon you handed over in vtx, using floating point math, from the Allegro game programming library. slay.


✨ SYNOPSIS ✨

#include <allegro.h>

int clip3d_f(int type, float min_z, float max_z, int vc, const V3D_f
*vtx[], V3D_f *vout[], V3D_f *vtmp[], int out[]);

✨ DESCRIPTION ✨

so basically πŸ’… it clips the polygon that's sitting in vtx. the vertex count is vc, the glow-up result lands in vout, and vtmp plus out are the behind-the-scenes besties that it needs for internal purposes. no questions, they're just doing their job. and listen β€” every pointer in vtx, vout and vtmp must point to valid V3D_f structures. valid. not vibes-based. actual valid structures. πŸ‘‘

here's the part where you have to pay attention, bestie πŸŽ€: because extra vertices can just appear out of nowhere during clipping (iconic of them honestly), the size of vout, vtmp and out should be at least

vc * (1.5 ^ n)

where n is the number of clipping planes (5 or 6), and ^ means "to the power of". so like, do the math, don't guess, because this is not the moment for main character recklessness. 😭

okay now the frustum (that's the viewing volume, iykyk) is defined by:

-z<x<z, -z<y<z, 0<min_z<z<max_z

and if max_z<=min_z, then the z<max_z clipping is not done. just skipped. that's the rule, periodt.

as you can see, clipping happens in camera space, with perspective in mind 🧠✨ β€” so you should call this routine after you apply the camera matrix, but before the perspective projection. get the order wrong and it's not gonna eat, fr fr.

the routine will correctly interpolate u, v, and c in the vertex structure. 🫢 but β€” and this is the sad part β€” no provision is made for high/truecolor GCOL. πŸ’€ so don't come for it about that.


✨ RETURN VALUE ✨

returns the number of vertices after clipping is done. that's it, that's the tea. ⭐


✨ SEE ALSO ✨


and that's the whole page, bestie!! 🌈 this one came from the Allegro manual, version 4.4.3, and it's clip3d_f(3alleg4) β€” go clip something gorgeous. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’