Advertisement Jump to content
Sign in to follow this  

Loading texture problem!

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

I'm using CreateTextureFromFileEx() to load a texture. When I run the code in the VC++ 6 IDE, it generates an error when loading the texture. However, when I run the .exe file in the debug folder, the extra message box I added after the loading should have occured pops up, meaning the texture loaded successfully. Why is this?

Share this post

Link to post
Share on other sites
To elaborate: When you run the exe from the IDE, the working directory is the project's directory. That is, if you had this directory structure:

When you run it from the IDE, the exe runs in "project", so when it attempts to load resources (textures), it doesn't find them (because they're in project/debug).

You can specify the working directory via project settings (Alt-F7). Make it "Debug" for the debug configuration, and "Release" for the release configuration.

Share this post

Link to post
Share on other sites

void TitleScreen::loadTexture(char* filename, IDirect3DTexture9* texture, D3DCOLOR key)
// Last parameter is the color key. Use 0xFFFF00FF for magenta. 0xFF000000 for black.
// Use 0x00000000 for no 'color key' substitution

D3DXIMAGE_INFO SrcInfo; // Optional

D3DXCreateTextureFromFileEx( D3D_device, filename, 0, 0, 1, 0,
key, &SrcInfo , NULL, &texture);

MessageBox(NULL, "Failed to load background texture!", "Error!",

IDirect3DTexture9* bg;
bg = 0;
Here is the function call:

When I run this from the debugger, and check the values during this function call, texture = 0x001f60a0 but &texture = 0x0012fde0 " '|" except the '|' character is fat. And when I expand the variable, I see -96 ' '.Anyways, it just looks like garbage. After the function call, I check the value of bg and it's equal to NULL still. It says when I expand:
IDirect3DBaseTexture9 CXX0030:Error:expression cannot be evaluated

Why is this call not working?

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!