現在 Direct3D で C++ を使用しており、アセット ストレージを変更しようとしています。
現在、アセットは「vector textureList」として保存され、列挙された定義を使用して取得されます。
STL マップ クラスを使用して、クラスをよりオープンにしたかったのです。ただし、これまでこのクラスを使用したことがなく、理解できない問題に直面しています。
私はテストするためにすべてをかなり必要最小限にしました。現在、次のものがあります。
#include <d3d9.h>
#include <d3dx9.h>
#include <map>
#include <string>
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
using namespace std;
class Assets
{
private:
typedef std::map<string, IDirect3DTexture9*> TexMap;
TexMap textureList;
public:
IDirect3DTexture9* LoadTexture(IDirect3DDevice9* pd3dDevice, LPCWSTR file, string key)
{
//load a texture from file
IDirect3DTexture9* tex;
//D3DXCreateTextureFromFile(pd3dDevice, file, &tex);
D3DXCreateTextureFromFileEx(pd3dDevice, file, 512, 512, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000, NULL, NULL, &tex);
//store the loaded texture to a vector array
textureList.insert(TexMap::value_type(key, tex));
return S_OK;
}
}
これを実行しようとすると、「map/set iterators incompatible」という表現で「Debug Assertion Failed」というエラーが表示されます
私はこれをコードでできる限り単純にしたと感じていますが、同様の例を見てエラーを確認することはできません。
また、コードを次のように実行しました。
#include <d3d9.h>
#include <d3dx9.h>
#include <map>
#include <string>
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
using namespace std;
class Assets
{
private:
typedef std::map<int, int> TexMap;
TexMap textureList;
public:
IDirect3DTexture9* LoadTexture(IDirect3DDevice9* pd3dDevice, LPCWSTR file, string key)
{
//load a texture from file
IDirect3DTexture9* tex;
//D3DXCreateTextureFromFile(pd3dDevice, file, &tex);
D3DXCreateTextureFromFileEx(pd3dDevice, file, 512, 512, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000, NULL, NULL, &tex);
//store the loaded texture to a vector array
//textureList.push_back(tex);
textureList.insert(TexMap::value_type(3, 4));
return S_OK;
}
}
単純にintを使用しているだけで、同じエラーが発生します。