tags:

views:

1191

answers:

4

Hi, In XNA, how do I load in a texture or mesh from a file without using the content pipeline?

+1  A: 

I believe Texture2D.FromFile(); is what you are looking for.

It does not look like you can do this with a Model though.

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.texture2d.fromfile.aspx

Cory
+2  A: 

The .FromFile method will not work on xbox or zune. You have two choices:

  1. Just use the content pipeline ... on xbox or zune (if you care about them), you can't have user-supplied content anyways, so it doesn't matter if you only use the content pipeline.
  2. Write code to load the texture (using .SetData), or of course to parse the model file and load the appropriate vertexbuffers, etc.
Joel Martinez
+1  A: 

For anyone interested in loading a model from a file check out this tutorial:

http://creators.xna.com/en-us/sample/winforms_series2

+1  A: 

This is a windows only Way to load a texture without loading it through the pipeline, As Cory stated above, all content must be compiled before loading it on the Xbox, and Zune.

Texture2D texture = Texture2D.FromFile(GraphicsDeviceManager.GraphicsDevice, @Location of your Texture Here.png);

Acedia