Sign in to follow this  

GraphicsDevice handle in a custom content processor

This topic is 2034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 Edited by AmzBee

Share this post


Link to post
Share on other sites
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. Edited by MJP

Share this post


Link to post
Share on other sites
Thanks for the reply, it took me a while to figure it out but you pointed me in the right direction [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

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

[CODE]
IGraphicsDeviceService obj = content.ServiceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService;
GraphicsDevice device = obj.GraphicsDevice;
[/CODE]

Aimee. Edited by AmzBee

Share this post


Link to post
Share on other sites

This topic is 2034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this