A pure Zig 2D graphics library - z2d

Hey folks!

Version 0.10.0 has been released. This is a small release before the new year, and includes hairline support, in addition to some very small API changes.

You can check out the changelog at: https://github.com/vancluever/z2d/blob/v0.10.0/CHANGELOG.md

Thanks!

2 Likes

Does anyone have advice on using z2d with SDL3? Getting a bit lost in the details since I’m new to Zig, z2d and SDL.

I’m trying using the 7Games/zig-sdl3 wrapper but an example using another wrapper, calls to the SDL C functions or even just a description would be helpful.

It seems like the general gist is:

  1. Build up a z2d surface using the painter commands
  2. Create an SDL3 surface or texture
  3. Copy the raw pixel buffer from the z2d surface to the SDL3 surface or texture
  4. Render the SDL3 surface or texture to the window

Am I on the right track?

@g4b3 you have the right approach! If you know you’re always going to be working with said surface/texture memory exclusively, you might want to look into how you can just map the memory directly, and then use Surface.initBuffer so you can just render directly to it, and save yourself some copying.

Happy to answer any other questions!