Outputting DirectX Error Codes

Started by
5 comments, last by reaptide 23 years, 11 months ago
Hello everyone, I''m rather new to Win32 programming and have a question about outputting my Direct X error codes. Right now I''m using the following code to to give a generic error message if something doesn''t work:
    
ddrval = lpDD->CreateSurface(&ddsdPrimary, &lpDDSPrimary, NULL);
	if (ddrval != DD_OK)
	{
		MessageBox(hWnd, "Could not create primary surface", "Display Initialization Error", MB_OK / MB_ICONINFORMATION);
		return FALSE;
	}
    
What I would like to know is if there is a way to output ddrval to a message box, I can''t seem to find one. Also if there is a better way to do this, I''d be more than happy to use it. Thanks for any input, Derek Sauer reaptide@my-deja.com
Advertisement
You could try using switch/case and checking for each of the possible errors and use the corresponding error in the messagebox, but, of course, that would be a bit taxing. Not to mention annoying.

And I doubt that you could convert an HRESULT to a char*. If that was to work then you could use it in MessageBox(). Otherwise, switch/case is all I can try and recommend. Sorry if I couldn''t be of any help.

"Remember, I'm the monkey, and you're the cheese grater. So no messing around."
-Grand Theft Auto, London

"It's not whether I win or lose, as long as I piss you off"
-Morrigan, Super Puzzle Fighter II Turbo
D:
I don''t know if this is the best way of doing it, but I have a function called GetDDrawHRESULT(HRESULT hr) (I''m asuming that ddrval is a HRESULT) that goes something like this:

switch(hr)
{
case DDERR_OUTOFVIDEMEMORY:
OutputDebugString("DDERR_OUTOFVIDEOMEMORY\n");
break;
.
.
.
case DDDERR_GENERIC:
OutputDebugString("DDERRR_GENERIC\n");
break;
}

It''s a LOT of work putting the function together but it saves hours of debugging work.


/Carl-Magnus Nordin
Thanks Carl-Magnus,

I think I will use your method. It is a bit of a pain to setup but once you got it, you never need to do it again.



"Nih!!!"
It's actually not that much work with a little copy pasting from the DirectX SDK and a little help from Macros.

Here is my function. Just use it!! Replace the "m_Debug.MessageToFile(" with your own routine using the visual C++ replace option. It's simple.

m_Result is a standard HRESULT

