Jump to content
  • Advertisement
Sign in to follow this  
smally

Texture loading error

This topic is 3842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
The most likely cause is that you've called your LoadTexture() on an invalid pointer. (Ex: didn't new the object.)

Share this post


Link to post
Share on other sites
Are you declaring m_texVector as static? If so, it might be a static initialization dependency problem.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
The most likely cause is that you've called your LoadTexture() on an invalid pointer. (Ex: didn't new the object.)


Ah yes, I got so caught up in the design I missed that, thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!