[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame for SDL 2, and how it may look.



Hi,

On 17-04-19 03:23 PM, Daniel Foerster wrote:

On 04/19/2017 01:16 AM, Lenard Lindstrom wrote:

Now I have experimented with separate Window and Renderer. I found a somewhat acceptable solution to the problems mentioned above. But it still felt clunky. Then, when I combined the window and renderer into on class, much of the complexity went away. The only real downside is that the window management code, the window method definitions, will be duplicated in both the WindowRenderer and WindowSurface classes. But then that is just cut and paste, provide one remembers to do it.

Why cut and paste when you can factor it out into a WindowBase class?

Extension type WindowSurface would add an SDL window C pointer to its pygame.Surface parent. This window pointer cannot be factored out into a separate WindowBase parent class. And any methods which access that pointer will be specific to WindowSurface's C structure type. The Renderer extension type will differ from Surface, so the WindowRenderer subclass will also differ from WindowSurface.

What is missing are mixins. I am writing new code in Cython. I believed I had found a way to create a rudimentary mixin, but it failed*. Anyway, I am still trying to make sense of SDL 2, so I may find a functional reason to keep windows and renderers separate in Pygame.


* Cython has an include statement. Unfortunately, include statements are not allowed in class declarations.

Lenard Lindstrom