Loads a texture, using either the DDS loader or the WIC loader
| 24 | |
| 25 | // Loads a texture, using either the DDS loader or the WIC loader |
| 26 | ID3D11ShaderResourceViewPtr LoadTexture(ID3D11Device* device, const wchar* filePath, bool forceSRGB) |
| 27 | { |
| 28 | ID3D11DeviceContextPtr context; |
| 29 | device->GetImmediateContext(&context); |
| 30 | |
| 31 | ID3D11ResourcePtr resource; |
| 32 | ID3D11ShaderResourceViewPtr srv; |
| 33 | |
| 34 | const std::wstring extension = GetFileExtension(filePath); |
| 35 | if(extension == L"DDS" || extension == L"dds") |
| 36 | { |
| 37 | DXCall(DirectX::CreateDDSTextureFromFileEx(device, filePath, 0, D3D11_USAGE_DEFAULT, |
| 38 | D3D11_BIND_SHADER_RESOURCE, 0, 0, forceSRGB, |
| 39 | &resource, &srv, nullptr)); |
| 40 | return srv; |
| 41 | } |
| 42 | else |
| 43 | { |
| 44 | DXCall(DirectX:: CreateWICTextureFromFileEx(device, context, filePath, 0, D3D11_USAGE_DEFAULT, |
| 45 | D3D11_BIND_SHADER_RESOURCE, 0, 0, forceSRGB, &resource, &srv)); |
| 46 | |
| 47 | return srv; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | template<typename T> |
| 52 | static void GetTextureData(ID3D11Device* device, ID3D11ShaderResourceView* textureSRV, |
no test coverage detected