Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm starting out with MonoGame. For now, I'm only targeting Windows (desktop -- not Windows 8 specifically).

I've used a couple of XNA products in the past (raw XNA, FlatRedBall, SilverSprite), so I may have a misunderstanding about how I should add images to my content.

How do I add images to my project?

Currently, I created a new Monogame project, added a folder called "Content," and added images under there; the only caveat is that I need to set the Copy to Output Directory action to one of the Copy ones.

It seems strange, because my "raw" XNA project just last week had a Content project in it (XNA Framework Content Pipeline, according to VS2010), which compiled my images to XNB (I think). It seems like Monogame doesn't use the same content pipeline, but I'm not sure.

Edit: My question is not about "how do I get the XNA content pipeline to work with Monogame." My question is "why would I want to use the XNA content pipeline in Monogame?"

Because there are (at least) two solutions (that I see today):

  • Add the images to the Monogame project and set the Copy to Output Directory options to copy.
  • Add a XNA content pipeline project and add my images to that instead; reference it from my MOnogame project.

Which solution should I use, and why? I currently have a working version with the first option.

share|improve this question

3 Answers

What I do, is create an XNA project inside of my MonoGame solution. I set the compile location of this "Dummy" project to point to the same location that MonoGame compiles to.

When you build your project, the XNA Content project will convert your images to XNB files in the same location as your MonoGame binaries.

You need to use the XNA content pipeline in order to get your XNB files, there is currently no way around this if you are writing a MonoGame project.

I then delete the dummy.exe file if I am submitting a release.

share|improve this answer
1  
My question is really about whether I should use the content pipeline at all or not; what are the tradeoffs here? I've updated my question accordingly. – ashes999 Nov 28 '12 at 15:30

There is, in fact, a way around the Content Pipeline if you can't use it, at least for image dependencies: Use the TitleContainer class to load your dependencies in their raw forms:

// Load a Texture2D from a file
System.IO.Stream stream = TitleContainer.OpenStream("Content/My Sprite.png");
mySpriteTexture = Texture2D.FromFile(GraphicsDevice, stream);

// Load a SoundEffect from a file 
// (NOTE: This is NOT in the current version of MonoGame)
stream = TitleContainer.OpenStream("Content/My Sound.wav");
mySound = SoundEffect.FromStream(stream);

These work wherever the Xna Framework can be used, but where the Xna Content Pipeline is not available or is too inconvenient.

share|improve this answer

I have got it to work by having an open XNA solution which i add the jpg's or png's to then rebuild.

I then copy this over to the content folder in the MonoGame solution and set it to a Content type in the properties.

I understand the monogame team are attempting to build a content pipeline but i'm not sure where they are up to it

share|improve this answer
My question is really about whether I should use the content pipeline at all or not; what are the tradeoffs here? I've updated my question accordingly. – ashes999 Nov 28 '12 at 15:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.