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

[c++ dx9]FAILED error code?

Started by ArgusMaker May 15, 2011 at 3:47 PM 7 replies 2.3k views
Original Post
ArgusMaker
ArgusMaker
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?
Benden
Benden
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.
GregMichael
GregMichael
You can also turn on / increase the debug output via the DirectX control panel that comes with the SDK.
ArgusMaker
ArgusMaker
the first hresult converted to int is -2005529767.
Where do i find its meaning?
GregMichael
GregMichael
Check the documentation.

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

You don't say which call failed ?
Waaayoff
Waaayoff
That doesn't look like a proper error code :S

Anyway, this function translates DX errors.
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "
ArgusMaker
ArgusMaker
LNK2019: undefined reference to external symbol _DXGetErrorDescriptionA@4
Which lib do i have to link? MSDN does not specify that
Benden
Benden
Dxerr.lib
ArgusMaker
ArgusMaker
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

Topic Locked

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

Sign in to reply to this topic.