17cupsofcoffee / tetra

🎮 A simple 2D game framework written in Rust
MIT License
909 stars 63 forks source link

Encapsualting graphics state changes #273

Open 17cupsofcoffee opened 3 years ago

17cupsofcoffee commented 3 years ago

Summary

aka: why did my GUI library just yeet my transform matrix

One thing I've noticed as I've been writing some games/libraries with Tetra, is that it's quite hard to build rendering abstractions that don't leak into the global rendering state.

It would be good to add something to the API that would let you push/pop graphics state changes. There's a similar API in a lot of engines I've used (most notably Love2D), and it ends up being pretty convenient.

In the past I've said I wouldn't implement this because it's possible to do in user-space, but that doesn't take into account the fact that code you don't control (e.g. third party libraries) can't benefit from that.

Motivation/Examples

Alternatives Considered