I am currently using C++ with Direct3D and am trying to alter my asset storage.
Right now my assets are stored as "vector textureList" and are obtained using enumerated definitions.
I wanted to make the class more open by using the STL map class. However, I have never used this class before and I am running into problems that I just don't understand.
I have just made everything pretty bare-bones to test and currently have the following:
#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;
}
}
When I try to run this I get a "Debug Assertion Failed" error with the expression "map/set iterators incompatible"
I just feel I have made this as simple as a can in the code and still cannot see the error from looking at similar examples.
I have also run the code as:
#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;
}
}
Just so it is simply using ints and I still get the same error.