D3DX10CreateTextureFromFile 返回未知錯誤 (D3DX10CreateTextureFromFile returns unknown error)


問題描述

D3DX10CreateTextureFromFile 返回未知錯誤 (D3DX10CreateTextureFromFile returns unknown error)

好的,首先是問題代碼:

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; 
}

問題是我無法獲取 D3Dx10CreateTextureFromFile 來創建有效的紋理。我得到的唯一錯誤是“未知錯誤 0x88790002”,所以我自己無法真正解決這個問題。我已經搜索並找不到任何相關的東西。

pD3DDevice 是一個有效且經過測試的 D3D10 設備。如果我註釋掉 D3Dx10CreateTextureFromFile 行,其他一切正常。

我是 Directx 的新手,因此不勝感激。

PS 我確實有所需的 .h 和 .lib 文件。


參考解法

方法 1:

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.

(by squeakyChuck Walbourn)

參考文件

  1. D3DX10CreateTextureFromFile returns unknown error (CC BY‑SA 2.5/3.0/4.0)

#directx-10 #C++






相關問題

D3D10 (DirectX10) 全屏性能問題 (D3D10 (DirectX10) fullscreen performance issue)

directx10 中的精靈和紋理過濾 (Sprites in directx10 and texture filtering)

Firemonkey 中的 DirectX10 支持(非 10.1) (DirectX10 support in Firemonkey (not 10.1))

錯誤 LNK2019 Directx10 VC++2010 (Error LNK2019 Directx10 VC++2010)

管理 HLSL 效果 (Managing HLSL effects)

D3DX10CreateTextureFromFile 返回未知錯誤 (D3DX10CreateTextureFromFile returns unknown error)

使用 HLSL 變量分配 struct C++ (Assign struct C++ with HLSL variable)

ID3DX10Mesh::CloneMesh (ID3DX10Mesh::CloneMesh)

在 DirectX 10 中清除單個視口 (Clear single viewport in DirectX 10)

Visual c++ DirectX 編譯錯誤 (Visual c++ DirectX compilation error)

將 ID3D11Texture2D 轉換為內存緩衝區 (Convert ID3D11Texture2D into a memory buffer)

DirectX 10.1 / C++:如何通過 ID3D10Resource* 紋理在精靈上渲染文本? (DirectX 10.1 / C++: How to render text on sprite over ID3D10Resource* textures?)







留言討論