I am trying to load a texture into my 3d graphics application. I am having trouble with my sampler state specifically. There are no errors generated just my little popup window saying, "Texture failed to load". I did a bit of debugging and couldn't find why my sampler is having trouble loading. All of the HRESULTs return S_OK and yet it throws a popup at me.
resourceManager.h
#pragma once
#include "renderer.h"
#include <d3dx11tex.h>
class ResourceManager
{
private:
ComPtr<ID3D11SamplerState> m_Sampler;
ComPtr<ID3D11ShaderResourceView> m_Texture;
Renderer m_Renderer;
public:
ResourceManager(Renderer& renderer);
inline ComPtr<ID3D11SamplerState> GetSampler() const { return m_Sampler; }
inline ComPtr<ID3D11ShaderResourceView> GetTexture() const { return m_Texture; }
bool CreateTexture(LPCWSTR file_name);
};
resourceManager.cpp
#include "resourceManager.h"
ResourceManager::ResourceManager(Renderer& renderer)
: m_Renderer(renderer)
{
}
bool ResourceManager::CreateTexture(LPCWSTR file_name)
{
auto handlerR = D3DX11CreateShaderResourceViewFromFile(m_Renderer.GetDevice().Get(), file_name, nullptr, nullptr, m_Texture.GetAddressOf(), nullptr);
if (FAILED(handlerR)) return false;
D3D11_SAMPLER_DESC sampDesc;
ZeroMemory(&sampDesc, sizeof(sampDesc));
sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
sampDesc.MinLOD = 0;
sampDesc.MaxLOD = D3D11_FLOAT32_MAX;
auto handlerS = m_Renderer.GetDevice()->CreateSamplerState(&sampDesc, m_Sampler.GetAddressOf());
if (FAILED(handlerS)) return false;
return true;
}