• Advertisement
Sign in to follow this  

D3DXCreateTextureFromFile() failing

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

Hey gamedev

I have a sprite locate at "C:\Users\Jyhe\Documents\Visual Studio 2010\Projects\2D test\2D test\Resources\Sprites\crosshair.png"

and I'm trying to load it with the following code:


D3DXCreateTextureFromFile(rd3dDevice, (GetDirectory().c_str(), L"\\Resources\\Sprites\\crosshair.png"), &crosshair)


But it's failing to load the texture.

My GetDirectory function returns "C:\Users\Jyhe\Documents\Visual Studio 2010\Projects\2D test\2D test" and is as follows:



std::wstring GetDirectory()
{
return currentDir;
}


currentDir is defined as follow:


TCHAR currentDirectory[MAX_PATH + 1];
std::wstring currentDir;

... later on in code


GetCurrentDirectory(MAX_PATH + 1, currentDirectory);
currentDir = currentDirectory;


Any idea why this is failing?

Share this post


Link to post
Share on other sites
Advertisement
Maybe you would write the code this way:


D3DXCreateTextureFromFile(rd3dDevice, (GetDirectory() + L"\\Resources\\Sprites\\crosshair.png").c_str(), &crosshair)

Share this post


Link to post
Share on other sites

Maybe you would write the code this way:


D3DXCreateTextureFromFile(rd3dDevice, (GetDirectory() + L"\\Resources\\Sprites\\crosshair.png").c_str(), &crosshair)



I feel stupid -__-

Thank you! :)

Share this post


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

  • Advertisement