create_sub_zbuffer(3)

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

✨ create_sub_zbuffer ✨

okay bestie, welcome to the Allegro manual πŸ’– this one's a function page from the Allegro game programming library, and it's genuinely so useful once it clicks, i promise.


πŸŽ€ NAME πŸŽ€

create_sub_zbuffer β€” it makes a sub-z-buffer</sub-z-buffer>, no cap. Allegro game programming library, periodt.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

ZBUFFER *create_sub_zbuffer(ZBUFFER *parent, int x, int y, int width,
int height);

🌸 DESCRIPTION 🌸

So here's the vibe: this creates a sub-z-buffer, which is literally a z-buffer that shares drawing memory with a z-buffer you already made πŸ‘‘ but it can be a different size. That's it, that's the whole thing.

The same rules as for sub-bitmaps apply, fr fr:

  • the sub-z-buffer's width and height can extend beyond the right and bottom edges of the parent β€” they just get clipped, no drama
  • but the origin point must lie within the parent region. that part is non-negotiable bestie 🫢

Now the important part, listen up πŸ“’ when you're drawing z-buffered to a bitmap, the top left corner of the bitmap is always mapped to the top left corner of the current z-buffer. always. so this function is mainly here for when you wanna draw to a sub-bitmap and use the corresponding sub-area of the z-buffer 🧚

In other cases β€” like, say, you just wanna draw to a sub-bitmap of the screen and not to the other parts of the screen β€” you'd usually wanna create a normal z-buffer (not a sub-z-buffer!) that's the size of the visible screen. and no, you do not need to first create a z-buffer the size of the virtual screen and then a sub-z-buffer of that. skip that whole detour, it's giving extra steps for no reason πŸ’…


⭐ RETURN VALUE ⭐

Returns the pointer to the sub ZBUFFER, or NULL if something went wrong 😭

πŸ’€ bestie PLEASE remember to destroy the ZBUFFER once you're done with it, otherwise you're gonna have memory leaks and that is not the main character energy we're going for.

🌈 SEE ALSO 🌈


mwah πŸ’œ that's the whole page! this one comes to you straight from the Allegro source, version 4.4.3 ✨ go forth and z-buffer responsibly, bestie πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from