Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Laroche

D3DXCreateTextureFromFileEx Failing

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

It''s failing, and I can''t figure out why. I checked every single possible return type using this bit of code:
  

	LPDIRECT3DTEXTURE8 pTexture   = NULL;

	HRESULT hr = D3DXCreateTextureFromFileEx(pDirect3D->GetDevice(), "Ship.bmp", 0, 0, 0, 0,
								D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT,
								D3DX_DEFAULT , 0, NULL, NULL, &pTexture);

	if (FAILED(hr))
	{
		switch (hr)
		{
		case D3DERR_INVALIDCALL:
			MessageBox(NULL,"ic","ic", MB_OK);
			break;
		case D3DXERR_INVALIDDATA:
			MessageBox(NULL,"id","id",MB_OK);
			break;
		case E_OUTOFMEMORY:
			MessageBox(NULL,"oom","oom",MB_OK);
			break;
		case D3DERR_NOTAVAILABLE:
			MessageBox(NULL,"na","na",MB_OK);
			break;
		case D3DERR_OUTOFVIDEOMEMORY:
			MessageBox(NULL,"oovm","oovm",MB_OK);
			break;
		case D3D_OK:
			MessageBox(NULL,"ok","ok??",MB_OK);
			break;
		default:
			MessageBox(NULL,"hr","hr",MB_OK);
			break;
		}
	}
  
Later on in my code I call SetTexture(0, pTexture), but nothing ever shows up. The error I am getting is in the default case. Is there any other return valus that I missed? What else could cause it to fail?

Share this post


Link to post
Share on other sites
Advertisement
In your default case, why not do the following:

DXTrace(__FILE__, __LINE__, hr, "Unexpected error", TRUE); 


Then run your program in the debugger. When you get that pesky unknown return value, it will output its name to the debug output window. When your program exits, check the debug tab of the output window and you will find a line like "C:\blah\blah\myfile.cpp(123): Unexpected error (hr=E_ERRORTYPE (0x00000a))". you can then avoid writing 20 different switches for every single time you can get an error.

Then come back and tell us what the error is.

[edited by - DCrazy on July 28, 2002 6:16:43 PM]

Share this post


Link to post
Share on other sites
Ah thanks for the info, I wasn't aware of that...

Ok, it tells me that it cannot find the file...weird..

I have a bitmap called "Ship" in the debug directory, the same directory that the exe is in..

How come it can't find it? This has always worked with dd7 for me.

EDIT: nm I fixed it Thanks for the useful tidbit of info.

[edited by - laroche on July 28, 2002 6:26:55 PM]

Share this post


Link to post
Share on other sites
if your gonna run it from the compiler it needs to be inside of the compilers folder then if your gonna run it from the exe it needs to be in the exe''s folder

Eric Wright o0Programmer0o




Share this post


Link to post
Share on other sites
I have came across this problem also. If you are running the program from Visual C++ (or whatever) then put the image file in the same folder as the project file. Otherwise putting the file in the same folder as the exe should work. I think this is what KingsRevenge meant

[edited by - Grambo on July 28, 2002 7:23:46 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!