• Advertisement
Sign in to follow this  

Loading texture problem!

This topic is 4656 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
Advertisement
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:
project
project/debug

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,
D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_DEFAULT,
key, &SrcInfo , NULL, &texture);

if(!texture)
{
MessageBox(NULL, "Failed to load background texture!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
}
}



IDirect3DTexture9* bg;
bg = 0;
Here is the function call:
loadTexture("Debug\\bg.bmp",bg,0xFFFF00FF);

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