4
\$\begingroup\$

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?

\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Jan 21, 2013 at 22:57
  • \$\begingroup\$ @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/… \$\endgroup\$
    – ashes999
    Commented Jan 22, 2013 at 0:54
  • \$\begingroup\$ Makes sense, either multiply the alphas yourself, or tell XNA that the alphas haven't been pre-multiplied. \$\endgroup\$ Commented Jan 22, 2013 at 16:31
0
\$\begingroup\$

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

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .