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

Function LoadTexture

Shadows/SampleFramework11/Utility.cpp:147–166  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

145
146// Loads a texture, using either the DDS loader or the WIC loader
147ID3D11ShaderResourceViewPtr LoadTexture(ID3D11Device* device, const wchar* filePath)
148{
149 ID3D11DeviceContextPtr context;
150 device->GetImmediateContext(&context);
151
152 ID3D11ResourcePtr resource;
153 ID3D11ShaderResourceViewPtr srv;
154
155 const std::wstring extension = GetFileExtension(filePath);
156 if(extension == L"DDS" || extension == L"dds")
157 {
158 DXCall(CreateDDSTextureFromFile(device, filePath, &resource, &srv, 0));
159 return srv;
160 }
161 else
162 {
163 DXCall(CreateWICTextureFromFile(device, context, filePath, &resource, &srv, 0));
164 return srv;
165 }
166}
167
168
169// Decode a texture into 32-bit floats and copies it to the CPU

Callers 3

InitializeMethod · 0.85
InitGlobalResourcesMethod · 0.85
LoadMaterialResourcesMethod · 0.85

Calls 4

GetFileExtensionFunction · 0.85
DXCallFunction · 0.85
CreateDDSTextureFromFileFunction · 0.85
CreateWICTextureFromFileFunction · 0.85

Tested by

no test coverage detected