Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

GraphicsDevice handle in a custom content processor


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 AmzBee   Members   -  Reputation: 414

Like
0Likes
Like

Posted 06 May 2012 - 04:59 PM

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, 06 May 2012 - 05:00 PM.

Aimee Bailey
Lead Programmer / Co-Founder

http://xpod-games.com
@XpodGames

Ad:

#2 MJP   Moderators   -  Reputation: 5418

Like
1Likes
Like

Posted 06 May 2012 - 08:48 PM

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, 06 May 2012 - 08:48 PM.


#3 AmzBee   Members   -  Reputation: 414

Like
1Likes
Like

Posted 17 May 2012 - 11:51 PM

Thanks for the reply, it took me a while to figure it out but you pointed me in the right direction Posted Image

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.

Edited by AmzBee, 17 May 2012 - 11:56 PM.

Aimee Bailey
Lead Programmer / Co-Founder

http://xpod-games.com
@XpodGames




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS