Skip to main content
GameDev.net gamedev.net
🔒 Locked

GraphicsDevice handle in a custom content processor

Started by AmzBee May 6, 2012 at 10:59 PM 1 replies 1.6k views
Original Post
AmzBee
AmzBee
During creating a custom content importer/processor for a mapping format, I realised it would be handy to grab a handle to the current GraphicsDevice, however I think I'm missing a bit of logic. When the content manager is asked to load a Model, the BasicEffect attached to each ModelMeshPart has a handle to the GraphicsDevice, this is what I want to do with my own loaded content, although I'm just not sure at what point I would be able to find a handle to it. I should make clear that I am not using the Model class, nor will be able to.

Does anyone know how I would be able to achieve this? I'd rather not have to require that the user of my importer/processor must pass the handle after calling Content.Load<>()

Thanks for your help.

Aimee
We are now on Tumblr, so please come and check out our site!    http://xpod-games.com
MJP
MJP
It's been a while since I did any XNA, but from what I recall you can get an IServiceProvider from the ContentManager that's loading the asset, which you can then ask for a GraphicsDevice.
AmzBee
AmzBee
Thanks for the reply, it took me a while to figure it out but you pointed me in the right direction smile.png

For anyone else looking for the solution, here is what I came up with:


IGraphicsDeviceService obj = content.ServiceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService;
GraphicsDevice device = obj.GraphicsDevice;


Aimee.
We are now on Tumblr, so please come and check out our site!    http://xpod-games.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.