Draft: st3m: offscreen rendering
Alternative to !222 (merged) , potential solution to #77 (closed), follow up to #28 (closed)
The exact API is in progress, but the general idea is:
- User code allocates a Texture and draws to it however it wants, currently we automagically provide a Context for each Texture.
- User code calls Texture.draw() in Responder.draw()
- The Texture state is never zeroed by the system, allowing for partial redraws. Worms has been moved to use this API as an example. Gay Drums is a great candidate to test against this API.
- Transitions, double buffering, overlays (ie. general compositing) continue to work.
Things to figure out:
- Can we make this simpler for users, ie. allow to easily define apps that just want a persistent ctx for full screen? An extra subclass of View/Responder which always gets such a texture allocated, and users don't have to implement draw(), just think()?
Why is texture drawing so slow? Currently we only get around 10 FPS when copying an empty texture. Am I using ctx_draw_texture and friends wrong? I'm not sure about the intended API with eid, I expected to be able to allocate an eid once and reuse it while modifying the buffer.I tried using RGB565_BYTESWAPPED instead of RGB8 for performance but that broke horribly. Not sure what's up with that.
Known issues:
- Textures are currently always full-screen, but that is easy to fix.
There's some glitches on the edges of a full screen texture. Off-by-one somewhere? Or is my apply_transform call wrong?- Simulator needs to be updated for this.
Possible future use:
- Non-full-screen-sized textures can be used for other purposes, like sprite graphics.
- This allows non-ctx access to graphics, eg. pixel graphics or alternative rendering engines.
Edited by Phileas