py-sdl2 icon indicating copy to clipboard operation
py-sdl2 copied to clipboard

[RFC][untested] optional presentation to render target in SpriteRenderSystem

Open mseeber opened this issue 7 years ago • 3 comments

  • 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.

mseeber avatar May 24 '18 18:05 mseeber

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?

mseeber avatar May 24 '18 18:05 mseeber

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?

marcusva avatar May 24 '18 19:05 marcusva

I'll have to look into how these test are going to be designed but sure. Once spare time allows it.

mseeber avatar May 25 '18 16:05 mseeber

@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!

a-hurst avatar Sep 03 '22 16:09 a-hurst