user32

I'm wondering about some of the inner workings of XNA. What is the relation between: Graphics and a GraphicsAdapter and/or device. I can see that the Graphics is obtained from the GraphicDeviceManager but how is this related to eachother. Im comming from WIN32 where there was something like a device context. Should i think in XNA along the same line

Can someone tell me how the following terms are related (graphics, device, graphicdevicemanager)



Re: XNA Framework Relation between Graphics and GraphicsAdapter/Device

Kyle_W

I assume you are referring to the relationship between the GraphicsDeviceManager class and the GraphicsDevice class. If you are referring to some other classes, please give the correct full class name.

The GraphicsDevice class exposes properties and methods that can be used to interact with the GPU directly. You would use this class if you want to manage the GPU yourself, including things like device lost/reset events. You cannot use the Game class in this situation.

The GraphicsDeviceManager class can only be used in conjunction with the Game class. In this case, the GraphicsDeviceManager class will automatically handle device lost/reset events and other device related tasks so the developer does not have to worry about them. The GraphicsDeviceManager class does expose properties and methods for manipulating the GPU. The ContentManager class also works in conjunction with Game and GraphicsDeviceManager to manage game assets automatically.





Re: XNA Framework Relation between Graphics and GraphicsAdapter/Device

user32

You are correct with the assumption. So when i understand correctly, there are two ways to work with devices (GPU).

First way: looking from a bottom-up approach: first create a device and customize it through PresentationParameters. This gives me control over the GPU. I have two questions concerning this: 1) you write that now i cannot use the Game class -> Why not and 2) How do i obtain a Graphics object from the new device (i do not understand how Graphics and Device are related here).

Second way: I'm starting with my inherited Game class. Implicitly there is(are) a device(s) created which can be accessed through the GraphicsAdapter class. The GraphicAdapter is "initialized " through the GraphicDeviceManager which in return obtains the Graphics object

I understand that after that the ContentManager is related to these classes. Sorry for my questions, but i really want to know how it works.





Re: XNA Framework Relation between Graphics and GraphicsAdapter/Device

Kyle_W

I don't know what you mean by Graphics and Device. I see no class named Graphics or Device in the XNA reference. Post a link to the MSDN reference for the class you are asking about. The Game class creates its own GraphicsDevice. You cannot pass it a GraphicsDevice that you created yourself. You must manipulate the GraphicsDevice of the Game class by using the GraphicsDeviceManager class. As best I can tell, the GraphicsAdapter class is just for getting information about a given adapter, not really for manipulating it.



Re: XNA Framework Relation between Graphics and GraphicsAdapter/Device

user32

I see my error and it becomes clear to me now. I misunderstood the term graphics (programmed too much Java and C# lately). The conceptual problem started when is saw a XNA device being created in a WinForm. I now see that it's OK to do that but then everything is manipulated by the created device. When using Game, the only thing you have to do is use the GraphicsDeviceManager because there already is a GraphicsDevice. Manipulating the GraphicsDevice can then be done by using events like: PreparingDeviceSettings through the GraphicsDeviceManager. Thanks for pointing it out to me!!