How to load a texture from a file?

北城以北 提交于 2019-12-08 06:09:00

问题


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?


回答1:


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)



来源:https://stackoverflow.com/questions/34925272/how-to-load-a-texture-from-a-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!