Search code examples
sharpdx

How to load a texture from a file?


I'm switching to SharpDX 3.0.0 right now. With the old SharpDX version you could load a texture from file in this way:

ShaderResourceView textureView = SharpDX.Direct3D11.Resource.FromFile<Texture2D>(device, "Texture.png");

or

ShaderResourceView textureView = ShaderResourceView.FromFile(device, "Texture.png");

But in version 3.0.0 the function FromFile is missing. How can I load textures from files with SharpDX 3?


Solution

  • You have to use the WIC API or similar methods. There is a old code TextureLoader.cs that performs a simplistic load (but doesn't handle format conversion)