py-sdl2
py-sdl2 copied to clipboard
[RFC][untested] optional presentation to render target in SpriteRenderSystem
-
factor presentation to render target out of SoftwareSpriteRenderSystem and TextureSpriteRenderSystem render method.
-
expanded interface of both render systems to allow manual presentation via 'present' method.
-
add flag to constructor of both systems to control if render results should be presented inside render method call.
-
set default for the new flag to True to preserve old behavior and keep interface compatible to old code.
-
add docstrings for new messgae and document new flag in init methods.
This is an attempt to solve #91 by adding a flag to both rendering Systems to control whether presentation should be done right after rendering or should be responsibility of another system.
This PR is untested and considered to be a base for discussion about possible better implementation variants.
Maybe this is better solved in the base class and maybe the flag itself should be part of the interface?
I'd want to avoid inheritance clutter and base-class invocations on SpriteRenderSystem.
A SpriteRenderSystem.present() method stub however would enable consisteny across the different renderers and their usage. Thus I'd also keep the control flag on the implementation level of inheriting classes.
Except from that, your approach looks good to me. Do you mind to change the code slightly and add some simple test cases (e.g simple color blits with a pixel check to verify), if you're comfortable with it?
I'll have to look into how these test are going to be designed but sure. Once spare time allows it.
@mseeber No clue if you're still using PySDL2 for anything, but I've created a new API sdl2.ext.Renderer which directly offers the sort of separate "draw to buffer" and "present buffer" methods this PR implements.
If you think there's a case for adding this functionality into the (deprecated) SpriteRenderSystem I can re-open this, but otherwise I'm going to consider this closed.
Thanks again for contributing to the project!