Sign in to follow this  

Help with image load DX10

This topic is 3100 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

Hi, I am not understanding why my load texture function is returning NULL when I run it. The file is in the correct place but it just isn't loading. the prototype
	ID3D10Texture2D	*loadTexture2DFromFile (LPCWSTR filename);

the call
	// load textures
	g_pTexture1 = loadTexture2DFromFile (TEXT(".\\spaceAce.bmp"));

the function
//
// getTexture2DFromFile
// loads a 2D texture object to memory and returns a pointer to it
//

ID3D10Texture2D	*loadTexture2DFromFile (LPCWSTR filename)
{
	// local variables
	ID3D10Texture2D	*pTexture = NULL;
	ID3D10Resource	*pResource = NULL;

	// local declarations
	HRESULT hr = D3DX10CreateTextureFromFile (g_pD3D10Device, filename, NULL, NULL, &pResource, NULL);
	if (FAILED(hr))
	{
		MessageBox(NULL, filename, L"Texture Load Failure", MB_OK);
		return NULL;
	}
	pResource->QueryInterface(__uuidof(ID3D10Texture2D), (LPVOID*) &pTexture);
	pResource->Release();

	// return
	return pTexture;
}

when I run the code I get the Messagebox error message with the path of the bmp that I am trying to load. What have I done wrong?

Share this post


Link to post
Share on other sites
What is ".\\spaceAce.bmp" supposed to mean?
That is exactly the same as "spaceAce.bmp", are you sure you don't mean "..\\" or something?
If not, try a different image, perhaps it doesn't like the format.

Share this post


Link to post
Share on other sites
windows speak for current directory /edit need the doubble back slash to cancel the escape character the computer just reads it as .\spaceAce.bmp

I have also used
./spaceAce.bmp
spaceAce.bmp

I have tried it in 24bit and 32bit color space

/edit again: I just loaded the image into the sample code that I am working from so the bmp does load just not in my program

Share this post


Link to post
Share on other sites

This topic is 3100 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this