RandyGaul / cute_framework

The *cutest* framework out there for creating 2D games in C++!
https://randygaul.github.io/cute_framework/#/
Other
546 stars 31 forks source link

Consider refactoring render_settings_*** functions #232

Closed RandyGaul closed 2 months ago

RandyGaul commented 2 months ago

The biggest point of confusion and friction in the draw API are how many of the draw_ functions set state upon drawable objects, i.e. the sprites/shapes. The state gets persisted on the object itself until the next render_to gets called. However, the render settings only get apply when render_to is called. This creates two very different lifetime schemes, and forces users to think about splitting up their draw calls and manually issuing render_to.

It's probably best to shift to a more "declarative" style where any render state changes opaquely separate draw calls under the hood. This way users can freely set anything, including uniforms, and a dirty flag system can be used to split up and submit draw calls as appropriate. This would make draw call counts more opaque and a little more difficult to diagnose when they get high, but, it's not a big deal. The gains on simplifying the API are quite good.

RandyGaul commented 2 months ago

https://github.com/RandyGaul/cute_framework/commit/2a5418ac77c6a2418249960b93e074f0687b14fa