scene_polygon3d(3alleg4)

πŸ’– scene_polygon3d β€” putting a polygon in the scene rendering list (Allegro manual, bestie edition)

okay so this is scene_polygon3d(3alleg4) and its sparkly twin scene_polygon3d_f, straight out of the Allegro game programming library. sit down, grab a snack, we're learning scene rendering πŸ’…


✨ SYNOPSIS ✨

#include <allegro.h>

int scene_polygon3d(int type, BITMAP *texture, int vc, V3D *vtx[]);

int scene_polygon3d_f(int type, BITMAP *texture, int vc, V3D_f *vtx[]);

🌸 DESCRIPTION 🌸

So basically? It puts a polygon in the rendering list. That's it. That's the whole vibe. Nothing is really rendered at this moment β€” like, you're just adding it to the queue, bestie, not actually drawing it yet. The glow-up happens later.

You should be calling this between clear_scene() and render_scene(). Those two are your bookends, the main characters, and this function is the little cameo in the middle πŸŽ€

The arguments are the same as for polygon3d(), except the bitmap is missing. Why? Because the one you passed to clear_scene() gets used instead. Reuse, recycle, iconic behavior ✨

Now here's the fun part β€” unlike polygon3d(), the polygon may be concave or self-intersecting. Yes really, go off. Shapes that penetrate one another may look OK, but ngl they are not really handled by this code, so don't come for me if it gets weird πŸ™ˆ

⚠️ Real talk: the texture is stored as a pointer only. So you gotta keep the actual bitmap alive and around until render_scene(), because that's where it actually gets used. Let it die early and you're gonna have a bad time 😭

Since the FLAT style is implemented with the low-level hline() function, the FLAT style is subject to DRAW_MODEs. All these modes are valid β€” no gatekeeping here. Along with the polygon, this mode will be stored for the rendering moment, and also all the other related variables too: the color_map pointer, the pattern pointer, the anchor, and the blender values. Everything gets remembered for later, like a notes app you never clear πŸ’œ

And lowkey important: the settings of the CPU_MMX and CPU_3DNOW flags of the cpu_capabilities global variable on entry in this routine affect the choice of low-level asm routine that will be used by render_scene() for this polygon. So like, the CPU flags at the moment you call this? They decide which asm routine your polygon gets. That's the lore πŸ”₯


πŸ¦‹ RETURN VALUE πŸ¦‹

Returns zero on success, or a negative number if it won't be rendered for lack of a rendering routine. Not a vibe, but at least it tells you πŸ’€


🌈 SEE ALSO 🌈


okay that's the whole page bestie, you ate it πŸ’…βœ¨ this was Allegro version 4.4.3, and yes, scene_polygon3d(3alleg4) β€” go forth and render, periodt 🫢