D3DX10CreateTextureFromFile returns unknown error

0

OK, first of all here is the problem code:

D3DX10_IMAGE_LOAD_INFO loadInfo;
ZeroMemory( &loadInfo, sizeof(D3DX10_IMAGE_LOAD_INFO) );
loadInfo.BindFlags = D3D10_BIND_SHADER_RESOURCE;

ID3D10Resource *texture = NULL;
LPCWSTR imageFile = L"../test.bmp";
D3DX10CreateTextureFromFile( pD3DDevice, imageFile, &loadInfo, NULL, &texture, &hr);

if ( hr != S_OK )
{ 
    _com_error err(hr);
    LPCTSTR errMsg = err.ErrorMessage();
    MessageBox(mHwnd, errMsg, L"Error", MB_OK | MB_ICONEXCLAMATION); return false; 
}

The problem is I cant get D3Dx10CreateTextureFromFile to create a valid texture. The only error I get is "Unknown Error 0x88790002" so I cant really figure this out on my own. I have searched and couldn't find anything relevant.

pD3DDevice is a valid and tested D3D10 device. If I comment out the D3Dx10CreateTextureFromFile line everything else works fine.

I am new to directx so any help is appreciated.

PS I do have the required .h and .lib files.

c++
directx-10
asked on Stack Overflow Apr 2, 2016 by squeaky

1 Answer

0

The old DirectX Error Lookup utility says HRESULT 0x88790002 is D3D10_ERROR_FILE_NOT_FOUND. Try using L"..\\test.bmp"; for the filename and double-check that the current working directory is what you expect it to be.

Note that at this point there's very little reason to use Direct3D 10 at all. You should use DirectX 11. D3DX9, D3DX10, and D3DX11 are deprecated and are only in the legacy DirectX SDK. See MSDN. You should look at using one of the many open source replacements for legacy D3DX10.

answered on Stack Overflow Apr 3, 2016 by Chuck Walbourn

User contributions licensed under CC BY-SA 3.0