Im using this code to load a texture:
HRESULT hr = D3DXCreateTextureFromFile(d3ddev, "test.bmp", &g_texture);
But it always returns D3DXERR_INVALIDDATA error!
The triangle i am rendering works just fine, so rest of the program is working, except texture loading.
What i have missed? the file exists for sure. i tried with jpg and png as well, and with smaller image with size 256×256. the image works just fine with me.. so it cant be invalid data, even though it says so.
Most likely, even though the file is available, it is not in the correct path for the program to access.
If you are running your program from within Visual Studio, make sure the working directory is pointing to the folder which contains your
test.bmp. Unfortunately the location of this setting changes a lot between different versions of VS, but in VS 2005 it isProject->Properties->Debugging->Working Directory. Make sure you have the same setting for both Debug and Release mode.You can check your current directory through code with GetCurrentDirectory.