-
Hello, How can I load a texture (all common formats *.dds, *.tga, *.png, *.jpg, etc.) in C# as In C++, you would add Windows Imaging Component (WIC) and then load the texture with the following line: DirectX::CreateWICTextureFromFile(device, L"path.jpg", &Resource, &ShaderResourceView); Thanks for the help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Since we don't have bindings to the directx XTK that function you are mentioning isn't available, but you could also import that function yourself if you really wanted to. Otherwise, this is some older code I wrote for DX12 (uses sharpdx from when that was still active), but the code is pretty much identical to how you would do this in silk. https://github.com/curin/CPU-GPU-Renderer/blob/master/GPUShaders/ShaderProfiles/SimpleTexture.cs#L195. It loads a bitmap as C# normally would and then converts it to a byte buffer with proper ordering (depends on what your resource is setup as rgba, rgb, argb, etc.) Then it writes it to a resource. This is essentially what the XTK function does for you. The DX11 code for this will be a little different, but have similar steps. |
Beta Was this translation helpful? Give feedback.
Since we don't have bindings to the directx XTK that function you are mentioning isn't available, but you could also import that function yourself if you really wanted to. Otherwise, this is some older code I wrote for DX12 (uses sharpdx from when that was still active), but the code is pretty much identical to how you would do this in silk. https://github.com/curin/CPU-GPU-Renderer/blob/master/GPUShaders/ShaderProfiles/SimpleTexture.cs#L195. It loads a bitmap as C# normally would and then converts it to a byte buffer with proper ordering (depends on what your resource is setup as rgba, rgb, argb, etc.) Then it writes it to a resource. This is essentially what the XTK function does for yo…