________________________________________________________

	if ( m_Result == D3D_OK ) { m_Debug.MessageToFile( "No error occurred." ); return; }	if ( m_Result == D3DERR_BADMAJORVERSION ) { m_Debug.MessageToFile( "The service that you requested is unavailable in this major version of DirectX. (A major version denotes a primary release, such as DirectX 6.0.) " ); return; }	if ( m_Result == D3DERR_BADMINORVERSION ) { m_Debug.MessageToFile( "The service that you requested is available in this major version of DirectX, but not in this minor version. Get the latest version of the component run time from Microsoft. (A minor version denotes a secondary release, such as DirectX 6.1.) " ); return; }	if ( m_Result == D3DERR_COLORKEYATTACHED ) { m_Debug.MessageToFile( "The application attempted to create a texture with a surface that uses a color key for transparency. " ); return; }	if ( m_Result == D3DERR_CONFLICTINGTEXTUREFILTER ) { m_Debug.MessageToFile( "The current texture filters cannot be used together. " ); return; }	if ( m_Result == D3DERR_CONFLICTINGTEXTUREPALETTE ) { m_Debug.MessageToFile( "The current textures cannot be used simultaneously. This generally occurs when a multitexture device requires that all palettized textures simultaneously enabled also share the same palette. " ); return; }	if ( m_Result == D3DERR_CONFLICTINGRENDERSTATE ) { m_Debug.MessageToFile( "The currently set render states cannot be used together. " ); return; }	if ( m_Result == D3DERR_DEVICEAGGREGATED ) { m_Debug.MessageToFile( "The IDirect3DDevice7::SetRenderTarget method was called on a device that was retrieved from the render target surface. " ); return; }	if ( m_Result == D3DERR_EXECUTE_CLIPPED_FAILED ) { m_Debug.MessageToFile( "The execute buffer could not be clipped during execution. " ); return; }	if ( m_Result == D3DERR_EXECUTE_CREATE_FAILED ) { m_Debug.MessageToFile( "The execute buffer could not be created. This typically occurs when no memory is available to allocate the execute buffer. " ); return; }	if ( m_Result == D3DERR_EXECUTE_DESTROY_FAILED ) { m_Debug.MessageToFile( "The memory for the execute buffer could not be deallocated. " ); return; }	if ( m_Result == D3DERR_EXECUTE_FAILED ) { m_Debug.MessageToFile( "The contents of the execute buffer are invalid and cannot be executed. " ); return; }	if ( m_Result == D3DERR_EXECUTE_LOCK_FAILED ) { m_Debug.MessageToFile( "The execute buffer could not be locked. " ); return; }	if ( m_Result == D3DERR_EXECUTE_LOCKED ) { m_Debug.MessageToFile( "The operation requested by the application could not be completed because the execute buffer is locked. " ); return; }	if ( m_Result == D3DERR_EXECUTE_NOT_LOCKED ) { m_Debug.MessageToFile( "The execute buffer could not be unlocked because it is not currently locked. " ); return; }	if ( m_Result == D3DERR_EXECUTE_UNLOCK_FAILED ) { m_Debug.MessageToFile( "The execute buffer could not be unlocked. " ); return; }	if ( m_Result == D3DERR_INBEGIN ) { m_Debug.MessageToFile( "The requested operation cannot be completed while scene rendering is taking place. Try again after the scene is completed and the IDirect3DDevice7::EndScene method is called. " ); return; }	if ( m_Result == D3DERR_INBEGINSTATEBLOCK ) { m_Debug.MessageToFile( "The operation cannot be completed while recording states for a state block. Complete recording by calling the IDirect3DDevice7::EndStateBlock method, and try again. " ); return; }	if ( m_Result == D3DERR_INITFAILED ) { m_Debug.MessageToFile( "A rendering device could not be created because the new device could not be initialized. " ); return; }	if ( m_Result == D3DERR_INVALID_DEVICE ) { m_Debug.MessageToFile( "The requested device type is not valid. " ); return; }	if ( m_Result == D3DERR_INVALIDCURRENTVIEWPORT ) { m_Debug.MessageToFile( "The currently selected viewport is not valid. " ); return; }	if ( m_Result == D3DERR_INVALIDMATRIX ) { m_Debug.MessageToFile( "The requested operation could not be completed because the combination of the currently set world, view, and projection matrices is invalid (the determinant of the combined matrix is 0). " ); return; }	if ( m_Result == D3DERR_INVALIDPALETTE ) { m_Debug.MessageToFile( "The palette associated with a surface is invalid. " ); return; }	if ( m_Result == D3DERR_INVALIDPRIMITIVETYPE ) { m_Debug.MessageToFile( "The primitive type specified by the application is invalid. " ); return; }	if ( m_Result == D3DERR_INVALIDRAMPTEXTURE ) { m_Debug.MessageToFile( "Ramp mode is being used, and the texture handle in the current material does not match the current texture handle that is set as a render state. " ); return; }	if ( m_Result == D3DERR_INVALIDSTATEBLOCK ) { m_Debug.MessageToFile( "The state block handle is invalid. " ); return; }	if ( m_Result == D3DERR_INVALIDVERTEXFORMAT ) { m_Debug.MessageToFile( "The combination of flexible vertex format flags specified by the application is not valid. " ); return; }	if ( m_Result == D3DERR_INVALIDVERTEXTYPE ) { m_Debug.MessageToFile( "The vertex type specified by the application is invalid. " ); return; }	if ( m_Result == D3DERR_LIGHT_SET_FAILED ) { m_Debug.MessageToFile( "The attempt to set lighting parameters for a light object failed. " ); return; }	if ( m_Result == D3DERR_LIGHTHASVIEWPORT ) { m_Debug.MessageToFile( "The requested operation failed because the light object is associated with another viewport. " ); return; }	if ( m_Result == D3DERR_LIGHTNOTINTHISVIEWPORT ) { m_Debug.MessageToFile( "The requested operation failed because the light object has not been associated with this viewport. " ); return; }	if ( m_Result == D3DERR_MATERIAL_CREATE_FAILED ) { m_Debug.MessageToFile( "The material could not be created. This typically occurs when no memory is available to allocate for the material. " ); return; }	if ( m_Result == D3DERR_MATERIAL_DESTROY_FAILED ) { m_Debug.MessageToFile( "The memory for the material could not be deallocated. " ); return; }	if ( m_Result == D3DERR_MATERIAL_GETDATA_FAILED ) { m_Debug.MessageToFile( "The material parameters could not be retrieved. " ); return; }	if ( m_Result == D3DERR_MATERIAL_SETDATA_FAILED ) { m_Debug.MessageToFile( "The material parameters could not be set. " ); return; }	if ( m_Result == D3DERR_MATRIX_CREATE_FAILED ) { m_Debug.MessageToFile( "The matrix could not be created. This can occur when no memory is available to allocate for the matrix. " ); return; }	if ( m_Result == D3DERR_MATRIX_DESTROY_FAILED ) { m_Debug.MessageToFile( "The memory for the matrix could not be deallocated. " ); return; }	if ( m_Result == D3DERR_MATRIX_GETDATA_FAILED ) { m_Debug.MessageToFile( "The matrix data could not be retrieved. This can occur when the matrix was not created by the current device. " ); return; }	if ( m_Result == D3DERR_MATRIX_SETDATA_FAILED ) { m_Debug.MessageToFile( "The matrix data could not be set. This can occur when the matrix was not created by the current device. " ); return; }	if ( m_Result == D3DERR_NOCURRENTVIEWPORT ) { m_Debug.MessageToFile( "The viewport parameters could not be retrieved because none have been set. " ); return; }	if ( m_Result == D3DERR_NOTINBEGIN ) { m_Debug.MessageToFile( "The requested rendering operation could not be completed because scene rendering has not begun. Call IDirect3DDevice7::BeginScene to begin rendering, and try again. " ); return; }	if ( m_Result == D3DERR_NOTINBEGINSTATEBLOCK ) { m_Debug.MessageToFile( "The requested operation could not be completed because it is only valid while recording a state block. Call the IDirect3DDevice7::BeginStateBlock method, and try again. " ); return; }	if ( m_Result == D3DERR_NOVIEWPORTS ) { m_Debug.MessageToFile( "The requested operation failed because the device currently has no viewports associated with it. " ); return; }	if ( m_Result == D3DERR_SCENE_BEGIN_FAILED ) { m_Debug.MessageToFile( "Scene rendering could not begin. " ); return; }	if ( m_Result == D3DERR_SCENE_END_FAILED ) { m_Debug.MessageToFile( "Scene rendering could not be completed. " ); return; }	if ( m_Result == D3DERR_SCENE_IN_SCENE ) { m_Debug.MessageToFile( "Scene rendering could not begin because a previous scene was not completed by a call to the IDirect3DDevice7::EndScene method. " ); return; }	if ( m_Result == D3DERR_SCENE_NOT_IN_SCENE ) { m_Debug.MessageToFile( "Scene rendering could not be completed because a scene was not started by a previous call to the IDirect3DDevice7::BeginScene method. " ); return; }	if ( m_Result == D3DERR_SETVIEWPORTDATA_FAILED ) { m_Debug.MessageToFile( "The viewport parameters could not be set. " ); return; }	if ( m_Result == D3DERR_STENCILBUFFER_NOTPRESENT ) { m_Debug.MessageToFile( "The requested stencil buffer operation could not be completed because there is no stencil buffer attached to the render target surface. " ); return; }	if ( m_Result == D3DERR_SURFACENOTINVIDMEM ) { m_Debug.MessageToFile( "The device could not be created because the render target surface is not located in video memory. (Hardware-accelerated devices require video-memory render target surfaces.) " ); return; }	if ( m_Result == D3DERR_TEXTURE_BADSIZE ) { m_Debug.MessageToFile( "The dimensions of a current texture are invalid. This can occur when an application attempts to use a texture that has dimensions that are not a power of 2 with a device that requires them. " ); return; }	if ( m_Result == D3DERR_TEXTURE_CREATE_FAILED ) { m_Debug.MessageToFile( "The texture handle for the texture could not be retrieved from the driver. " ); return; }	if ( m_Result == D3DERR_TEXTURE_DESTROY_FAILED ) { m_Debug.MessageToFile( "The device was unable to deallocate the texture memory. " ); return; }	if ( m_Result == D3DERR_TEXTURE_GETSURF_FAILED ) { m_Debug.MessageToFile( "The DirectDraw surface used to create the texture could not be retrieved. " ); return; }	if ( m_Result == D3DERR_TEXTURE_LOAD_FAILED ) { m_Debug.MessageToFile( "The texture could not be loaded. " ); return; }	if ( m_Result == D3DERR_TEXTURE_LOCK_FAILED ) { m_Debug.MessageToFile( "The texture could not be locked. " ); return; }	if ( m_Result == D3DERR_TEXTURE_LOCKED ) { m_Debug.MessageToFile( "The requested operation could not be completed because the texture surface is currently locked. " ); return; }	if ( m_Result == D3DERR_TEXTURE_NO_SUPPORT ) { m_Debug.MessageToFile( "The device does not support texture mapping. " ); return; }	if ( m_Result == D3DERR_TEXTURE_NOT_LOCKED ) { m_Debug.MessageToFile( "The requested operation could not be completed because the texture surface is not locked. " ); return; }	if ( m_Result == D3DERR_TEXTURE_SWAP_FAILED ) { m_Debug.MessageToFile( "The texture handles could not be swapped. " ); return; }	if ( m_Result == D3DERR_TEXTURE_UNLOCK_FAILED ) { m_Debug.MessageToFile( "The texture surface could not be unlocked. " ); return; }	if ( m_Result == D3DERR_TOOMANYOPERATIONS ) { m_Debug.MessageToFile( "The application is requesting more texture-filtering operations than the device supports. " ); return; }	if ( m_Result == D3DERR_TOOMANYPRIMITIVES ) { m_Debug.MessageToFile( "The device is unable to render the provided number of primitives in a single pass. " ); return; }	if ( m_Result == D3DERR_UNSUPPORTEDALPHAARG ) { m_Debug.MessageToFile( "The device does not support one of the specified texture-blending arguments for the alpha channel. " ); return; }	if ( m_Result == D3DERR_UNSUPPORTEDALPHAOPERATION ) { m_Debug.MessageToFile( "The device does not support one of the specified texture-blending operations for the alpha channel. " ); return; }	if ( m_Result == D3DERR_UNSUPPORTEDCOLORARG ) { m_Debug.MessageToFile( "The device does not support one of the specified texture-blending arguments for color values. " ); return; }	if ( m_Result == D3DERR_UNSUPPORTEDCOLOROPERATION ) { m_Debug.MessageToFile( "The device does not support one of the specified texture-blending operations for color values. " ); return; }	if ( m_Result == D3DERR_UNSUPPORTEDFACTORVALUE ) { m_Debug.MessageToFile( "The specified texture factor value is not supported by the device. " ); return; }	if ( m_Result == D3DERR_UNSUPPORTEDTEXTUREFILTER ) { m_Debug.MessageToFile( "The specified texture filter is not supported by the device. " ); return; }	if ( m_Result == D3DERR_VBUF_CREATE_FAILED ) { m_Debug.MessageToFile( "The vertex buffer could not be created. This can happen when there is insufficient memory to allocate a vertex buffer. " ); return; }	if ( m_Result == D3DERR_VERTEXBUFFERLOCKED ) { m_Debug.MessageToFile( "The requested operation could not be completed because the vertex buffer is locked. " ); return; }	if ( m_Result == D3DERR_VERTEXBUFFEROPTIMIZED ) { m_Debug.MessageToFile( "The requested operation could not be completed because the vertex buffer is optimized. (The contents of optimized vertex buffers are driver-specific and considered private.) " ); return; }	if ( m_Result == D3DERR_VERTEXBUFFERUNLOCKFAILED ) { m_Debug.MessageToFile( "The vertex buffer could not be unlocked because the vertex buffer memory was overrun. Be sure that your application does not write beyond the size of the vertex buffer. " ); return; }	if ( m_Result == D3DERR_VIEWPORTDATANOTSET ) { m_Debug.MessageToFile( "The requested operation could not be completed because viewport parameters have not yet been set. Set the viewport parameters by calling the IDirect3DDevice7::SetViewport method, and try again. " ); return; }	if ( m_Result == D3DERR_VIEWPORTHASNODEVICE ) { m_Debug.MessageToFile( "The requested operation could not be completed because the viewport has not yet been associated with a device. Associate the viewport with a rendering device by calling the IDirect3DDevice3::AddViewport method, and try again. " ); return; }	if ( m_Result == D3DERR_WRONGTEXTUREFORMAT ) { m_Debug.MessageToFile( "The pixel format of the texture surface is not valid. " ); return; }	if ( m_Result == D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY ) { m_Debug.MessageToFile( "The requested operation could not be completed because the specified device requires system-memory depth-buffer surfaces. (Software rendering devices require system-memory depth buffers.) " ); return; }	if ( m_Result == D3DERR_ZBUFF_NEEDS_VIDEOMEMORY ) { m_Debug.MessageToFile( "The requested operation could not be completed because the specified device requires video-memory depth-buffer surfaces. (Hardware-accelerated devices require video-memory depth buffers.) " ); return; }	if ( m_Result == D3DERR_ZBUFFER_NOTPRESENT ) { m_Debug.MessageToFile( "The requested operation could not be completed because the render target surface does not have an attached depth buffer. " ); return; }	if ( m_Result == DD_OK ) { m_Debug.MessageToFile( "The request completed successfully." ); return; }	if ( m_Result == DDERR_ALREADYINITIALIZED ) { m_Debug.MessageToFile( "The object has already been initialized." ); return; }	if ( m_Result == DDERR_BLTFASTCANTCLIP ) { m_Debug.MessageToFile( "A DirectDrawClipper object is attached to a source surface that has passed into a call to the IDirectDrawSurface7::BltFast method." ); return; }	if ( m_Result == DDERR_CANNOTATTACHSURFACE ) { m_Debug.MessageToFile( "A surface cannot be attached to another requested surface." ); return; }	if ( m_Result == DDERR_CANNOTDETACHSURFACE ) { m_Debug.MessageToFile( "A surface cannot be detached from another requested surface." ); return; }	if ( m_Result == DDERR_CANTCREATEDC ) { m_Debug.MessageToFile( "Windows cannot create any more device contexts (DCs), or a DC has requested a palette-indexed surface when the surface had no palette and the display mode was not palette-indexed (in this case DirectDraw cannot select a proper palette into the DC)." ); return; }	if ( m_Result == DDERR_CANTDUPLICATE ) { m_Debug.MessageToFile( "Primary and 3-D surfaces, or surfaces that are implicitly created, cannot be duplicated." ); return; }	if ( m_Result == DDERR_CANTLOCKSURFACE ) { m_Debug.MessageToFile( "Access to this surface is refused because an attempt was made to lock the primary surface without DCI support." ); return; }	if ( m_Result == DDERR_CANTPAGELOCK ) { m_Debug.MessageToFile( "An attempt to page-lock a surface failed. Page lock does not work on a display-memory surface or an emulated primary surface." ); return; }	if ( m_Result == DDERR_CANTPAGEUNLOCK ) { m_Debug.MessageToFile( "An attempt to page-unlock a surface failed. Page unlock does not work on a display-memory surface or an emulated primary surface." ); return; }	if ( m_Result == DDERR_CLIPPERISUSINGHWND ) { m_Debug.MessageToFile( "An attempt was made to set a clip list for a DirectDrawClipper object that is already monitoring a window handle." ); return; }	if ( m_Result == DDERR_COLORKEYNOTSET ) { m_Debug.MessageToFile( "No source color key is specified for this operation." ); return; }	if ( m_Result == DDERR_CURRENTLYNOTAVAIL ) { m_Debug.MessageToFile( "No support is currently available." ); return; }	if ( m_Result == DDERR_DDSCAPSCOMPLEXREQUIRED ) { m_Debug.MessageToFile( "New for DirectX 7.0. The surface requires the DDSCAPS_COMPLEX flag." ); return; }	if ( m_Result == DDERR_DCALREADYCREATED ) { m_Debug.MessageToFile( "A device context (DC) has already been returned for this surface. Only one DC can be retrieved for each surface." ); return; }	if ( m_Result == DDERR_DEVICEDOESNTOWNSURFACE ) { m_Debug.MessageToFile( "Surfaces created by one DirectDraw device cannot be used directly by another DirectDraw device." ); return; }	if ( m_Result == DDERR_DIRECTDRAWALREADYCREATED ) { m_Debug.MessageToFile( "A DirectDraw object representing this driver has already been created for this process." ); return; }	if ( m_Result == DDERR_EXCEPTION ) { m_Debug.MessageToFile( "An exception was encountered while performing the requested operation." ); return; }	if ( m_Result == DDERR_EXCLUSIVEMODEALREADYSET ) { m_Debug.MessageToFile( "An attempt was made to set the cooperative level when it was already set to exclusive." ); return; }	if ( m_Result == DDERR_EXPIRED ) { m_Debug.MessageToFile( "The data has expired and is therefore no longer valid." ); return; }	if ( m_Result == DDERR_GENERIC ) { m_Debug.MessageToFile( "There is an undefined error condition." ); return; }	if ( m_Result == DDERR_HEIGHTALIGN ) { m_Debug.MessageToFile( "The height of the provided rectangle is not a multiple of the required alignment." ); return; }	if ( m_Result == DDERR_HWNDALREADYSET ) { m_Debug.MessageToFile( "The DirectDraw cooperative-level window handle has already been set. It cannot be reset while the process has surfaces or palettes created." ); return; }	if ( m_Result == DDERR_HWNDSUBCLASSED ) { m_Debug.MessageToFile( "DirectDraw is prevented from restoring state because the DirectDraw cooperative-level window handle has been subclassed." ); return; }	if ( m_Result == DDERR_IMPLICITLYCREATED ) { m_Debug.MessageToFile( "The surface cannot be restored because it is an implicitly created surface." ); return; }	if ( m_Result == DDERR_INCOMPATIBLEPRIMARY ) { m_Debug.MessageToFile( "The primary surface creation request does not match the existing primary surface." ); return; }	if ( m_Result == DDERR_INVALIDCAPS ) { m_Debug.MessageToFile( "One or more of the capability bits passed to the callback function are incorrect." ); return; }	if ( m_Result == DDERR_INVALIDCLIPLIST ) { m_Debug.MessageToFile( "DirectDraw does not support the provided clip list." ); return; }	if ( m_Result == DDERR_INVALIDDIRECTDRAWGUID ) { m_Debug.MessageToFile( "The globally unique identifier (GUID) passed to the DirectDrawCreate function is not a valid DirectDraw driver identifier." ); return; }	if ( m_Result == DDERR_INVALIDMODE ) { m_Debug.MessageToFile( "DirectDraw does not support the requested mode." ); return; }	if ( m_Result == DDERR_INVALIDOBJECT ) { m_Debug.MessageToFile( "DirectDraw received a pointer that was an invalid DirectDraw object." ); return; }	if ( m_Result == DDERR_INVALIDPARAMS ) { m_Debug.MessageToFile( "One or more of the parameters passed to the method are incorrect." ); return; }	if ( m_Result == DDERR_INVALIDPIXELFORMAT ) { m_Debug.MessageToFile( "The pixel format was invalid as specified." ); return; }	if ( m_Result == DDERR_INVALIDPOSITION ) { m_Debug.MessageToFile( "The position of the overlay on the destination is no longer legal." ); return; }	if ( m_Result == DDERR_INVALIDRECT ) { m_Debug.MessageToFile( "The provided rectangle was invalid." ); return; }	if ( m_Result == DDERR_INVALIDSTREAM ) { m_Debug.MessageToFile( "The specified stream contains invalid data." ); return; }	if ( m_Result == DDERR_INVALIDSURFACETYPE ) { m_Debug.MessageToFile( "The surface was of the wrong type." ); return; }	if ( m_Result == DDERR_LOCKEDSURFACES ) { m_Debug.MessageToFile( "One or more surfaces are locked, causing the failure of the requested operation." ); return; }	if ( m_Result == DDERR_MOREDATA ) { m_Debug.MessageToFile( "There is more data available than the specified buffer size can hold." ); return; }	if ( m_Result == DDERR_NEWMODE ) { m_Debug.MessageToFile( "New for DirectX 7.0. When IDirectDraw7::StartModeTest is called with the DDSMT_ISTESTREQUIRED flag, it may return this value to denote that some or all of the resolutions can and should be tested. IDirectDraw7::EvaluateMode returns this value to indicate that the test has switched to a new display mode." ); return; }	if ( m_Result == DDERR_NO3D ) { m_Debug.MessageToFile( "No 3-D hardware or emulation is present." ); return; }	if ( m_Result == DDERR_NOALPHAHW ) { m_Debug.MessageToFile( "No alpha-acceleration hardware is present or available, causing the failure of the requested operation." ); return; }	if ( m_Result == DDERR_NOBLTHW ) { m_Debug.MessageToFile( "No blitter hardware is present." ); return; }	if ( m_Result == DDERR_NOCLIPLIST ) { m_Debug.MessageToFile( "No clip list is available." ); return; }	if ( m_Result == DDERR_NOCLIPPERATTACHED ) { m_Debug.MessageToFile( "No DirectDrawClipper object is attached to the surface object." ); return; }	if ( m_Result == DDERR_NOCOLORCONVHW ) { m_Debug.MessageToFile( "No color-conversion hardware is present or available." ); return; }	if ( m_Result == DDERR_NOCOLORKEY ) { m_Debug.MessageToFile( "The surface does not currently have a color key." ); return; }	if ( m_Result == DDERR_NOCOLORKEYHW ) { m_Debug.MessageToFile( "There is no hardware support for the destination color key." ); return; }	if ( m_Result == DDERR_NOCOOPERATIVELEVELSET ) { m_Debug.MessageToFile( "A create function was called without the IDirectDraw7::SetCooperativeLevel method." ); return; }	if ( m_Result == DDERR_NODC ) { m_Debug.MessageToFile( "No device context (DC) has ever been created for this surface." ); return; }	if ( m_Result == DDERR_NODDROPSHW ) { m_Debug.MessageToFile( "No DirectDraw raster-operation (ROP) hardware is available." ); return; }	if ( m_Result == DDERR_NODIRECTDRAWHW ) { m_Debug.MessageToFile( "Hardware-only DirectDraw object creation is not possible; the driver does not support any hardware." ); return; }	if ( m_Result == DDERR_NODIRECTDRAWSUPPORT ) { m_Debug.MessageToFile( "DirectDraw support is not possible with the current display driver." ); return; }	if ( m_Result == DDERR_NODRIVERSUPPORT ) { m_Debug.MessageToFile( "New for DirectX 7.0. Testing cannot proceed because the display adapter driver does not enumerate refresh rates." ); return; }	if ( m_Result == DDERR_NOEMULATION ) { m_Debug.MessageToFile( "Software emulation is not available." ); return; }	if ( m_Result == DDERR_NOEXCLUSIVEMODE ) { m_Debug.MessageToFile( "The operation requires the application to have exclusive mode, but the application does not have exclusive mode." ); return; }	if ( m_Result == DDERR_NOFLIPHW ) { m_Debug.MessageToFile( "Flipping visible surfaces is not supported." ); return; }	if ( m_Result == DDERR_NOFOCUSWINDOW ) { m_Debug.MessageToFile( "An attempt was made to create or set a device window without first setting the focus window." ); return; }	if ( m_Result == DDERR_NOGDI ) { m_Debug.MessageToFile( "No GDI is present." ); return; }	if ( m_Result == DDERR_NOHWND ) { m_Debug.MessageToFile( "Clipper notification requires a window handle, or no window handle has been previously set as the cooperative level window handle." ); return; }	if ( m_Result == DDERR_NOMIPMAPHW ) { m_Debug.MessageToFile( "No mipmap-capable texture mapping hardware is present or available." ); return; }	if ( m_Result == DDERR_NOMIRRORHW ) { m_Debug.MessageToFile( "No mirroring hardware is present or available." ); return; }	if ( m_Result == DDERR_NOMONITORINFORMATION ) { m_Debug.MessageToFile( "New for DirectX 7.0. Testing cannot proceed because the monitor has no associated EDID data." ); return; }	if ( m_Result == DDERR_NONONLOCALVIDMEM ) { m_Debug.MessageToFile( "An attempt was made to allocate nonlocal video memory from a device that does not support nonlocal video memory." ); return; }	if ( m_Result == DDERR_NOOPTIMIZEHW ) { m_Debug.MessageToFile( "The device does not support optimized surfaces." ); return; }	if ( m_Result == DDERR_NOOVERLAYDEST ) { m_Debug.MessageToFile( "The IDirectDrawSurface7::GetOverlayPosition method is called on an overlay that the IDirectDrawSurface7::UpdateOverlay method has not been called on to establish as a destination." ); return; }	if ( m_Result == DDERR_NOOVERLAYHW ) { m_Debug.MessageToFile( "No overlay hardware is present or available." ); return; }	if ( m_Result == DDERR_NOPALETTEATTACHED ) { m_Debug.MessageToFile( "No palette object is attached to this surface." ); return; }	if ( m_Result == DDERR_NOPALETTEHW ) { m_Debug.MessageToFile( "There is no hardware support for 16- or 256-color palettes." ); return; }	if ( m_Result == DDERR_NORASTEROPHW ) { m_Debug.MessageToFile( "No appropriate raster-operation hardware is present or available." ); return; }	if ( m_Result == DDERR_NOROTATIONHW ) { m_Debug.MessageToFile( "No rotation hardware is present or available." ); return; }	if ( m_Result == DDERR_NOSTEREOHARDWARE ) { m_Debug.MessageToFile( "There is no stereo hardware present or available." ); return; }	if ( m_Result == DDERR_NOSTRETCHHW ) { m_Debug.MessageToFile( "There is no hardware support for stretching." ); return; }	if ( m_Result == DDERR_NOSURFACELEFT ) { m_Debug.MessageToFile( "There is no hardware present that supports stereo surfaces." ); return; }	if ( m_Result == DDERR_NOT4BITCOLOR ) { m_Debug.MessageToFile( "The DirectDrawSurface object is not using a 4-bit color palette, and the requested operation requires a 4-bit color palette." ); return; }	if ( m_Result == DDERR_NOT4BITCOLORINDEX ) { m_Debug.MessageToFile( "The DirectDrawSurface object is not using a 4-bit color index palette, and the requested operation requires a 4-bit color index palette." ); return; }	if ( m_Result == DDERR_NOT8BITCOLOR ) { m_Debug.MessageToFile( "The DirectDrawSurface object is not using an 8-bit color palette, and the requested operation requires an 8-bit color palette." ); return; }	if ( m_Result == DDERR_NOTAOVERLAYSURFACE ) { m_Debug.MessageToFile( "An overlay component is called for a nonoverlay surface." ); return; }	if ( m_Result == DDERR_NOTEXTUREHW ) { m_Debug.MessageToFile( "The operation cannot be carried out because no texture-mapping hardware is present or available." ); return; }	if ( m_Result == DDERR_NOTFLIPPABLE ) { m_Debug.MessageToFile( "An attempt was made to flip a surface that cannot be flipped." ); return; }	if ( m_Result == DDERR_NOTFOUND ) { m_Debug.MessageToFile( "The requested item was not found." ); return; }	if ( m_Result == DDERR_NOTINITIALIZED ) { m_Debug.MessageToFile( "An attempt was made to call an interface method of a DirectDraw object created by CoCreateInstance before the object was initialized." ); return; }	if ( m_Result == DDERR_NOTLOADED ) { m_Debug.MessageToFile( "The surface is an optimized surface, but it has not yet been allocated any memory." ); return; }	if ( m_Result == DDERR_NOTLOCKED ) { m_Debug.MessageToFile( "An attempt was made to unlock a surface that was not locked." ); return; }	if ( m_Result == DDERR_NOTPAGELOCKED ) { m_Debug.MessageToFile( "An attempt was made to page-unlock a surface with no outstanding page locks." ); return; }	if ( m_Result == DDERR_NOTPALETTIZED ) { m_Debug.MessageToFile( "The surface being used is not a palette-based surface." ); return; }	if ( m_Result == DDERR_NOVSYNCHW ) { m_Debug.MessageToFile( "There is no hardware support for vertical blank–synchronized operations." ); return; }	if ( m_Result == DDERR_NOZBUFFERHW ) { m_Debug.MessageToFile( "The operation to create a z-buffer in display memory or to perform a blit, using a z-buffer cannot be carried out because there is no hardware support for z-buffers." ); return; }	if ( m_Result == DDERR_NOZOVERLAYHW ) { m_Debug.MessageToFile( "The overlay surfaces cannot be z-layered, based on the z-order because the hardware does not support z-ordering of overlays." ); return; }	if ( m_Result == DDERR_OUTOFCAPS ) { m_Debug.MessageToFile( "The hardware needed for the requested operation has already been allocated." ); return; }	if ( m_Result == DDERR_OUTOFMEMORY ) { m_Debug.MessageToFile( "DirectDraw does not have enough memory to perform the operation." ); return; }	if ( m_Result == DDERR_OUTOFVIDEOMEMORY ) { m_Debug.MessageToFile( "DirectDraw does not have enough display memory to perform the operation." ); return; }	if ( m_Result == DDERR_OVERLAPPINGRECTS ) { m_Debug.MessageToFile( "The source and destination rectangles are on the same surface and overlap each other." ); return; }	if ( m_Result == DDERR_OVERLAYCANTCLIP ) { m_Debug.MessageToFile( "The hardware does not support clipped overlays." ); return; }	if ( m_Result == DDERR_OVERLAYCOLORKEYONLYONEACTIVE ) { m_Debug.MessageToFile( "An attempt was made to have more than one color key active on an overlay." ); return; }	if ( m_Result == DDERR_OVERLAYNOTVISIBLE ) { m_Debug.MessageToFile( "The IDirectDrawSurface7::GetOverlayPosition method was called on a hidden overlay." ); return; }	if ( m_Result == DDERR_PALETTEBUSY ) { m_Debug.MessageToFile( "Access to this palette is refused because the palette is locked by another thread." ); return; }	if ( m_Result == DDERR_PRIMARYSURFACEALREADYEXISTS ) { m_Debug.MessageToFile( "This process has already created a primary surface." ); return; }	if ( m_Result == DDERR_REGIONTOOSMALL ) { m_Debug.MessageToFile( "The region passed to the IDirectDrawClipper::GetClipList method is too small." ); return; }	if ( m_Result == DDERR_SURFACEALREADYATTACHED ) { m_Debug.MessageToFile( "An attempt was made to attach a surface to another surface to which it is already attached." ); return; }	if ( m_Result == DDERR_SURFACEALREADYDEPENDENT ) { m_Debug.MessageToFile( "An attempt was made to make a surface a dependency of another surface on which it is already dependent." ); return; }	if ( m_Result == DDERR_SURFACEBUSY ) { m_Debug.MessageToFile( "Access to the surface is refused because the surface is locked by another thread." ); return; }	if ( m_Result == DDERR_SURFACEISOBSCURED ) { m_Debug.MessageToFile( "Access to the surface is refused because the surface is obscured." ); return; }	if ( m_Result == DDERR_SURFACELOST ) { m_Debug.MessageToFile( "Access to the surface is refused because the surface memory is gone. Call the IDirectDrawSurface7::Restore method on this surface to restore the memory associated with it." ); return; }	if ( m_Result == DDERR_SURFACENOTATTACHED ) { m_Debug.MessageToFile( "The requested surface is not attached." ); return; }	if ( m_Result == DDERR_TESTFINISHED ) { m_Debug.MessageToFile( "New for DirectX 7.0. When returned by the IDirectDraw7::StartModeTest method, this value means that no test could be initiated because all the resolutions chosen for testing already have refresh rate information in the registry. When returned by IDirectDraw7::EvaluateMode, the value means that DirectDraw has completed a refresh rate test." ); return; }	if ( m_Result == DDERR_TOOBIGHEIGHT ) { m_Debug.MessageToFile( "The height requested by DirectDraw is too large." ); return; }	if ( m_Result == DDERR_TOOBIGSIZE ) { m_Debug.MessageToFile( "The size requested by DirectDraw is too large. However, the individual height and width are valid sizes." ); return; }	if ( m_Result == DDERR_TOOBIGWIDTH ) { m_Debug.MessageToFile( "The width requested by DirectDraw is too large." ); return; }	if ( m_Result == DDERR_UNSUPPORTED ) { m_Debug.MessageToFile( "The operation is not supported." ); return; }	if ( m_Result == DDERR_UNSUPPORTEDFORMAT ) { m_Debug.MessageToFile( "The pixel format requested is not supported by DirectDraw." ); return; }	if ( m_Result == DDERR_UNSUPPORTEDMASK ) { m_Debug.MessageToFile( "The bitmask in the pixel format requested is not supported by DirectDraw." ); return; }	if ( m_Result == DDERR_UNSUPPORTEDMODE ) { m_Debug.MessageToFile( "The display is currently in an unsupported mode." ); return; }	if ( m_Result == DDERR_VERTICALBLANKINPROGRESS ) { m_Debug.MessageToFile( "A vertical blank is in progress." ); return; }	if ( m_Result == DDERR_VIDEONOTACTIVE ) { m_Debug.MessageToFile( "The video port is not active." ); return; }	if ( m_Result == DDERR_WASSTILLDRAWING ) { m_Debug.MessageToFile( "The previous blit operation that is transferring information to or from this surface is incomplete." ); return; }	if ( m_Result == DDERR_WRONGMODE ) { m_Debug.MessageToFile( "This surface cannot be restored because it was created in a different mode." ); return; }	if ( m_Result == DDERR_XALIGN ) { m_Debug.MessageToFile( "The provided rectangle was not horizontally aligned on a required boundary." ); return; }		m_Debug.MessageToFile( "Non recgonized error. Weird stuff man, I suppose you have a big problem." ); 



____________________________
Mmmm, I'll have to think of one.

Edited by - s9801758 on June 12, 2000 2:11:50 PM
____________________________Mmmm, I''ll have to think of one.
By the way,

this only does the Direct3D and DirectDraw error codes. Since those are the only codes I use at the moment.

Jaap
____________________________Mmmm, I''ll have to think of one.
For those of us who are lazy, the D3DXGetErrorString() function converts any DirectX and Win32 HRESULT into a readable textstring.

- WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement