ObjectivelyMVC icon indicating copy to clipboard operation
ObjectivelyMVC copied to clipboard

Multiple SDL_Window support

Open jdolan opened this issue 8 years ago • 5 comments

Currently MVC only deals with a single window, and it assumes that all events are eligible for that window. Consideration for applications with multiple window should include:

  • Is event filtering by WindowController useful / required?
  • WindowController is not aware of its window's lifecycle, and can end up with a stale reference when the window is destroyed / recreated.

jdolan avatar Oct 18 '16 02:10 jdolan

I've also been wondering about why Renderer has to be passed through so many levels. I feel like Renderer should be stored in one spot and accessed through a common hierarchy instead of passed as an argument, but maybe I'm not seeing something there.

Paril avatar Oct 20 '16 01:10 Paril

Do you mean View::render(View *, Renderer *)? I prefer to pass parameters around than rely on global state. Particularly for things like multiple-window support, global state could really mess things up. Methods that take in all of the parameters they need to execute are also more testable. Or am I missing what you were describing?

jdolan avatar Oct 20 '16 04:10 jdolan

Well, couldn't the WindowController just store the Renderer, and children go down through the hierarchy until they get to a WindowController with a Renderer tied to it.

kaadmy avatar May 07 '17 20:05 kaadmy

Not really. There's no way for a View to find its ViewController, and there's no way for a ViewController to find its WindowController. This is intentional and by design, to enforce proper encapsulation and delegation.

However, because of SDL, it is possible for each of these to know which Window they are in. SDL_GL_GetCurrentWindow provides that.

jdolan avatar Sep 27 '17 15:09 jdolan

Some progress was made on this in effort to fix some noise / thrashing with ViewController::viewWillAppear. The SDL_Window * member on WindowController is now passed down and maintained (through recursion) on all View instances. Every View knowing what window it's actually in is a good first step.

jdolan avatar Sep 28 '17 01:09 jdolan