Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DXERR_INVALIDDATA when loading a texture

Started by PeterH Apr 3, 2005 at 5:44 AM 5 replies 11.9k views
Original Post
PeterH
PeterH
Hi all, Quick query regarding D3DXCreateTextureFromFile - every time I try to use it I get a D3DXERR_INVALIDDATA error. The DirectX doco doesn't provide much extra information (just "the data is invalid"), and I've tried quite a few textures, from large 1600x1200 jpg's (which the doco says CreateTextureFromFile can handle), to simply 256x256 black and white (ie. 1 bit) .bmp files freshly created in Photoshop. I always get the same error though. Any thoughts on what might be causing it, or any suggestions on how I can get more information about exactly what the problem with the textures I'm trying to load is? Cheers, Peter.
jollyjeffers
jollyjeffers
Have you tried running your application with the Direct3D Debug runtimes enabled?

If you've got these in place then you might well get a hint via the debug output as to exactly what it doesn't like.

Failing that, care to post the functions/params/lines that are giving you grief? might well be something someone here can spot.

Cheers,
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
Cambo_frog
Cambo_frog
Hi,
Could you post the code of your D3DXCreateTextureFromFile call?

Cheers,
Cambo_frog
For the love of god, please tell me that you've just omitted your error checking code for brevity, and you don't really assume that all those functions succeed.
PeterH
PeterH
Hi,

Thanks for the replies. Here's what I'm using:
hResult = D3DXCreateTextureFromFile(m_Device, "test.bmp", &m_Map);    if (FAILED(hResult)) {        MessageBox(0, DXGetErrorString9(hResult), 0, 0);        return false;    }

where m_Device is defined as:

IDirect3DDevice9 *m_Device;

and m_Map is a defined as:

IDirect3DTexture9 *m_Map;

I'm hoping I'm missing really simple here :)

Cheers,

Peter.
Specchum
Specchum
Most probably the function is failing because it can't find your texture file. Make sure the texture bitmap is in the same directory as your project, and that the filename you specify is the *same* as the one in the directory (idiotic as this may seem - I seem to do it ALL the time! ;) ).
"There is no dark side of the moon." - Pink Floyd
PeterH
PeterH
Hah, that was it pretty much. I had the file in the "Debug" directory VC++ creates and places the built .exe file. I was assuming that Debug directory was the "pwd" for the running program, but I was in the middle of implementing some log file code and realised the log file was appearing in the main project directory, not the Debug directory as I would have expected. I moved my bitmap to the main project directory and voila, all working :).

Thanks for the help everyone.

Cheers,

Peter.
jollyjeffers
jollyjeffers
Quote:
Original post by PeterH
Hah, that was it pretty much. I had the file in the "Debug" directory VC++ creates and places the built .exe file. I was assuming that Debug directory was the "pwd" for the running program, but I was in the middle of implementing some log file code and realised the log file was appearing in the main project directory, not the Debug directory as I would have expected. I moved my bitmap to the main project directory and voila, all working :).

There are a few settings in Visual C++ so you can set the default working directory when running a program. I use this so that I can keep my development code/projects seperate from all of the files that make up the game - and so I don't require any duplicates.

Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.