On Thu, Apr 20, 2017 at 5:38 PM, Greg Ewing
wrote:
> 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
The second use-case is more-or-less exactly what I was thinking. (I'm
still unconvinced the first use case really warrants a dedicated
constructor.)
I'm not sure if SDL 2's hardware renderers support being shared. I assume
they do, just from the API they export, but I don't know.
> --
> Greg
>
Ian