jonathanhogg / flitter

A functional programming language and declarative system for describing 2D and 3D visuals
https://flitter.readthedocs.io
BSD 2-Clause "Simplified" License
34 stars 1 forks source link

What if `Context` objects became the interface between the engine and rendering? #39

Open jonathanhogg opened 5 months ago

jonathanhogg commented 5 months ago

Following on from an idea in #38 of putting references into Context so that @context_funcs can access them, what if the Context was also passed into renderers instead of the current mish-mash of engine, node, references and global names?

Other than possibly just being neater, another key advantage of doing this would be allowing renderers to update the warnings and errors sets. At the moment, there's no good way for renderers to log problems that wouldn't spam the console on each frame, so they tend to just eat errors and forget about them.

jonathanhogg commented 5 months ago

Ways that engine is currently used by renderers:

Engine's .state is in the Context already and .target_fps is in the names dictionary. Adding the counter into the context sounds reasonable. The page stuff probably needs abstracting into a better concept of actions (or events?) that would make it easier for controllers to trigger things.

There is probably also an argument for having BeatCounter become part of flitter.model.