Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphicsDeviceManager partial class refactor #4425

Merged
merged 2 commits into from
Apr 2, 2016

Conversation

tomspilman
Copy link
Member

This PR is an attempt to clean and split up GraphicsDeviceManager to allow for partial class extension on new platforms.

  • Copied existing GraphicsDeviceManager to GraphicsDeviceManager.Legacy.cs to maintain behavior of old platforms.
  • New version of GraphicsDeviceManager.cs without any platform specific code in it.
  • The Windows, Windows8, Windows Phone, Windows Phone 8.1, Windows Universal, and Web platforms now use the new GraphicsDeviceManager.
  • Added some more reference docs.
  • Minor cleanups in Windows platform files.

Fixes #2859
Fixes #1762.

Once we switch over the OpenTK backed to support this then also #1748 should be fixed if it isn't already.

@tomspilman
Copy link
Member Author

FYI. I just put this up to test my progress.

I still need to figure out how to abstract out Initialize() ApplyChanges(), ToggleFullScreen(), and IsFullScreen.

@tomspilman
Copy link
Member Author

@dellis1972 @KonajuGames

I'm thinking of taking the mess of code in these methods and just putting them in some ".Legacy.cs" partial file. We can then structure a new path for new platforms and slowly bring the existing platforms over.

Any other ideas?

@KonajuGames
Copy link
Contributor

KonajuGames commented Jan 14, 2016 via email

@dellis1972
Copy link
Contributor

Ditto Legacy.cs sounds like the most reasonable approach. then we can move the code out slowly as things change.

@tomspilman
Copy link
Member Author

So sticking to the legacy file concept here, but I won't do any complex partial thing. Instead we have two copies of GraphicsDeviceManager:

  • GraphicsDeviceManager.cs is the new code with partials for platform specific bits.
  • GraphicsDeviceManager.Legacy.cs is the old code for platforms that haven't been switched over yet.

Once we get all the platforms switched over the legacy implementation can be removed.

Should have a new push here shortly with these changes.

@Tzenchor
Copy link
Contributor

i'm having a look at making an abstract device manager with the common parts and a concrete class with the specifics for each platform.
Form what i have done until now, it seems viable, and can remove every conditional compilation block, but needs some reworking to avoid duplicated code

@tomspilman
Copy link
Member Author

i'm having a look at making an abstract device manager with the common parts and a concrete class with the specifics for each platform.

We preferably don't want to make abstract GraphicsDeviceManager class as it alters the class hierarchy from XNA.

The path I've taken here allows for GraphicsDeviceManager to remain identical to XNA with platform specific code in one of three places:

  • A partial class of GraphicsDeviceManager.
  • The GraphicsDevice.
  • The GamePlatform.

Things are looking pretty good this way.

@tomspilman
Copy link
Member Author

@dellis1972 @KonajuGames - I could use feedback on this now.

@dellis1972
Copy link
Contributor

Looks ok to me. @KonajuGames ?

@tomspilman
Copy link
Member Author

Note this can wait until after 3.5.

@tomspilman tomspilman added this to the 3.6 Release milestone Jan 19, 2016
@tomspilman
Copy link
Member Author

Going to merge this. It only affects Windows platforms at the moment.

@tomspilman tomspilman merged commit 799d133 into MonoGame:develop Apr 2, 2016
@tomspilman tomspilman changed the title GraphicsDeviceManager Refactor GraphicsDeviceManager partial class refactor Jun 15, 2016
@tomspilman tomspilman deleted the fxr branch January 4, 2017 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor GraphicsDeviceManager GraphicsDevice is null during Game construction after ApplyChanges()
5 participants