Sign in to follow this  
ChewBaggins

D3DXCreateTextureFromFileEx problems

Recommended Posts

ChewBaggins    122
sprintf(filename,"Images/walk_front.bmp"); D3DXGetImageInfoFromFile(filename,&info); if(D3DXCreateTextureFromFileEx(D3DDevice,filename,info.Width,info.Height,1,D3DPOOL_DEFAULT,D3DFMT_UNKNOWN,D3DPOOL_DEFAULT, D3DX_DEFAULT,D3DX_DEFAULT,D3DCOLOR_XRGB(255,0,255),&info,NULL,&image) == NULL) { return NULL; } The following code works perfect when the image is in the root directory. I am trying to have it load from a folder named Images. Is there a way that i can do this?

Share this post


Link to post
Share on other sites
Skeleton_V@T    512
What IDE/Compiler are you using ?

Besure to check for current directory when specifying relative path, current directory may not be the same as your exe's when running the program.

By the way, why did you use sprintf ?. Just specify "Images\\Walk_Front.bmp" directly to the D3DXCreate...() or declare a temp variable:

char *pcImgPath = "Images\\Walk_Front.bmp" ;

...then pass that pcImgPath to D3DXGetImageInfoFromFile and CreateTex()

The most likely problem is that D3DXGetImageinfoFromFile can not load the correct file with your specified path, note that "\\" may not be compatible.

Hope this helps.
V@T

Share this post


Link to post
Share on other sites
jollyjeffers    1570
Quote:
Original post by Skeleton_V@T
Besure to check for current directory when specifying relative path, current directory may not be the same as your exe's when running the program.

If you're using VStudio then it can be quite easy to confuse the working directories... I forget exactly where the setting(s) are, but I've definitely confused myself with this one before [smile]

GetCurrentDirector() might well be of use to you.

hth
Jack

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