Trying out sokol in zig
Go to file
nothke 2524dbf206 Slightly better time management 2024-07-04 16:02:52 +02:00
src Slightly better time management 2024-07-04 16:02:52 +02:00
.gitignore Initial 2024-06-09 00:48:23 +02:00
build.zig Events. Quit on mouse move or press like a screensaver 2024-06-16 14:50:36 +02:00
build.zig.zon Cleanup 2024-06-11 01:17:51 +02:00
compile_shaders.bat Uniforms and compiling shaders with a script 2024-06-11 20:43:41 +02:00
readme.md Better readme, added why zig and sokol 2024-06-12 12:58:14 +02:00
todo.todo Circle that doesnt stretch 2024-06-12 02:04:37 +02:00

readme.md

A little learning playground of sokol in zig. Started on the gamejam at Decentrala, 9th June 2024.

The goal of this project is not fixed, and is just to try out some sokol features. But here's a few things I'd like to try out:

  • Draw a circle
  • Load and render textures
  • Render a 3D object
  • Compile it for WebAssembly and run it in the browser

Build

To build, you need to have zig master (you can use zvm to help you with this). Then just zig build run and that should be it!

Note that if you change shaders, you have to recompile them manually - run compile_shaders.bat.

Why zig?

Zig is a low level language and toolchain that is designed as a "better C". Its main goal is to be simple, robust and fast. A few strong points:

  • It can cross-compile from any platform to any platform.
  • It can include C headers and you can use it in zig directly.
  • It has a built-in build system that is also written in zig, so no other build systems like cmake are needed.
  • Unlike C++, it's not OOP, there are no hidden constructor and destructor calls and overcomplicated copy/move rules.
  • Unlike C, it solves A LOT of problems of C, and is MUCH harder to shoot yourself in the foot.
  • There are no hidden allocations, everything that is heap-allocating has to be done explicitely.
  • It has a powerful metaprogramming facility "comptime", which provides full static reflection.
  • I can go on listing more cool features, but that is enough for now.. :)

Why sokol?

Sokol is a cross platform graphics library with minimal footprint that can compile to any backend like DirectX, OpenGL, Vulcan, Metal or even WebAssembly.