Take the 2-minute tour ×
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 currently writing a program in C# with the XNA framework. It is absolutely necessary for the game's images and text assets to be visible by the end user in the form of PNG files, so I can't use the content pipeline.

How would I go about using graphics and text in my XNA game without it?

share|improve this question
add comment

2 Answers 2

You don't need the content pipeline.

MonoGame, for example, allows you to use LoadContent<Texture2D> and specify an image name of a file that's just a simple PNG in your Content directory. This is what I do for all my projects (since MonoGame has difficult/flakey? support of the content pipeline today), and because I don't care about "protecting" my assets by converting them into XN* format.

From what I remember of "vanilla" or MS XNA, this worked there too.

share|improve this answer
    
Note that you don't need to store the raw PNG and other content in the Content directory, and that textures that you load in this fashion do not have pre-multiplied alphas, so this will need to be done manually. See my answer here for a method that does this. –  John McDonald Jan 21 '13 at 22:57
    
@JohnMcDonald I'm not sure if this is true. I have no problem with pre-multiplied alphas, albeit you have to set the spritebatch BlendState to Non-Premultiplied. See my question here: gamedev.stackexchange.com/questions/44696/… –  ashes999 Jan 22 '13 at 0:54
    
Makes sense, either multiply the alphas yourself, or tell XNA that the alphas haven't been pre-multiplied. –  John McDonald Jan 22 '13 at 16:31
add comment

Use Texture.FromStream to load the texture at runtime. This is a little tricky because of premultiplied alpha as referred to in ashes999 answer. Here is a great explanation from David Gouveia on how to do it correctly

share|improve this answer
add comment

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.