everyone! I’m developing a platformer in XNA/C# and I’m running into problems with GraphicsDevices. I’ve heard that XNA requires GraphicsDevices in a lot of methods, but it can only be called after LoadContent() which is problematic for me, as I’m going to have a lot of classes in my project. How can I get the GraphicsDevice?
Thanks in advance!
EDIT: Here’s a code example: http://pastebin.com/vrYhA6MA
In your Game class, add a GraphicsDeviceManager variable like so:
Now, in your Game constructor, initialize it like so:
After the Game constructor, within both the Initialize and the LoadContent methods, the graphics.GraphicsDevice variable should be loaded. You can pass it into methods and give it settings, like DepthStencilState, etc.