Timeline for Why does GameComponent have an Initialize() method?
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 13, 2017 at 12:18 | history | edited | CommunityBot |
replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/
|
|
Oct 19, 2014 at 14:49 | comment | added | Kyle Baran |
Okay cool, that's exactly what I wanted to know. I didn't realize that it inserted itself into Game.Services
|
|
Oct 19, 2014 at 14:49 | comment | added | Andrew Russell |
I'm not sure I fully understand the question. When GraphicsDeviceManager(this) runs, where this is a reference to Game , it inserts itself into the given Game.Services as both IGraphicsDeviceService and IGraphicsDeviceManager . This is how Game.Run is able to find the GDM to set up the GraphicsDevice . If you were so inclined, you could provide your own implementations of those two interfaces, and Game would work as expected. You could even skip Game all together and initialize GraphicsDevice yourself.
|
|
Oct 19, 2014 at 12:42 | comment | added | Kyle Baran |
Actually, that other answer is pretty helpful/interesting. So basically, it's set up in this way to guarantee that the GDM is in a usable state by the time components get around to initializing themselves, or using textures or other resources that rely on the graphic device. Makes sense. On a related note, I've noticed I can actually call new GraphicsDeviceManager(this); and it still sets everything up correctly anyways (albeit without a reference to the GDM). Usually, I would expect this sort of 'automatic' behavior to be in a static method, not a constructor. What gives?
|
|
Oct 19, 2014 at 12:30 | vote | accept | Kyle Baran | ||
Oct 19, 2014 at 11:49 | history | answered | Andrew Russell | CC BY-SA 3.0 |