MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / LoadTexture

Function LoadTexture

SampleFramework11/v1.02/Graphics/Textures.cpp:26–49  ·  view source on GitHub ↗

Loads a texture, using either the DDS loader or the WIC loader

Source from the content-addressed store, hash-verified

24
25 // Loads a texture, using either the DDS loader or the WIC loader
26ID3D11ShaderResourceViewPtr 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
51template<typename T>
52static void GetTextureData(ID3D11Device* device, ID3D11ShaderResourceView* textureSRV,

Callers 3

InitializeMethod · 0.85
InitializeMethod · 0.85
LoadMaterialResourcesMethod · 0.85

Calls 2

GetFileExtensionFunction · 0.85
DXCallFunction · 0.85

Tested by

no test coverage detected