Help with image load DX10

Started by
1 comment, last by Razorwire 14 years, 10 months ago
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?
Advertisement
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.
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

This topic is closed to new replies.

Advertisement