home *** CD-ROM | disk | FTP | other *** search
/ NEXT Generation 27 / NEXT27.iso / pc / demos / emperor / dx3.exe / SDK / SAMPLES / MISC / RMERROR.C < prev    next >
C/C++ Source or Header  |  1996-08-28  |  16KB  |  298 lines

  1. /*
  2.  *  Copyright (C) 1995, 1996 Microsoft Corporation. All Rights Reserved.
  3.  *
  4.  *  File: rmerror.cpp
  5.  *
  6.  *  Error reporting code for D3DRM examples.
  7.  *
  8.  */
  9.  
  10. #include "rmerror.h"
  11.  
  12. /* Msg
  13.  * Displays a message box containing the given formatted string.
  14.  */
  15. void __cdecl
  16. Msg( LPSTR fmt, ... )
  17. {
  18.     char buff[256];
  19.  
  20.     wvsprintf(buff, fmt, (char *)(&fmt+1));
  21.     lstrcat(buff, "\r\n");
  22.     MessageBox( NULL, buff, "D3DRM Example Message", MB_OK );
  23. }
  24.  
  25. /*
  26.  * D3DRMErrorToString
  27.  * Returns a pointer to a string describing the given DD, D3D or D3DRM error code.
  28.  */
  29. char*
  30. D3DRMErrorToString(HRESULT error)
  31. {
  32.     switch(error) {
  33.         case DD_OK:
  34.             /* Also includes D3D_OK and D3DRM_OK */
  35.             return "No error.\0";
  36.         case DDERR_ALREADYINITIALIZED:
  37.             return "This object is already initialized.\0";
  38.         case DDERR_BLTFASTCANTCLIP:
  39.             return "Return if a clipper object is attached to the source surface passed into a BltFast call.\0";
  40.         case DDERR_CANNOTATTACHSURFACE:
  41.             return "This surface can not be attached to the requested surface.\0";
  42.         case DDERR_CANNOTDETACHSURFACE:
  43.             return "This surface can not be detached from the requested surface.\0";
  44.         case DDERR_CANTCREATEDC:
  45.             return "Windows can not create any more DCs.\0";
  46.         case DDERR_CANTDUPLICATE:
  47.             return "Can't duplicate primary & 3D surfaces, or surfaces that are implicitly created.\0";
  48.         case DDERR_CLIPPERISUSINGHWND:
  49.             return "An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd.\0";
  50.         case DDERR_COLORKEYNOTSET:
  51.             return "No src color key specified for this operation.\0";
  52.         case DDERR_CURRENTLYNOTAVAIL:
  53.             return "Support is currently not available.\0";
  54.         case DDERR_DIRECTDRAWALREADYCREATED:
  55.             return "A DirectDraw object representing this driver has already been created for this process.\0";
  56.         case DDERR_EXCEPTION:
  57.             return "An exception was encountered while performing the requested operation.\0";
  58.         case DDERR_EXCLUSIVEMODEALREADYSET:
  59.             return "An attempt was made to set the cooperative level when it was already set to exclusive.\0";
  60.         case DDERR_GENERIC:
  61.             return "Generic failure.\0";
  62.         case DDERR_HEIGHTALIGN:
  63.             return "Height of rectangle provided is not a multiple of reqd alignment.\0";
  64.         case DDERR_HWNDALREADYSET:
  65.             return "The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or palettes created.\0";
  66.         case DDERR_HWNDSUBCLASSED:
  67.             return "HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring state.\0";
  68.         case DDERR_IMPLICITLYCREATED:
  69.             return "This surface can not be restored because it is an implicitly created surface.\0";
  70.         case DDERR_INCOMPATIBLEPRIMARY:
  71.             return "Unable to match primary surface creation request with existing primary surface.\0";
  72.         case DDERR_INVALIDCAPS:
  73.             return "One or more of the caps bits passed to the callback are incorrect.\0";
  74.         case DDERR_INVALIDCLIPLIST:
  75.             return "DirectDraw does not support the provided cliplist.\0";
  76.         case DDERR_INVALIDDIRECTDRAWGUID:
  77.             return "The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier.\0";
  78.         case DDERR_INVALIDMODE:
  79.             return "DirectDraw does not support the requested mode.\0";
  80.         case DDERR_INVALIDOBJECT:
  81.             return "DirectDraw received a pointer that was an invalid DIRECTDRAW object.\0";
  82.         case DDERR_INVALIDPARAMS:
  83.             return "One or more of the parameters passed to the function are incorrect.\0";
  84.         case DDERR_INVALIDPIXELFORMAT:
  85.             return "The pixel format was invalid as specified.\0";
  86.         case DDERR_INVALIDPOSITION:
  87.             return "Returned when the position of the overlay on the destination is no longer legal for that destination.\0";
  88.         case DDERR_INVALIDRECT:
  89.             return "Rectangle provided was invalid.\0";
  90.         case DDERR_LOCKEDSURFACES:
  91.             return "Operation could not be carried out because one or more surfaces are locked.\0";
  92.         case DDERR_NO3D:
  93.             return "There is no 3D present.\0";
  94.         case DDERR_NOALPHAHW:
  95.             return "Operation could not be carried out because there is no alpha accleration hardware present or available.\0";
  96.         case DDERR_NOBLTHW:
  97.             return "No blitter hardware present.\0";
  98.         case DDERR_NOCLIPLIST:
  99.             return "No cliplist available.\0";
  100.         case DDERR_NOCLIPPERATTACHED:
  101.             return "No clipper object attached to surface object.\0";
  102.         case DDERR_NOCOLORCONVHW:
  103.             return "Operation could not be carried out because there is no color conversion hardware present or available.\0";
  104.         case DDERR_NOCOLORKEY:
  105.             return "Surface doesn't currently have a color key\0";
  106.         case DDERR_NOCOLORKEYHW:
  107.             return "Operation could not be carried out because there is no hardware support of the destination color key.\0";
  108.         case DDERR_NOCOOPERATIVELEVELSET:
  109.             return "Create function called without DirectDraw object method SetCooperativeLevel being called.\0";
  110.         case DDERR_NODC:
  111.             return "No DC was ever created for this surface.\0";
  112.         case DDERR_NODDROPSHW:
  113.             return "No DirectDraw ROP hardware.\0";
  114.         case DDERR_NODIRECTDRAWHW:
  115.             return "A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware.\0";
  116.         case DDERR_NOEMULATION:
  117.             return "Software emulation not available.\0";
  118.         case DDERR_NOEXCLUSIVEMODE:
  119.             return "Operation requires the application to have exclusive mode but the application does not have exclusive mode.\0";
  120.         case DDERR_NOFLIPHW:
  121.             return "Flipping visible surfaces is not supported.\0";
  122.         case DDERR_NOGDI:
  123.             return "There is no GDI present.\0";
  124.         case DDERR_NOHWND:
  125.             return "Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND.\0";
  126.         case DDERR_NOMIRRORHW:
  127.             return "Operation could not be carried out because there is no hardware present or available.\0";
  128.         case DDERR_NOOVERLAYDEST:
  129.             return "Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on to establish a destination.\0";
  130.         case DDERR_NOOVERLAYHW:
  131.             return "Operation could not be carried out because there is no overlay hardware present or available.\0";
  132.         case DDERR_NOPALETTEATTACHED:
  133.             return "No palette object attached to this surface.\0";
  134.         case DDERR_NOPALETTEHW:
  135.             return "No hardware support for 16 or 256 color palettes.\0";
  136.         case DDERR_NORASTEROPHW:
  137.             return "Operation could not be carried out because there is no appropriate raster op hardware present or available.\0";
  138.         case DDERR_NOROTATIONHW:
  139.             return "Operation could not be carried out because there is no rotation hardware present or available.\0";
  140.         case DDERR_NOSTRETCHHW:
  141.             return "Operation could not be carried out because there is no hardware support for stretching.\0";
  142.         case DDERR_NOT4BITCOLOR:
  143.             return "DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette.\0";
  144.         case DDERR_NOT4BITCOLORINDEX:
  145.             return "DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette.\0";
  146.         case DDERR_NOT8BITCOLOR:
  147.             return "DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color.\0";
  148.         case DDERR_NOTAOVERLAYSURFACE:
  149.             return "Returned when an overlay member is called for a non-overlay surface.\0";
  150.         case DDERR_NOTEXTUREHW:
  151.             return "Operation could not be carried out because there is no texture mapping hardware present or available.\0";
  152.         case DDERR_NOTFLIPPABLE:
  153.             return "An attempt has been made to flip a surface that is not flippable.\0";
  154.         case DDERR_NOTFOUND:
  155.             return "Requested item was not found.\0";
  156.         case DDERR_NOTLOCKED:
  157.             return "Surface was not locked.  An attempt to unlock a surface that was not locked at all, or by this process, has been attempted.\0";
  158.         case DDERR_NOTPALETTIZED:
  159.             return "The surface being used is not a palette-based surface.\0";
  160.         case DDERR_NOVSYNCHW:
  161.             return "Operation could not be carried out because there is no hardware support for vertical blank synchronized operations.\0";
  162.         case DDERR_NOZBUFFERHW:
  163.             return "Operation could not be carried out because there is no hardware support for zbuffer blitting.\0";
  164.         case DDERR_NOZOVERLAYHW:
  165.             return "Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays.\0";
  166.         case DDERR_OUTOFCAPS:
  167.             return "The hardware needed for the requested operation has already been allocated.\0";
  168.         case DDERR_OUTOFMEMORY:
  169.             return "DirectDraw does not have enough memory to perform the operation.\0";
  170.         case DDERR_OUTOFVIDEOMEMORY:
  171.             return "DirectDraw does not have enough memory to perform the operation.\0";
  172.         case DDERR_OVERLAYCANTCLIP:
  173.             return "The hardware does not support clipped overlays.\0";
  174.         case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
  175.             return "Can only have ony color key active at one time for overlays.\0";
  176.         case DDERR_OVERLAYNOTVISIBLE:
  177.             return "Returned when GetOverlayPosition is called on a hidden overlay.\0";
  178.         case DDERR_PALETTEBUSY:
  179.             return "Access to this palette is being refused because the palette is already locked by another thread.\0";
  180.         case DDERR_PRIMARYSURFACEALREADYEXISTS:
  181.             return "This process already has created a primary surface.\0";
  182.         case DDERR_REGIONTOOSMALL:
  183.             return "Region passed to Clipper::GetClipList is too small.\0";
  184.         case DDERR_SURFACEALREADYATTACHED:
  185.             return "This surface is already attached to the surface it is being attached to.\0";
  186.         case DDERR_SURFACEALREADYDEPENDENT:
  187.             return "This surface is already a dependency of the surface it is being made a dependency of.\0";
  188.         case DDERR_SURFACEBUSY:
  189.             return "Access to this surface is being refused because the surface is already locked by another thread.\0";
  190.         case DDERR_SURFACEISOBSCURED:
  191.             return "Access to surface refused because the surface is obscured.\0";
  192.         case DDERR_SURFACELOST:
  193.             return "Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it.\0";
  194.         case DDERR_SURFACENOTATTACHED:
  195.             return "The requested surface is not attached.\0";
  196.         case DDERR_TOOBIGHEIGHT:
  197.             return "Height requested by DirectDraw is too large.\0";
  198.         case DDERR_TOOBIGSIZE:
  199.             return "Size requested by DirectDraw is too large, but the individual height and width are OK.\0";
  200.         case DDERR_TOOBIGWIDTH:
  201.             return "Width requested by DirectDraw is too large.\0";
  202.         case DDERR_UNSUPPORTED:
  203.             return "Action not supported.\0";
  204.         case DDERR_UNSUPPORTEDFORMAT:
  205.             return "FOURCC format requested is unsupported by DirectDraw.\0";
  206.         case DDERR_UNSUPPORTEDMASK:
  207.             return "Bitmask in the pixel format requested is unsupported by DirectDraw.\0";
  208.         case DDERR_VERTICALBLANKINPROGRESS:
  209.             return "Vertical blank is in progress.\0";
  210.         case DDERR_WASSTILLDRAWING:
  211.             return "Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete.\0";
  212.         case DDERR_WRONGMODE:
  213.             return "This surface can not be restored because it was created in a different mode.\0";
  214.         case DDERR_XALIGN:
  215.             return "Rectangle provided was not horizontally aligned on required boundary.\0";
  216.         case D3DERR_BADMAJORVERSION:
  217.             return "D3DERR_BADMAJORVERSION\0";
  218.         case D3DERR_BADMINORVERSION:
  219.             return "D3DERR_BADMINORVERSION\0";
  220.         case D3DERR_EXECUTE_LOCKED:
  221.             return "D3DERR_EXECUTE_LOCKED\0";
  222.         case D3DERR_EXECUTE_NOT_LOCKED:
  223.             return "D3DERR_EXECUTE_NOT_LOCKED\0";
  224.         case D3DERR_EXECUTE_CREATE_FAILED:
  225.             return "D3DERR_EXECUTE_CREATE_FAILED\0";
  226.         case D3DERR_EXECUTE_DESTROY_FAILED:
  227.             return "D3DERR_EXECUTE_DESTROY_FAILED\0";
  228.         case D3DERR_EXECUTE_LOCK_FAILED:
  229.             return "D3DERR_EXECUTE_LOCK_FAILED\0";
  230.         case D3DERR_EXECUTE_UNLOCK_FAILED:
  231.             return "D3DERR_EXECUTE_UNLOCK_FAILED\0";
  232.         case D3DERR_EXECUTE_FAILED:
  233.             return "D3DERR_EXECUTE_FAILED\0";
  234.         case D3DERR_EXECUTE_CLIPPED_FAILED:
  235.             return "D3DERR_EXECUTE_CLIPPED_FAILED\0";
  236.         case D3DERR_TEXTURE_NO_SUPPORT:
  237.             return "D3DERR_TEXTURE_NO_SUPPORT\0";
  238.         case D3DERR_TEXTURE_NOT_LOCKED:
  239.             return "D3DERR_TEXTURE_NOT_LOCKED\0";
  240.         case D3DERR_TEXTURE_LOCKED:
  241.             return "D3DERR_TEXTURELOCKED\0";
  242.         case D3DERR_TEXTURE_CREATE_FAILED:
  243.             return "D3DERR_TEXTURE_CREATE_FAILED\0";
  244.         case D3DERR_TEXTURE_DESTROY_FAILED:
  245.             return "D3DERR_TEXTURE_DESTROY_FAILED\0";
  246.         case D3DERR_TEXTURE_LOCK_FAILED:
  247.             return "D3DERR_TEXTURE_LOCK_FAILED\0";
  248.         case D3DERR_TEXTURE_UNLOCK_FAILED:
  249.             return "D3DERR_TEXTURE_UNLOCK_FAILED\0";
  250.         case D3DERR_TEXTURE_LOAD_FAILED:
  251.             return "D3DERR_TEXTURE_LOAD_FAILED\0";
  252.         case D3DERR_MATRIX_CREATE_FAILED:
  253.             return "D3DERR_MATRIX_CREATE_FAILED\0";
  254.         case D3DERR_MATRIX_DESTROY_FAILED:
  255.             return "D3DERR_MATRIX_DESTROY_FAILED\0";
  256.         case D3DERR_MATRIX_SETDATA_FAILED:
  257.             return "D3DERR_MATRIX_SETDATA_FAILED\0";
  258.         case D3DERR_SETVIEWPORTDATA_FAILED:
  259.             return "D3DERR_SETVIEWPORTDATA_FAILED\0";
  260.         case D3DERR_MATERIAL_CREATE_FAILED:
  261.             return "D3DERR_MATERIAL_CREATE_FAILED\0";
  262.         case D3DERR_MATERIAL_DESTROY_FAILED:
  263.             return "D3DERR_MATERIAL_DESTROY_FAILED\0";
  264.         case D3DERR_MATERIAL_SETDATA_FAILED:
  265.             return "D3DERR_MATERIAL_SETDATA_FAILED\0";
  266.         case D3DERR_LIGHT_SET_FAILED:
  267.             return "D3DERR_LIGHT_SET_FAILED\0";
  268.         case D3DRMERR_BADOBJECT:
  269.             return "D3DRMERR_BADOBJECT\0";
  270.         case D3DRMERR_BADTYPE:
  271.             return "D3DRMERR_BADTYPE\0";
  272.         case D3DRMERR_BADALLOC:
  273.             return "D3DRMERR_BADALLOC\0";
  274.         case D3DRMERR_FACEUSED:
  275.             return "D3DRMERR_FACEUSED\0";
  276.         case D3DRMERR_NOTFOUND:
  277.             return "D3DRMERR_NOTFOUND\0";
  278.         case D3DRMERR_NOTDONEYET:
  279.             return "D3DRMERR_NOTDONEYET\0";
  280.         case D3DRMERR_FILENOTFOUND:
  281.             return "The file was not found.\0";
  282.         case D3DRMERR_BADFILE:
  283.             return "D3DRMERR_BADFILE\0";
  284.         case D3DRMERR_BADDEVICE:
  285.             return "D3DRMERR_BADDEVICE\0";
  286.         case D3DRMERR_BADVALUE:
  287.             return "D3DRMERR_BADVALUE\0";
  288.         case D3DRMERR_BADMAJORVERSION:
  289.             return "D3DRMERR_BADMAJORVERSION\0";
  290.         case D3DRMERR_BADMINORVERSION:
  291.             return "D3DRMERR_BADMINORVERSION\0";
  292.         case D3DRMERR_UNABLETOEXECUTE:
  293.             return "D3DRMERR_UNABLETOEXECUTE\0";
  294.         default:
  295.             return "Unrecognized error value.\0";
  296.     }
  297. }
  298.