ObjectivelyMVC
ObjectivelyMVC copied to clipboard
Multiple SDL_Window support
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.
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.
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?
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.
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.
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.