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

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



Ian Mallett wrote:
​I like this idea a lot, modulo that you should also store the reference to the window.

The Renderer would hold a reference to the window itself,
so you would only need to keep a separate reference to the
window if you wanted to use different renderers with it
at different times, or switch one renderer around between
different windows.

You might actually want to do the latter. If the Renderer
encapsulates an OpenGL context, using just one Renderer
would make it easy to share the same set of textures etc.
for all of your drawing.

So we have two use cases. If you have just one window:

   r = Renderer(window = Window())
   # do some drawing with r

If you have multiple windows and want shared rendering
state:

   w1 = Window()
   w2 = Window()
   r = Renderer()

   r.window = w1
   # do some drawing with r
   r.window = w2
   # do some drawing with r

--
Greg