Hresult in a string
Is there a way I can get the name of the hresult in a string? im afraid im going to have to do a huge switch to test for all the possible codes.
Yep, you have to do exactly that... or you can printf("0x%x", hresult) and look ''em up by hand in the DX header files.
Mason McCuskey
Spin Studios - home of Quaternion, 2000 GDC Indie Games Fest Finalist!
www.spin-studios.com
Mason McCuskey
Spin Studios - home of Quaternion, 2000 GDC Indie Games Fest Finalist!
www.spin-studios.com
Founder, Cuttlefish Industries
The Cuttlefish Engine lets anyone develop great games for iPad, iPhone, Android, WP7, the web, and more!
The Cuttlefish Engine lets anyone develop great games for iPad, iPhone, Android, WP7, the web, and more!
If you look in the sample source, under D3DRM, in the RMEnum folder there''s a file called rmerror.c/h. There''s alot of the DD errors already defined, might save you some time. If anyone knows of a better resource (more complete with like the other possible error codes listed) please let me know.
-ns-
-ns-
-ns-
Someone posted this a while ago. I think it covers all the DirectDraw codes, for DX6 I assume. Anyway, someone might find it useful:
struct ERROR_STRUCT DDErrorList[] = {
{DDERR_ALREADYINITIALIZED ,"DDERR_ALREADYINITIALIZED"},
{DDERR_CANNOTATTACHSURFACE ,"DDERR_CANNOTATTACHSURFACE"},
{DDERR_CANNOTDETACHSURFACE ,"DDERR_CANNOTDETACHSURFACE"},
{DDERR_CURRENTLYNOTAVAIL ,"DDERR_CURRENTLYNOTAVAIL"},
{DDERR_EXCEPTION ,"DDERR_EXCEPTION"},
{DDERR_HEIGHTALIGN ,"DDERR_HEIGHTALIGN"},
{DDERR_INCOMPATIBLEPRIMARY ,"DDERR_INCOMPATIBLEPRIMARY"},
{DDERR_INVALIDCAPS ,"DDERR_INVALIDCAPS"},
{DDERR_INVALIDCLIPLIST ,"DDERR_INVALIDCLIPLIST"},
{DDERR_INVALIDMODE ,"DDERR_INVALIDMODE"},
{DDERR_INVALIDOBJECT ,"DDERR_INVALIDOBJECT"},
{DDERR_INVALIDPIXELFORMAT ,"DDERR_INVALIDPIXELFORMAT"},
{DDERR_INVALIDRECT ,"DDERR_INVALIDRECT"},
{DDERR_LOCKEDSURFACES ,"DDERR_LOCKEDSURFACES"},
{DDERR_NO3D ,"DDERR_NO3D"},
{DDERR_NOALPHAHW ,"DDERR_NOALPHAHW"},
{DDERR_NOCLIPLIST ,"DDERR_NOCLIPLIST"},
{DDERR_NOCOLORCONVHW ,"DDERR_NOCOLORCONVHW"},
{DDERR_NOCOOPERATIVELEVELSET ,"DDERR_NOCOOPERATIVELEVELSET"},
{DDERR_NOCOLORKEY ,"DDERR_NOCOLORKEY"},
{DDERR_NOCOLORKEYHW ,"DDERR_NOCOLORKEYHW"},
{DDERR_NODIRECTDRAWSUPPORT ,"DDERR_NODIRECTDRAWSUPPORT"},
{DDERR_NOEXCLUSIVEMODE ,"DDERR_NOEXCLUSIVEMODE"},
{DDERR_NOFLIPHW ,"DDERR_NOFLIPHW"},
{DDERR_NOGDI ,"DDERR_NOGDI"},
{DDERR_NOMIRRORHW ,"DDERR_NOMIRRORHW"},
{DDERR_NOTFOUND ,"DDERR_NOTFOUND"},
{DDERR_NOOVERLAYHW ,"DDERR_NOOVERLAYHW"},
{DDERR_OVERLAPPINGRECTS ,"DDERR_OVERLAPPINGRECTS"},
{DDERR_NORASTEROPHW ,"DDERR_NORASTEROPHW"},
{DDERR_NOROTATIONHW ,"DDERR_NOROTATIONHW"},
{DDERR_NOSTRETCHHW ,"DDERR_NOSTRETCHHW"},
{DDERR_NOT4BITCOLOR ,"DDERR_NOT4BITCOLOR"},
{DDERR_NOT4BITCOLORINDEX ,"DDERR_NOT4BITCOLORINDEX"},
{DDERR_NOT8BITCOLOR ,"DDERR_NOT8BITCOLOR"},
{DDERR_NOTEXTUREHW ,"DDERR_NOTEXTUREHW"},
{DDERR_NOVSYNCHW ,"DDERR_NOVSYNCHW"},
{DDERR_NOZBUFFERHW ,"DDERR_NOZBUFFERHW"},
{DDERR_NOZOVERLAYHW ,"DDERR_NOZOVERLAYHW"},
{DDERR_OUTOFCAPS ,"DDERR_OUTOFCAPS"},
{DDERR_OUTOFVIDEOMEMORY ,"DDERR_OUTOFVIDEOMEMORY"},
{DDERR_OVERLAYCANTCLIP ,"DDERR_OVERLAYCANTCLIP"},
{DDERR_OVERLAYCOLORKEYONLYONEACTIVE ,"DDERR_OVERLAYCOLORKEYONLYONEACTIVE"},
{DDERR_PALETTEBUSY ,"DDERR_PALETTEBUSY"},
{DDERR_COLORKEYNOTSET ,"DDERR_COLORKEYNOTSET"},
{DDERR_SURFACEALREADYATTACHED ,"DDERR_SURFACEALREADYATTACHED"},
{DDERR_SURFACEALREADYDEPENDENT ,"DDERR_SURFACEALREADYDEPENDENT"},
{DDERR_SURFACEBUSY ,"DDERR_SURFACEBUSY"},
{DDERR_CANTLOCKSURFACE ,"DDERR_CANTLOCKSURFACE"},
{DDERR_SURFACEISOBSCURED ,"DDERR_SURFACEISOBSCURED"},
{DDERR_SURFACELOST ,"DDERR_SURFACELOST"},
{DDERR_SURFACENOTATTACHED ,"DDERR_SURFACENOTATTACHED"},
{DDERR_TOOBIGHEIGHT ,"DDERR_TOOBIGHEIGHT"},
{DDERR_TOOBIGSIZE ,"DDERR_TOOBIGSIZE"},
{DDERR_TOOBIGWIDTH ,"DDERR_TOOBIGWIDTH"},
{DDERR_UNSUPPORTEDFORMAT ,"DDERR_UNSUPPORTEDFORMAT"},
{DDERR_UNSUPPORTEDMASK ,"DDERR_UNSUPPORTEDMASK"},
{DDERR_INVALIDSTREAM ,"DDERR_INVALIDSTREAM"},
{DDERR_VERTICALBLANKINPROGRESS ,"DDERR_VERTICALBLANKINPROGRESS"},
{DDERR_WASSTILLDRAWING ,"DDERR_WASSTILLDRAWING"},
{DDERR_XALIGN ,"DDERR_XALIGN"},
{DDERR_INVALIDDIRECTDRAWGUID ,"DDERR_INVALIDDIRECTDRAWGUID"},
{DDERR_DIRECTDRAWALREADYCREATED ,"DDERR_DIRECTDRAWALREADYCREATED"},
{DDERR_NODIRECTDRAWHW ,"DDERR_NODIRECTDRAWHW"},
{DDERR_PRIMARYSURFACEALREADYEXISTS ,"DDERR_PRIMARYSURFACEALREADYEXISTS"},
{DDERR_NOEMULATION ,"DDERR_NOEMULATION"},
{DDERR_REGIONTOOSMALL ,"DDERR_REGIONTOOSMALL"},
{DDERR_CLIPPERISUSINGHWND ,"DDERR_CLIPPERISUSINGHWND"},
{DDERR_NOCLIPPERATTACHED ,"DDERR_NOCLIPPERATTACHED"},
{DDERR_NOHWND ,"DDERR_NOHWND"},
{DDERR_HWNDSUBCLASSED ,"DDERR_HWNDSUBCLASSED"},
{DDERR_HWNDALREADYSET ,"DDERR_HWNDALREADYSET"},
{DDERR_NOPALETTEATTACHED ,"DDERR_NOPALETTEATTACHED"},
{DDERR_NOPALETTEHW ,"DDERR_NOPALETTEHW"},
{DDERR_BLTFASTCANTCLIP ,"DDERR_BLTFASTCANTCLIP"},
{DDERR_NOBLTHW ,"DDERR_NOBLTHW"},
{DDERR_NODDROPSHW ,"DDERR_NODDROPSHW"},
{DDERR_OVERLAYNOTVISIBLE ,"DDERR_OVERLAYNOTVISIBLE"},
{DDERR_NOOVERLAYDEST ,"DDERR_NOOVERLAYDEST"},
{DDERR_INVALIDPOSITION ,"DDERR_INVALIDPOSITION"},
{DDERR_NOTAOVERLAYSURFACE ,"DDERR_NOTAOVERLAYSURFACE"},
{DDERR_EXCLUSIVEMODEALREADYSET ,"DDERR_EXCLUSIVEMODEALREADYSET"},
{DDERR_NOTFLIPPABLE ,"DDERR_NOTFLIPPABLE"},
{DDERR_CANTDUPLICATE ,"DDERR_CANTDUPLICATE"},
{DDERR_NOTLOCKED ,"DDERR_NOTLOCKED"},
{DDERR_CANTCREATEDC ,"DDERR_CANTCREATEDC"},
{DDERR_NODC ,"DDERR_NODC"},
{DDERR_WRONGMODE ,"DDERR_WRONGMODE"},
{DDERR_IMPLICITLYCREATED ,"DDERR_IMPLICITLYCREATED"},
{DDERR_NOTPALETTIZED ,"DDERR_NOTPALETTIZED"},
{DDERR_UNSUPPORTEDMODE ,"DDERR_UNSUPPORTEDMODE"},
{DDERR_NOMIPMAPHW ,"DDERR_NOMIPMAPHW"},
{DDERR_INVALIDSURFACETYPE ,"DDERR_INVALIDSURFACETYPE"},
{DDERR_NOOPTIMIZEHW ,"DDERR_NOOPTIMIZEHW"},
{DDERR_NOTLOADED ,"DDERR_NOTLOADED"},
{DDERR_NOFOCUSWINDOW ,"DDERR_NOFOCUSWINDOW"},
{DDERR_DCALREADYCREATED ,"DDERR_DCALREADYCREATED"},
{DDERR_NONONLOCALVIDMEM ,"DDERR_NONONLOCALVIDMEM"},
{DDERR_CANTPAGELOCK ,"DDERR_CANTPAGELOCK"},
{DDERR_CANTPAGEUNLOCK ,"DDERR_CANTPAGEUNLOCK"},
{DDERR_NOTPAGELOCKED ,"DDERR_NOTPAGELOCKED"},
{DDERR_MOREDATA ,"DDERR_MOREDATA"},
{DDERR_EXPIRED ,"DDERR_EXPIRED"},
{DDERR_VIDEONOTACTIVE ,"DDERR_VIDEONOTACTIVE"},
{DDERR_DEVICEDOESNTOWNSURFACE ,"DDERR_DEVICEDOESNTOWNSURFACE"},
Hmm... I had a feeling I had the ones for DirectSound and Direct3D too, but cant find them now. If anyone needs them post here and I''ll have another look. You''ll have to write your own ERROR_STRUCT to use them with.
Regards
Starfall
struct ERROR_STRUCT DDErrorList[] = {
{DDERR_ALREADYINITIALIZED ,"DDERR_ALREADYINITIALIZED"},
{DDERR_CANNOTATTACHSURFACE ,"DDERR_CANNOTATTACHSURFACE"},
{DDERR_CANNOTDETACHSURFACE ,"DDERR_CANNOTDETACHSURFACE"},
{DDERR_CURRENTLYNOTAVAIL ,"DDERR_CURRENTLYNOTAVAIL"},
{DDERR_EXCEPTION ,"DDERR_EXCEPTION"},
{DDERR_HEIGHTALIGN ,"DDERR_HEIGHTALIGN"},
{DDERR_INCOMPATIBLEPRIMARY ,"DDERR_INCOMPATIBLEPRIMARY"},
{DDERR_INVALIDCAPS ,"DDERR_INVALIDCAPS"},
{DDERR_INVALIDCLIPLIST ,"DDERR_INVALIDCLIPLIST"},
{DDERR_INVALIDMODE ,"DDERR_INVALIDMODE"},
{DDERR_INVALIDOBJECT ,"DDERR_INVALIDOBJECT"},
{DDERR_INVALIDPIXELFORMAT ,"DDERR_INVALIDPIXELFORMAT"},
{DDERR_INVALIDRECT ,"DDERR_INVALIDRECT"},
{DDERR_LOCKEDSURFACES ,"DDERR_LOCKEDSURFACES"},
{DDERR_NO3D ,"DDERR_NO3D"},
{DDERR_NOALPHAHW ,"DDERR_NOALPHAHW"},
{DDERR_NOCLIPLIST ,"DDERR_NOCLIPLIST"},
{DDERR_NOCOLORCONVHW ,"DDERR_NOCOLORCONVHW"},
{DDERR_NOCOOPERATIVELEVELSET ,"DDERR_NOCOOPERATIVELEVELSET"},
{DDERR_NOCOLORKEY ,"DDERR_NOCOLORKEY"},
{DDERR_NOCOLORKEYHW ,"DDERR_NOCOLORKEYHW"},
{DDERR_NODIRECTDRAWSUPPORT ,"DDERR_NODIRECTDRAWSUPPORT"},
{DDERR_NOEXCLUSIVEMODE ,"DDERR_NOEXCLUSIVEMODE"},
{DDERR_NOFLIPHW ,"DDERR_NOFLIPHW"},
{DDERR_NOGDI ,"DDERR_NOGDI"},
{DDERR_NOMIRRORHW ,"DDERR_NOMIRRORHW"},
{DDERR_NOTFOUND ,"DDERR_NOTFOUND"},
{DDERR_NOOVERLAYHW ,"DDERR_NOOVERLAYHW"},
{DDERR_OVERLAPPINGRECTS ,"DDERR_OVERLAPPINGRECTS"},
{DDERR_NORASTEROPHW ,"DDERR_NORASTEROPHW"},
{DDERR_NOROTATIONHW ,"DDERR_NOROTATIONHW"},
{DDERR_NOSTRETCHHW ,"DDERR_NOSTRETCHHW"},
{DDERR_NOT4BITCOLOR ,"DDERR_NOT4BITCOLOR"},
{DDERR_NOT4BITCOLORINDEX ,"DDERR_NOT4BITCOLORINDEX"},
{DDERR_NOT8BITCOLOR ,"DDERR_NOT8BITCOLOR"},
{DDERR_NOTEXTUREHW ,"DDERR_NOTEXTUREHW"},
{DDERR_NOVSYNCHW ,"DDERR_NOVSYNCHW"},
{DDERR_NOZBUFFERHW ,"DDERR_NOZBUFFERHW"},
{DDERR_NOZOVERLAYHW ,"DDERR_NOZOVERLAYHW"},
{DDERR_OUTOFCAPS ,"DDERR_OUTOFCAPS"},
{DDERR_OUTOFVIDEOMEMORY ,"DDERR_OUTOFVIDEOMEMORY"},
{DDERR_OVERLAYCANTCLIP ,"DDERR_OVERLAYCANTCLIP"},
{DDERR_OVERLAYCOLORKEYONLYONEACTIVE ,"DDERR_OVERLAYCOLORKEYONLYONEACTIVE"},
{DDERR_PALETTEBUSY ,"DDERR_PALETTEBUSY"},
{DDERR_COLORKEYNOTSET ,"DDERR_COLORKEYNOTSET"},
{DDERR_SURFACEALREADYATTACHED ,"DDERR_SURFACEALREADYATTACHED"},
{DDERR_SURFACEALREADYDEPENDENT ,"DDERR_SURFACEALREADYDEPENDENT"},
{DDERR_SURFACEBUSY ,"DDERR_SURFACEBUSY"},
{DDERR_CANTLOCKSURFACE ,"DDERR_CANTLOCKSURFACE"},
{DDERR_SURFACEISOBSCURED ,"DDERR_SURFACEISOBSCURED"},
{DDERR_SURFACELOST ,"DDERR_SURFACELOST"},
{DDERR_SURFACENOTATTACHED ,"DDERR_SURFACENOTATTACHED"},
{DDERR_TOOBIGHEIGHT ,"DDERR_TOOBIGHEIGHT"},
{DDERR_TOOBIGSIZE ,"DDERR_TOOBIGSIZE"},
{DDERR_TOOBIGWIDTH ,"DDERR_TOOBIGWIDTH"},
{DDERR_UNSUPPORTEDFORMAT ,"DDERR_UNSUPPORTEDFORMAT"},
{DDERR_UNSUPPORTEDMASK ,"DDERR_UNSUPPORTEDMASK"},
{DDERR_INVALIDSTREAM ,"DDERR_INVALIDSTREAM"},
{DDERR_VERTICALBLANKINPROGRESS ,"DDERR_VERTICALBLANKINPROGRESS"},
{DDERR_WASSTILLDRAWING ,"DDERR_WASSTILLDRAWING"},
{DDERR_XALIGN ,"DDERR_XALIGN"},
{DDERR_INVALIDDIRECTDRAWGUID ,"DDERR_INVALIDDIRECTDRAWGUID"},
{DDERR_DIRECTDRAWALREADYCREATED ,"DDERR_DIRECTDRAWALREADYCREATED"},
{DDERR_NODIRECTDRAWHW ,"DDERR_NODIRECTDRAWHW"},
{DDERR_PRIMARYSURFACEALREADYEXISTS ,"DDERR_PRIMARYSURFACEALREADYEXISTS"},
{DDERR_NOEMULATION ,"DDERR_NOEMULATION"},
{DDERR_REGIONTOOSMALL ,"DDERR_REGIONTOOSMALL"},
{DDERR_CLIPPERISUSINGHWND ,"DDERR_CLIPPERISUSINGHWND"},
{DDERR_NOCLIPPERATTACHED ,"DDERR_NOCLIPPERATTACHED"},
{DDERR_NOHWND ,"DDERR_NOHWND"},
{DDERR_HWNDSUBCLASSED ,"DDERR_HWNDSUBCLASSED"},
{DDERR_HWNDALREADYSET ,"DDERR_HWNDALREADYSET"},
{DDERR_NOPALETTEATTACHED ,"DDERR_NOPALETTEATTACHED"},
{DDERR_NOPALETTEHW ,"DDERR_NOPALETTEHW"},
{DDERR_BLTFASTCANTCLIP ,"DDERR_BLTFASTCANTCLIP"},
{DDERR_NOBLTHW ,"DDERR_NOBLTHW"},
{DDERR_NODDROPSHW ,"DDERR_NODDROPSHW"},
{DDERR_OVERLAYNOTVISIBLE ,"DDERR_OVERLAYNOTVISIBLE"},
{DDERR_NOOVERLAYDEST ,"DDERR_NOOVERLAYDEST"},
{DDERR_INVALIDPOSITION ,"DDERR_INVALIDPOSITION"},
{DDERR_NOTAOVERLAYSURFACE ,"DDERR_NOTAOVERLAYSURFACE"},
{DDERR_EXCLUSIVEMODEALREADYSET ,"DDERR_EXCLUSIVEMODEALREADYSET"},
{DDERR_NOTFLIPPABLE ,"DDERR_NOTFLIPPABLE"},
{DDERR_CANTDUPLICATE ,"DDERR_CANTDUPLICATE"},
{DDERR_NOTLOCKED ,"DDERR_NOTLOCKED"},
{DDERR_CANTCREATEDC ,"DDERR_CANTCREATEDC"},
{DDERR_NODC ,"DDERR_NODC"},
{DDERR_WRONGMODE ,"DDERR_WRONGMODE"},
{DDERR_IMPLICITLYCREATED ,"DDERR_IMPLICITLYCREATED"},
{DDERR_NOTPALETTIZED ,"DDERR_NOTPALETTIZED"},
{DDERR_UNSUPPORTEDMODE ,"DDERR_UNSUPPORTEDMODE"},
{DDERR_NOMIPMAPHW ,"DDERR_NOMIPMAPHW"},
{DDERR_INVALIDSURFACETYPE ,"DDERR_INVALIDSURFACETYPE"},
{DDERR_NOOPTIMIZEHW ,"DDERR_NOOPTIMIZEHW"},
{DDERR_NOTLOADED ,"DDERR_NOTLOADED"},
{DDERR_NOFOCUSWINDOW ,"DDERR_NOFOCUSWINDOW"},
{DDERR_DCALREADYCREATED ,"DDERR_DCALREADYCREATED"},
{DDERR_NONONLOCALVIDMEM ,"DDERR_NONONLOCALVIDMEM"},
{DDERR_CANTPAGELOCK ,"DDERR_CANTPAGELOCK"},
{DDERR_CANTPAGEUNLOCK ,"DDERR_CANTPAGEUNLOCK"},
{DDERR_NOTPAGELOCKED ,"DDERR_NOTPAGELOCKED"},
{DDERR_MOREDATA ,"DDERR_MOREDATA"},
{DDERR_EXPIRED ,"DDERR_EXPIRED"},
{DDERR_VIDEONOTACTIVE ,"DDERR_VIDEONOTACTIVE"},
{DDERR_DEVICEDOESNTOWNSURFACE ,"DDERR_DEVICEDOESNTOWNSURFACE"},
Hmm... I had a feeling I had the ones for DirectSound and Direct3D too, but cant find them now. If anyone needs them post here and I''ll have another look. You''ll have to write your own ERROR_STRUCT to use them with.
Regards
Starfall
In my error handler Im also going to need the line and file name info. In msvc ,which im using, I think if you pass --LINE-- into the function it will be the line number. Not sure though, and Is there one for the filename it came from?
__LINE__ is a macro to get the line number, and __FILE__ is a macro to get the filename, they can both be used as strings. You can also use the macros:
__DATE__: the date
__TIMESTAMP__: the last modification date of the current file, and
__STDC__: tells whether or not the file is being compiled with full ANSI compatibility.
-----------------------------
"And I write and I write and I don't believe it's gonna change today"
- From Yellow Ledbetter by Pearl Jam
http://www.crosswinds.net/~uselessknowledge
__DATE__: the date
__TIMESTAMP__: the last modification date of the current file, and
__STDC__: tells whether or not the file is being compiled with full ANSI compatibility.
-----------------------------
"And I write and I write and I don't believe it's gonna change today"
- From Yellow Ledbetter by Pearl Jam
http://www.crosswinds.net/~uselessknowledge
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement