Ok, I decided to re-design how my engines texture are handled. However I've come across a problem with the loading of the texture. It crashes during and the call stack points at m_texVector.push_back(tex) and I can't see what I have done wrong.
m_texVector is declared as:
std::vector<LPDIRECT3DTEXTURE9> m_texVector;
the problem points to here:
bool Texture::LoadTexture(const std::string filename)
{
bool fQuit = false;
LPDIRECT3DTEXTURE9 tex = 0;
while ( !fQuit )
{
HRESULT hr = D3DXCreateTextureFromFile(g_device, filename.c_str(), &tex);
if ( SUCCEEDED(hr) )
{
m_texVector.push_back( tex ); // Error somehow!!!
return true;
}
else
{
std::string errorMsg = "Cannot find texture: " + filename;
int msg = MessageBox(0, errorMsg.c_str(), "Texture Error", MB_ABORTRETRYIGNORE);
switch ( msg )
{
case IDABORT:
fQuit = true;
PostQuitMessage(0);
break;
case IDIGNORE:
fQuit = true;
break;
default:
break;
}
}
}
return false;
}