D3DXCreateTextureFromFileExA in DirectX8 crashes

Started by
7 comments, last by Evil Steve 17 years, 4 months ago
Hi guys, I am using the following function for loading a texture in DirectX8. This code crashes if I run the exe file directly. If I run it in visual studio it works fine. Later I changed the filter type to Default, Which loads all the files without any problem, but my texture are scaled now, Guys pls help me out with this, when it crashes it doesn't even give me any useful information. D3DXCreateTextureFromFileExA( device, filename.c_str(), D3DX_DEFAULT, DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN,D3DPOOL_MANAGED,D3DX_FILTER_NONE, D3DX_FILTER_NONE, 0xFFFF00FF, NULL, NULL, &m_texture );
Advertisement
Hi,

Firstly, are you sure this is not a problem with relative paths. When you run a program from Visual Studio the paths are different than an external execution.

Secondly, if you go to the DirectX control panel icon (for older versions of DirectX9) or to the start menu for new versions you can turn on alot of debug information as well put Direct3D itself into debug mode as supposed to retail.

Once you have done this, please paste the debug output that is displayed in the output window.

Dave
Am pretty sure about the path, Coz the Debug exe file runs out of visual studio. Only the Release build has a problem.
In this case it is more likely that you have 1 or more variable that are uninitialised.

When you build a Debug exe all variables are initialised to the default value automatically. This is not the case for Release so make sure that all variables are initialised.

Dave
What do you mean it crashes? Access violation? If so, is it reading or writing, and what's the address it/s reading or writing to?

You could try adding some checks (MessageBox()es) to check that the device pointer looks valid, and the path is correct.

Are you able to open the file (with fopen() or whatever the iostream stuff equivalent is) passed as a parameter to D3DXCreateTextureFromFileEx()? If not, there's no way D3DX will be able to open it.

Are you checking the return value of D3DXCreateTextureFromFileEx()? I suspect it's failing, and you're then accessing the texture, assuming it's going to work, which gives you a NULL pointer exception (Access violation reading 0x00000000).

Finally, you can get applications to let you capture the debug output window from an app without havingto run it in the IDE. I'm not sure of the names of any offhand though, but ISTR there's one with VC2005. Or, you could just open the IDE, and then open the release EXE from there and run it (Without running it as debug or step-through).
Am using try & catch block, the function "D3DXCreateTextureFromFileEx()" itself crashes internally. Actually I have all the images in DDS DXT5 format, if the code crashes I just change the file format to DDS A8R8G8B8 format & the code works fine. Why is this happening, I want to use DXT5 only coz it take less space.
Quote:Original post by Altaf
Am using try & catch block, the function "D3DXCreateTextureFromFileEx()" itself crashes internally. Actually I have all the images in DDS DXT5 format, if the code crashes I just change the file format to DDS A8R8G8B8 format & the code works fine. Why is this happening, I want to use DXT5 only coz it take less space.
Quote:Original post by Evil Steve
What do you mean it crashes? Access violation? If so, is it reading or writing, and what's the address it/s reading or writing to?
try/catch blocks don't catch things like access violations, only exceptions thrown by your application.

If you want to try to recover from an access violation (Again, assuming it's an access violation, you still haven't said), you need to use Windows' Structured Exception Handling (SEH), and you can't really recover from that, only fail gracefully.
Definitely there is no access violation. I used the return value in Directx error look up tool, but no useful info is provided. There is no entry fir that error code. If the code is crashing it should always crash, it crashes only when I load DDS DXT5 files, It successfully loads any other format successfully.
Quote:Original post by Altaf
Definitely there is no access violation. I used the return value in Directx error look up tool, but no useful info is provided. There is no entry fir that error code. If the code is crashing it should always crash, it crashes only when I load DDS DXT5 files, It successfully loads any other format successfully.
If it's not giving you an access violation, then in what way is it crashing? Returning an error code isn't crashing. What is the error code exactly?

Also, have a look at the forum FAQ - that'll tell you how to install the debug runtimes, which will give you a proper error message in the debug output telling you why it failed.

This topic is closed to new replies.

Advertisement