Sign in to follow this  
ArgusMaker

[c++ dx9]FAILED error code?

Recommended Posts

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


[code]
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);[/code]


returns false.
How can i see the erro code?

Share this post


Link to post
Share on other sites
Benden    1480
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
Waaayoff    952
That doesn't look like a proper error code :S

Anyway, [url="http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.errorhandling.dxgeterrordescription(v=vs.85).aspx"]this function[/url] translates DX errors.

Share this post


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

[code]
D3DXIMAGE_INFO imageInfo;
HRESULT hr = D3DXGetImageInfoFromFile(path,&imageInfo);
const char* a = DXGetErrorDescription(hr);
MessageBox(0,a,"asd",MB_OK);[/code]
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this