|
||
---|---|---|
src | ||
.gitignore | ||
build.zig | ||
build.zig.zon | ||
compile_shaders.bat | ||
readme.md | ||
todo.todo |
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.
Live error checking
This project has been configured so that zls can show live compile errors on save. To make it work, you need to set these zls config params (in VSCode just copy these to your preferences):
"zig.zls.enableBuildOnSave": true,
"zig.zls.buildOnSaveStep": "check"
Also, if you're in VSCode, install ErrorLens extension so you can see the errors inline.
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.