Rust 2D Engine, Rendering revisited

"hale"s rendering system was implemented in pure opengl. 

sokol-app was used to get opengl context on windows/linux, and custom wasm thing for web.

Rendering system supposed to be released and separated, reusable crate. I want to make good-web-game the first user of that rendering layer.
So I had two options - keep API high-level, basically reimplement good-web-game in opengl and call it rendering layer.
Or make some lower-level abstraction and build good-web-game on top of it.

I tried both ways and decided to choose the second option.
And here we go, first results: zemeroth running on top of good-web-game running on top of that layer:

yes, transparency is not yet supported and I am writing this post instead of fixing it

This is how it looks:
good-web-game use very similar code.

The code looks nearly identical to the sokol-gfx samples. As with "hale" I decided to take some good, proven design and just reimplement it in rust.

The api is so close to sokol's, that documentation is 99% applicable to my rust version!  <- a nice overview of sokol concepts.

The most interesting part is how frame is built:

"Render pass" is an act of drawing something somewhere. To the screen or to some render buffer.

"Draw state" is all the resource bindings - images, meshes.  

"Uniforms" - are material parameters. Separated from "draw state" because usually are changed more frequently.

So to draw something we need to start render pass, bind all the resources and set the uniforms.
Looks super clean, nice and straightforward, I really like it!

Later "draw state" was splitted to  "bindings"  and "pipeline". "binding" is buffers and images and "pipeline" is material and vertex attributes. As uniforms - its common to change those things separately.

By becoming a patron, you'll instantly unlock access to 9 exclusive posts
By becoming a patron, you'll instantly unlock access to 9 exclusive posts