clip3d_f(3)

๐Ÿ“ฆ version 4.4.3.1, in fedora 43, fedora 44

โœจ clip3d_f โ€” the Allegro manual, but make it cute โœจ

okay bestie, welcome to the clip3d_f(3) page from the Allegro manual ๐Ÿ’– this one's a real one, she clips polygons with floating point math and she does it flawlessly. Allegro game programming library, as always. let's get into it ๐ŸŽ€


๐ŸŒธ NAME ๐ŸŒธ

clip3d_f โ€” clips the polygon given in vtx using floating point math. Allegro game programming library, periodt. ๐Ÿ’…


๐Ÿฆ‹ 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[]);

look at her. iconic signature. no notes. โœจ


๐Ÿ‘‘ DESCRIPTION ๐Ÿ‘‘

so what's the tea? clip3d_f clips the polygon you hand her in vtx. the number of vertices is vc, the result goes in vout, and vtmp and out are needed for internal purposes โ€” they're the backstage crew, don't worry about them, just give them a seat. ๐ŸŒˆ

important bestie: the pointers in vtx, vout and vtmp must point to valid V3D_f structures. no fake ones, no random memory, fr fr. ๐Ÿ’€

now, here's the thing โ€” as additional vertices may appear in the process of clipping (she's growing the polygon, main character energy), 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 ^ denotes "to the power of". so like, math. do the math. ๐Ÿงฎโœจ

the frustum (that's the viewing volume, the little zone where things actually show up) is defined by -z<x<z, -z<y<z, 0<min_z<z<max_z. and if max_z<=min_z, the z<max_z clipping is not done. noted. ๐Ÿ“

as you can see, clipping is done in the camera space, with perspective in mind, so this routine should be called after you apply the camera matrix, but before the perspective projection. order matters, bestie, it's giving choreography. ๐Ÿ’ƒ

and she will correctly interpolate u, v, and c in the vertex structure. however โ€” and this is the one sad part ๐Ÿ˜ญ โ€” no provision is made for high/truecolor GCOL. she simply does not do that. ๐Ÿ’”


โญ RETURN VALUE โญ

returns the number of vertices after clipping is done. a little number, a big slay. ๐Ÿ‘‘


๐Ÿซถ SEE ALSO ๐Ÿซถ

go read those too, they're all part of the friend group ๐Ÿ’œ


and that's the whole page, babe! ๐Ÿฆ‹ this was clip3d_f(3) from the Allegro manual, brought to you by Allegro version 4.4.3 โ€” mwah, ily, go clip some polygons responsibly ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from