SharpDX 3.0.2 D3D11-如何从文件加载纹理并使其在着色器中工作? [英] SharpDX 3.0.2 D3D11 - How to load texture from file and make it to work in shader?
问题描述
我有0个D3D经验。我目前正在阅读Frank Luna的有关D3D11的书,并尝试通过不带效果框架的SharpSharp使示例在C#中工作。我现在坚持纹理化。我不明白如何从文件加载纹理以及如何将其发送到着色器。
I have 0 experience with D3D. I am currently reading Frank Luna's book about D3D11 and trying to make examples working in C# using SharpDX though w/o effect framework. I stuck with texturing now. I don't understand how to load texture from file and how to send it to shader.
官方Wiki已死。或至少它对我不起作用。
我在这里搜索过,但发现只有D2D附带的SharpDX.WIC可以做到这一点,所以在D3D应用程序中使用某些D2D组件对我来说有点奇怪。
Official wiki is dead. Or at least it doesn't load for me. I searched here but found only some way to do it with SharpDX.WIC which is with D2D so it looks a bit weird for me to use some D2D components in D3D app.
推荐答案
在此处查找纹理加载器:如何从文件中加载纹理?
Look here for the texture loader: How to load a texture from a file?
用法:
var device = this.DeviceManager.Direct3DDevice;
var texture = TextureLoader.CreateTexture2DFromBitmap(device, TextureLoader.LoadBitmap(new SharpDX.WIC.ImagingFactory2(), "Texture2.png"));
ShaderResourceView textureView = new ShaderResourceView(device, texture);
这篇关于SharpDX 3.0.2 D3D11-如何从文件加载纹理并使其在着色器中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!