• Advertisement
Sign in to follow this  

[c++ dx9]FAILED error code?

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

Hey, i recently found out why my codes never work.
They fail on every directx function!
EG:



IDirect3DSurface9* surface = NULL;
D3DXIMAGE_INFO imageInfo;
if(FAILED(D3DXGetImageInfoFromFile(fname,&imageInfo)) &&
FAILED(DX::g_pd3dDevice->CreateOffscreenPlainSurface( imageInfo.Width,imageInfo.Height,imageInfo.Format,D3DPOOL_DEFAULT,&surface,NULL)) &&
FAILED(D3DXLoadSurfaceFromFile(surface,NULL,NULL,fname,NULL,D3DX_DEFAULT,0,NULL)))
return(false);
return(true);



returns false.
How can i see the erro code?

Share this post


Link to post
Share on other sites
Advertisement
The 'FAILED' macro simply checks the return value (of type HRESULT) from those functions against the value 'D3D_OK'.

So instead simply do:

HRESULT hr = whateverD3DFunction();

That'll give you the result from each function so you can check for specific errors as they are reported.

Share this post


Link to post
Share on other sites
You can also turn on / increase the debug output via the DirectX control panel that comes with the SDK.

Share this post


Link to post
Share on other sites
Check the documentation.

It will state what return values you will get when calling DirectX functions.

You don't say which call failed ?

Share this post


Link to post
Share on other sites
LNK2019: undefined reference to external symbol _DXGetErrorDescriptionA@4
Which lib do i have to link? MSDN does not specify that

Share this post


Link to post
Share on other sites
Ok, here is the code and the error


D3DXIMAGE_INFO imageInfo;
HRESULT hr = D3DXGetImageInfoFromFile(path,&imageInfo);
const char* a = DXGetErrorDescription(hr);
MessageBox(0,a,"asd",MB_OK);

error: Invalid Data.
damned directx..

edit: ok, it was because D3DXGetImageInfoFromFile doesen't accept .png files..
i'm trying with .bmp, and device->CreateOffscreenPlainSurace(..) gives me the error: Invalid Call.
Resolved, i was trying to use a non-supported surface format :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement