Sign in to follow this  
littletray26

D3DXCreateTextureFromFile() failing

Recommended Posts

littletray26    284
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:

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

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:

[CODE]

std::wstring GetDirectory()
{
return currentDir;
}
[/CODE]

currentDir is defined as follow:
[CODE]

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

... later on in code


GetCurrentDirectory(MAX_PATH + 1, currentDirectory);
currentDir = currentDirectory;
[/CODE]

Any idea why this is failing?

Share this post


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

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

Share this post


Link to post
Share on other sites
littletray26    284
[quote name='kubera' timestamp='1338628039' post='4945527']
Maybe you would write the code this way:

[CODE]
D3DXCreateTextureFromFile(rd3dDevice, (GetDirectory() + L"\\Resources\\Sprites\\crosshair.png").c_str(), &crosshair)
[/CODE]
[/quote]

I feel stupid -__-

Thank you! :)

Share this post


Link to post
Share on other sites

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