2 **-----------------------------------------------------------------------------
4 ** Purpose: Example debug code for D3D sample
7 ** Copyright (C) 199 - 1997 Microsoft Corporation. All Rights Reserved.
8 **-----------------------------------------------------------------------------
12 **-----------------------------------------------------------------------------
14 **-----------------------------------------------------------------------------
25 **-----------------------------------------------------------------------------
27 **-----------------------------------------------------------------------------
29 #define MAX_STRING 256
32 DWORD g_dwDebugLevel = DEBUG_ALWAYS;
35 BOOL g_fDebug = FALSE;
41 **-----------------------------------------------------------------------------
43 **-----------------------------------------------------------------------------
47 BOOL GetDDErrorString (HRESULT hResult, LPTSTR lpszError, DWORD cchError);
52 **-----------------------------------------------------------------------------
54 **-----------------------------------------------------------------------------
59 **-----------------------------------------------------------------------------
61 ** Purpose: Printf to debug output
62 **-----------------------------------------------------------------------------
66 void __cdecl dprintf (DWORD dwDebugLevel, LPCTSTR szFormat, ...)
68 TCHAR szBuffer[MAX_STRING];
71 // Check if current debug level
72 if (dwDebugLevel < g_dwDebugLevel)
75 lstrcpy (szBuffer, START_STR);
76 va_start(va, szFormat);
77 wvsprintf (szBuffer+lstrlen (szBuffer), szFormat, va);
79 lstrcat (szBuffer, END_STR);
80 OutputDebugString (szBuffer);
87 **-----------------------------------------------------------------------------
88 ** Name: ReportDDError
90 **-----------------------------------------------------------------------------
93 void _cdecl ReportDDError (HRESULT hResult, LPCTSTR szFormat, ...)
95 TCHAR szMsg[MAX_STRING];
96 TCHAR szErr[MAX_STRING];
97 TCHAR szUnknown[] = TEXT("Unknown");
98 DWORD cchErr = sizeof(szErr)/sizeof(TCHAR);
101 // Check for Success Error code
102 if (hResult == DD_OK)
105 va_start( va, szFormat );
106 wvsprintf (szMsg, szFormat, va);
109 // Get DD/D3D error string
111 GetDDErrorString (hResult, szErr, cchErr);
112 wsprintf (szMsg + strlen (szMsg), TEXT(" : DD/D3D Error = %s\r\n"), szErr);
116 DPF (DEBUG_ERROR, TEXT("%s"), szMsg);
119 // Define the following if you want an in your face Messagebox on errors
121 //#define DEBUG_PROMPTME
122 #ifdef DEBUG_PROMPTME
127 OnPause (g_hWnd, TRUE);
129 // Display Error Message to user
135 MessageBox (hWindow, szMsg, g_szMainTitle, MB_OK | MB_APPLMODAL);
139 OnPause (g_hWnd, FALSE);
146 ULONG CDebugTracker::s_cLevels = 0;
147 char CDebugTracker::szsp [80];
149 CDebugTracker::CDebugTracker (LPCSTR lpsz)
151 m_psz = strdup (lpsz);
154 szsp [s_cLevels] = '/';
155 szsp [s_cLevels + 1] = '\0';
156 DPF (DEBUG_ALWAYS, "%s%s start", szsp, m_psz);
157 szsp [s_cLevels] = '|';
161 CDebugTracker::~CDebugTracker ()
166 szsp [s_cLevels + 1] = '\0';
167 szsp [s_cLevels] = '\\';
168 DPF (DEBUG_ALWAYS, "%s%s end", szsp, m_psz);
170 free ((LPVOID) m_psz);
173 void __cdecl Return (LPCSTR szFormat, ...)
179 **-----------------------------------------------------------------------------
180 ** Name: GetDDErrorString
181 ** Purpose: outputs a debug string to debugger
182 **-----------------------------------------------------------------------------
186 BOOL GetDDErrorString (HRESULT hResult, LPTSTR lpszErrorBuff, DWORD cchError)
190 TCHAR szMsg[MAX_STRING];
193 if (!lpszErrorBuff || !cchError)
195 // Error, invalid parameters
202 // The request completed successfully.
203 lpszError = TEXT("DD_OK");
206 case DDERR_ALREADYINITIALIZED:
207 // The object has already been initialized.
208 lpszError = TEXT("DDERR_ALREADYINITIALIZED");
211 case DDERR_BLTFASTCANTCLIP:
212 // A DirectDrawClipper object is attached to a source surface
213 // that has passed into a call to the IDirectDrawSurface4::BltFast method.
214 lpszError = TEXT("DDERR_BLTFASTCANTCLIP");
217 case DDERR_CANNOTATTACHSURFACE:
218 // A surface cannot be attached to another requested surface.
219 lpszError = TEXT("DDERR_CANNOTATTACHSURFACE");
222 case DDERR_CANNOTDETACHSURFACE:
223 // A surface cannot be detached from another requested surface.
224 lpszError = TEXT("DDERR_CANNOTDETACHSURFACE");
227 case DDERR_CANTCREATEDC:
228 // Windows cannot create any more device contexts (DCs).
229 lpszError = TEXT("DDERR_CANTCREATEDC");
232 case DDERR_CANTDUPLICATE:
233 // Primary and 3D surfaces, or surfaces that are
234 // implicitly created, cannot be duplicated.
235 lpszError = TEXT("DDERR_CANTDUPLICATE");
238 case DDERR_CANTLOCKSURFACE:
239 // Access to this surface is refused because an
240 // attempt was made to lock the primary surface without DCI support.
241 lpszError = TEXT("DDERR_CANTLOCKSURFACE");
244 case DDERR_CANTPAGELOCK:
245 // An attempt to page lock a surface failed.
246 // Page lock will not work on a display-memory
247 // surface or an emulated primary surface.
248 lpszError = TEXT("DDERR_CANTPAGELOCK");
251 case DDERR_CANTPAGEUNLOCK:
252 // An attempt to page unlock a surface failed.
253 // Page unlock will not work on a display-memory
254 // surface or an emulated primary surface.
255 lpszError = TEXT("DDERR_CANTPAGEUNLOCK");
258 case DDERR_CLIPPERISUSINGHWND:
259 // An attempt was made to set a clip list for a DirectDrawClipper
260 // object that is already monitoring a window handle.
261 lpszError = TEXT("DDERR_CLIPPERISUSINGHWND");
264 case DDERR_COLORKEYNOTSET:
265 // No source color key is specified for this operation
266 lpszError = TEXT("DDERR_COLORKEYNOTSET");
269 case DDERR_CURRENTLYNOTAVAIL:
270 // No support is currently available.
271 lpszError = TEXT("DDERR_CURRENTLYNOTAVAIL");
274 case DDERR_DCALREADYCREATED:
275 // A device context (DC) has already been returned for this surface.
276 // Only one DC can be retrieved for each surface.
277 lpszError = TEXT("DDERR_DCALREADYCREATED");
280 case DDERR_DIRECTDRAWALREADYCREATED:
281 // A DirectDraw object representing this driver
282 // has already been created for this process.
283 lpszError = TEXT("DDERR_DIRECTDRAWALREADYCREATED");
286 case DDERR_EXCEPTION:
287 // An exception was encountered while
288 // performing the requested operation.
289 lpszError = TEXT("DDERR_EXCEPTION");
292 case DDERR_EXCLUSIVEMODEALREADYSET:
293 // An attempt was made to set the cooperative
294 // level when it was already set to exclusive.
295 lpszError = TEXT("DDERR_EXCLUSIVEMODEALREADYSET");
299 // There is an undefined error condition.
300 lpszError = TEXT("DDERR_GENERIC");
303 case DDERR_HEIGHTALIGN:
304 // The height of the provided rectangle
305 // is not a multiple of the required alignment.
306 lpszError = TEXT("DDERR_HEIGHTALIGN");
309 case DDERR_HWNDALREADYSET:
310 // The DirectDraw cooperative level window
311 // handle has already been set. It cannot
312 // be reset while the process has surfaces or palettes created.
313 lpszError = TEXT("DDERR_HWNDALREADYSET");
316 case DDERR_HWNDSUBCLASSED:
317 // DirectDraw is prevented from restoring state because the
318 // DirectDraw cooperative level window handle has been subclassed.
319 lpszError = TEXT("DDERR_HWNDSUBCLASSED");
322 case DDERR_IMPLICITLYCREATED:
323 // The surface cannot be restored because
324 // it is an implicitly created surface.
325 lpszError = TEXT("DDERR_IMPLICITLYCREATED");
328 case DDERR_INCOMPATIBLEPRIMARY:
329 // The primary surface creation request
330 // does not match with the existing primary surface.
331 lpszError = TEXT("DDERR_INCOMPATIBLEPRIMARY");
334 case DDERR_INVALIDCAPS:
335 // One or more of the capability bits
336 // passed to the callback function are incorrect.
337 lpszError = TEXT("DDERR_INVALIDCAPS");
340 case DDERR_INVALIDCLIPLIST:
341 // DirectDraw does not support the provided clip list.
342 lpszError = TEXT("DDERR_INVALIDCLIPLIST");
345 case DDERR_INVALIDDIRECTDRAWGUID:
346 // The globally unique identifier (GUID) passed to the
347 // DirectDrawCreate function is not a valid DirectDraw driver identifier.
348 lpszError = TEXT("DDERR_INVALIDDIRECTDRAWGUID");
351 case DDERR_INVALIDMODE:
352 // DirectDraw does not support the requested mode.
353 lpszError = TEXT("DDERR_INVALIDMODE");
356 case DDERR_INVALIDOBJECT:
357 // DirectDraw received a pointer that was an invalid DirectDraw object.
358 lpszError = TEXT("DDERR_INVALIDOBJECT");
361 case DDERR_INVALIDPARAMS:
362 // One or more of the parameters passed to the method are incorrect.
363 lpszError = TEXT("DDERR_INVALIDPARAMS");
366 case DDERR_INVALIDPIXELFORMAT:
367 // The pixel format was invalid as specified.
368 lpszError = TEXT("DDERR_INVALIDPIXELFORMAT");
371 case DDERR_INVALIDPOSITION:
372 // The position of the overlay on the destination is no longer legal.
373 lpszError = TEXT("DDERR_INVALIDPOSITION");
376 case DDERR_INVALIDRECT:
377 // The provided rectangle was invalid.
378 lpszError = TEXT("DDERR_INVALIDRECT");
381 case DDERR_INVALIDSURFACETYPE:
382 // The requested operation could not be performed
383 // because the surface was of the wrong type.
384 lpszError = TEXT("DDERR_INVALIDSURFACETYPE");
387 case DDERR_LOCKEDSURFACES:
388 // One or more surfaces are locked,
389 // causing the failure of the requested operation.
390 lpszError = TEXT("DDERR_LOCKEDSURFACES");
394 // There is more data available than the specified
395 // buffer size could hold.
396 lpszError = TEXT("DDERR_MOREDATA");
400 // No 3D hardware or emulation is present.
401 lpszError = TEXT("DDERR_NO3D");
404 case DDERR_NOALPHAHW:
405 // No alpha acceleration hardware is present or available,
406 // causing the failure of the requested operation.
407 lpszError = TEXT("DDERR_NOALPHAHW");
411 // No blitter hardware is present.
412 lpszError = TEXT("DDERR_NOBLTHW");
415 case DDERR_NOCLIPLIST:
416 // No clip list is available.
417 lpszError = TEXT("DDERR_NOCLIPLIST");
420 case DDERR_NOCLIPPERATTACHED:
421 // No DirectDrawClipper object is attached to the surface object.
422 lpszError = TEXT("DDERR_NOCLIPPERATTACHED");
425 case DDERR_NOCOLORCONVHW:
426 // The operation cannot be carried out because
427 // no color-conversion hardware is present or available.
428 lpszError = TEXT("DDERR_NOCOLORCONVHW");
431 case DDERR_NOCOLORKEY:
432 // The surface does not currently have a color key.
433 lpszError = TEXT("DDERR_NOCOLORKEY");
436 case DDERR_NOCOLORKEYHW:
437 // The operation cannot be carried out because there
438 // is no hardware support for the destination color key.
439 lpszError = TEXT("DDERR_NOCOLORKEYHW");
442 case DDERR_NOCOOPERATIVELEVELSET:
443 // A create function is called without the
444 // IDirectDraw2::SetCooperativeLevel method being called.
445 lpszError = TEXT("DDERR_NOCOOPERATIVELEVELSET");
449 // No DC has ever been created for this surface.
450 lpszError = TEXT("DDERR_NODC");
453 case DDERR_NODDROPSHW:
454 // No DirectDraw raster operation (ROP) hardware is available.
455 lpszError = TEXT("DDERR_NODDROPSHW");
458 case DDERR_NODIRECTDRAWHW:
459 // Hardware-only DirectDraw object creation is not possible;
460 // the driver does not support any hardware.
461 lpszError = TEXT("DDERR_NODIRECTDRAWHW");
464 case DDERR_NODIRECTDRAWSUPPORT:
465 // DirectDraw support is not possible with the current display driver.
466 lpszError = TEXT("DDERR_NODIRECTDRAWSUPPORT");
469 case DDERR_NOEMULATION:
470 // Software emulation is not available.
471 lpszError = TEXT("DDERR_NOEMULATION");
474 case DDERR_NOEXCLUSIVEMODE:
475 // The operation requires the application to have
476 // exclusive mode, but the application does not have exclusive mode.
477 lpszError = TEXT("DDERR_NOEXCLUSIVEMODE");
481 // Flipping visible surfaces is not supported.
482 lpszError = TEXT("DDERR_NOFLIPHW");
486 // No GDI is present.
487 lpszError = TEXT("DDERR_NOGDI");
491 // Clipper notification requires a window handle,
492 // or no window handle has been previously set
493 // as the cooperative level window handle.
494 lpszError = TEXT("DDERR_NOHWND");
497 case DDERR_NOMIPMAPHW:
498 // The operation cannot be carried out because no
499 // mipmap texture mapping hardware is present or available.
500 lpszError = TEXT("DDERR_NOMIPMAPHW");
503 case DDERR_NOMIRRORHW:
504 // The operation cannot be carried out because
505 // no mirroring hardware is present or available.
506 lpszError = TEXT("DDERR_NOMIRRORHW");
509 case DDERR_NONONLOCALVIDMEM:
510 // An attempt was made to allocate non-local video memory
511 // from a device that does not support non-local video memory.
512 lpszError = TEXT("DDERR_NONONLOCALVIDMEM");
515 case DDERR_NOOVERLAYDEST:
516 // The IDirectDrawSurface4::GetOverlayPosition method
517 // is called on an overlay that the IDirectDrawSurface4::UpdateOverlay
518 // method has not been called on to establish a destination.
519 lpszError = TEXT("DDERR_NOOVERLAYDEST");
522 case DDERR_NOOVERLAYHW:
523 // The operation cannot be carried out because
524 // no overlay hardware is present or available.
525 lpszError = TEXT("DDERR_NOOVERLAYHW");
528 case DDERR_NOPALETTEATTACHED:
529 // No palette object is attached to this surface.
530 lpszError = TEXT("DDERR_NOPALETTEATTACHED");
533 case DDERR_NOPALETTEHW:
534 // There is no hardware support for 16- or 256-color palettes.
535 lpszError = TEXT("DDERR_NOPALETTEHW");
538 case DDERR_NORASTEROPHW:
539 // The operation cannot be carried out because
540 // no appropriate raster operation hardware is present or available.
541 lpszError = TEXT("DDERR_NORASTEROPHW");
544 case DDERR_NOROTATIONHW:
545 // The operation cannot be carried out because
546 // no rotation hardware is present or available.
547 lpszError = TEXT("DDERR_NOROTATIONHW");
550 case DDERR_NOSTRETCHHW:
551 // The operation cannot be carried out because
552 // there is no hardware support for stretching.
553 lpszError = TEXT("DDERR_NOSTRETCHHW");
556 case DDERR_NOT4BITCOLOR:
557 // The DirectDrawSurface object is not using a
558 // 4-bit color palette and the requested operation
559 // requires a 4-bit color palette.
560 lpszError = TEXT("DDERR_NOT4BITCOLOR");
563 case DDERR_NOT4BITCOLORINDEX:
564 // The DirectDrawSurface object is not using a 4-bit
565 // color index palette and the requested operation
566 // requires a 4-bit color index palette.
567 lpszError = TEXT("DDERR_NOT4BITCOLORINDEX");
570 case DDERR_NOT8BITCOLOR:
571 // The DirectDrawSurface object is not using an 8-bit
572 // color palette and the requested operation requires
573 // an 8-bit color palette.
574 lpszError = TEXT("DDERR_NOT8BITCOLOR");
577 case DDERR_NOTAOVERLAYSURFACE:
578 // An overlay component is called for a non-overlay surface.
579 lpszError = TEXT("DDERR_NOTAOVERLAYSURFACE");
582 case DDERR_NOTEXTUREHW:
583 // The operation cannot be carried out because no
584 // texture-mapping hardware is present or available.
585 lpszError = TEXT("DDERR_NOTEXTUREHW");
588 case DDERR_NOTFLIPPABLE:
589 // An attempt has been made to flip a surface that cannot be flipped.
590 lpszError = TEXT("DDERR_NOTFLIPPABLE");
594 // The requested item was not found.
595 lpszError = TEXT("DDERR_NOTFOUND");
598 case DDERR_NOTINITIALIZED:
599 // An attempt was made to call an interface method of a DirectDraw object
600 // created by CoCreateInstance before the object was initialized.
601 lpszError = TEXT("DDERR_NOTINITIALIZED");
604 case DDERR_NOTLOCKED:
605 // An attempt is made to unlock a surface that was not locked.
606 lpszError = TEXT("DDERR_NOTLOCKED");
609 case DDERR_NOTPAGELOCKED:
610 // An attempt is made to page unlock a surface
611 // with no outstanding page locks.
612 lpszError = TEXT("DDERR_NOTPAGELOCKED");
615 case DDERR_NOTPALETTIZED:
616 // The surface being used is not a palette-based surface.
617 lpszError = TEXT("DDERR_NOTPALETTIZED");
620 case DDERR_NOVSYNCHW:
621 // The operation cannot be carried out because
622 // there is no hardware support for vertical blank synchronized operations.
623 lpszError = TEXT("DDERR_NOVSYNCHW");
626 case DDERR_NOZBUFFERHW:
627 // The operation to create a z-buffer in display memory
628 // or to perform a blit using a z-buffer cannot be carried
629 // out because there is no hardware support for z-buffers.
630 lpszError = TEXT("DDERR_NOZBUFFERHW");
633 case DDERR_NOZOVERLAYHW:
634 // The overlay surfaces cannot be z-layered based
635 // on the z-order because the hardware does not
636 // support z-ordering of overlays.
637 lpszError = TEXT("DDERR_NOZOVERLAYHW");
640 case DDERR_OUTOFCAPS:
641 // The hardware needed for the requested operation has already been allocated.
642 lpszError = TEXT("DDERR_OUTOFCAPS");
645 case DDERR_OUTOFMEMORY:
646 // DirectDraw does not have enough memory to perform the operation.
647 lpszError = TEXT("DDERR_OUTOFMEMORY");
650 case DDERR_OUTOFVIDEOMEMORY:
651 // DirectDraw does not have enough display memory to perform the operation.
652 lpszError = TEXT("DDERR_OUTOFVIDEOMEMORY");
655 case DDERR_OVERLAYCANTCLIP:
656 // The hardware does not support clipped overlays.
657 lpszError = TEXT("DDERR_OVERLAYCANTCLIP");
660 case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
661 // An attempt was made to have more than one color key active on an overlay.
662 lpszError = TEXT("DDERR_OVERLAYCOLORKEYONLYONEACTIVE");
665 case DDERR_OVERLAYNOTVISIBLE:
666 // The IDirectDrawSurface4::GetOverlayPosition method is called on a hidden overlay.
667 lpszError = TEXT("DDERR_OVERLAYNOTVISIBLE");
670 case DDERR_PALETTEBUSY:
671 // Access to this palette is refused
672 // because the palette is locked by another thread.
673 lpszError = TEXT("DDERR_PALETTEBUSY");
676 case DDERR_PRIMARYSURFACEALREADYEXISTS:
677 // This process has already created a primary surface.
678 lpszError = TEXT("DDERR_PRIMARYSURFACEALREADYEXISTS");
681 case DDERR_REGIONTOOSMALL:
682 // The region passed to the
683 // IDirectDrawClipper::GetClipList method is too small.
684 lpszError = TEXT("DDERR_REGIONTOOSMALL");
687 case DDERR_SURFACEALREADYATTACHED:
688 // An attempt was made to attach a surface to
689 // another surface to which it is already attached.
690 lpszError = TEXT("DDERR_SURFACEALREADYATTACHED");
693 case DDERR_SURFACEALREADYDEPENDENT:
694 // An attempt was made to make a surface a dependency
695 // of another surface to which it is already dependent.
696 lpszError = TEXT("DDERR_SURFACEALREADYDEPENDENT");
699 case DDERR_SURFACEBUSY:
700 // Access to the surface is refused because the
701 // surface is locked by another thread.
702 lpszError = TEXT("DDERR_SURFACEBUSY");
705 case DDERR_SURFACEISOBSCURED:
706 // Access to the surface is refused
707 // because the surface is obscured.
708 lpszError = TEXT("DDERR_SURFACEISOBSCURED");
711 case DDERR_SURFACELOST:
712 // Access to the surface is refused because the
713 // surface memory is gone. The DirectDrawSurface
714 // object representing this surface should have
715 // the IDirectDrawSurface4::Restore method called on it.
716 lpszError = TEXT("DDERR_SURFACELOST");
719 case DDERR_SURFACENOTATTACHED:
720 // The requested surface is not attached.
721 lpszError = TEXT("DDERR_SURFACENOTATTACHED");
724 case DDERR_TOOBIGHEIGHT:
725 // The height requested by DirectDraw is too large.
726 lpszError = TEXT("DDERR_TOOBIGHEIGHT");
729 case DDERR_TOOBIGSIZE:
730 // The size requested by DirectDraw is too large.
731 // However, the individual height and width are OK.
732 lpszError = TEXT("DDERR_TOOBIGSIZE");
735 case DDERR_TOOBIGWIDTH:
736 // The width requested by DirectDraw is too large.
737 lpszError = TEXT("DDERR_TOOBIGWIDTH");
740 case DDERR_UNSUPPORTED:
741 // The operation is not supported.
742 lpszError = TEXT("DDERR_UNSUPPORTED");
745 case DDERR_UNSUPPORTEDFORMAT:
746 // The FourCC format requested is not supported by DirectDraw.
747 lpszError = TEXT("DDERR_UNSUPPORTEDFORMAT");
750 case DDERR_UNSUPPORTEDMASK:
751 // The bitmask in the pixel format requested is not supported by DirectDraw.
752 lpszError = TEXT("DDERR_UNSUPPORTEDMASK");
755 case DDERR_UNSUPPORTEDMODE:
756 // The display is currently in an unsupported mode.
757 lpszError = TEXT("DDERR_UNSUPPORTEDMODE");
760 case DDERR_VERTICALBLANKINPROGRESS:
761 // A vertical blank is in progress.
762 lpszError = TEXT("DDERR_VERTICALBLANKINPROGRESS");
765 case DDERR_WASSTILLDRAWING:
766 // The previous blit operation that is transferring
767 // information to or from this surface is incomplete.
768 lpszError = TEXT("DDERR_WASSTILLDRAWING");
771 case DDERR_WRONGMODE:
772 // This surface cannot be restored because it was created in a different mode.
773 lpszError = TEXT("DDERR_WRONGMODE");
777 // The provided rectangle was not horizontally aligned on a required boundary.
778 lpszError = TEXT("DDERR_XALIGN");
781 case DDERR_VIDEONOTACTIVE:
782 // The video port is not active
783 lpszError = TEXT("DDERR_VIDEONOTACTIVE");
788 // D3D Immediate Mode Errors
791 case D3DERR_BADMAJORVERSION:
793 lpszError = TEXT("D3DERR_BADMAJORVERSION");
796 case D3DERR_BADMINORVERSION:
798 lpszError = TEXT("D3DERR_BADMINORVERSION");
801 case D3DERR_INVALID_DEVICE:
803 lpszError = TEXT("D3DERR_INVALID_DEVICE");
806 case D3DERR_INITFAILED:
808 lpszError = TEXT("D3DERR_INITFAILED");
811 case D3DERR_EXECUTE_CREATE_FAILED:
813 lpszError = TEXT("D3DERR_EXECUTE_CREATE_FAILED");
816 case D3DERR_EXECUTE_DESTROY_FAILED:
818 lpszError = TEXT("D3DERR_EXECUTE_DESTROY_FAILED");
821 case D3DERR_EXECUTE_LOCK_FAILED:
823 lpszError = TEXT("D3DERR_EXECUTE_LOCK_FAILED");
826 case D3DERR_EXECUTE_UNLOCK_FAILED:
828 lpszError = TEXT("D3DERR_EXECUTE_UNLOCK_FAILED");
831 case D3DERR_EXECUTE_LOCKED:
833 lpszError = TEXT("D3DERR_EXECUTE_LOCKED");
836 case D3DERR_EXECUTE_NOT_LOCKED:
838 lpszError = TEXT("D3DERR_EXECUTE_NOT_LOCKED");
841 case D3DERR_EXECUTE_FAILED:
843 lpszError = TEXT("D3DERR_EXECUTE_FAILED");
846 case D3DERR_EXECUTE_CLIPPED_FAILED:
848 lpszError = TEXT("D3DERR_CLIPPED_FAILED");
851 case D3DERR_TEXTURE_NO_SUPPORT:
853 lpszError = TEXT("D3DERR_TEXTURE_NO_SUPPORT");
856 case D3DERR_TEXTURE_CREATE_FAILED:
858 lpszError = TEXT("D3DERR_TEXTURE_CREATE_FAILED");
861 case D3DERR_TEXTURE_DESTROY_FAILED:
863 lpszError = TEXT("D3DERR_TEXTURE_DESTROY_FAILED");
866 case D3DERR_TEXTURE_LOCK_FAILED:
868 lpszError = TEXT("D3DERR_TEXTURE_LOCK_FAILED");
871 case D3DERR_TEXTURE_UNLOCK_FAILED:
873 lpszError = TEXT("D3DERR_TEXTURE_UNLOCK_FAILED");
876 case D3DERR_TEXTURE_LOAD_FAILED:
878 lpszError = TEXT("D3DERR_LOAD_FAILED");
881 case D3DERR_TEXTURE_SWAP_FAILED:
883 lpszError = TEXT("D3DERR_SWAP_FAILED");
886 case D3DERR_TEXTURE_LOCKED:
888 lpszError = TEXT("D3DERR_TEXTURE_LOCKED");
891 case D3DERR_TEXTURE_NOT_LOCKED:
893 lpszError = TEXT("D3DERR_TEXTURE_NOT_LOCKED");
896 case D3DERR_TEXTURE_GETSURF_FAILED:
898 lpszError = TEXT("D3DERR_TEXTURE_GETSURF_FAILED");
901 case D3DERR_MATRIX_CREATE_FAILED:
903 lpszError = TEXT("D3DERR_MATRIX_CREATE_FAILED");
906 case D3DERR_MATRIX_DESTROY_FAILED:
908 lpszError = TEXT("D3DERR_MATRIX_DESTROY_FAILED");
911 case D3DERR_MATRIX_SETDATA_FAILED:
913 lpszError = TEXT("D3DERR_MATRIX_SETDATA_FAILED");
916 case D3DERR_MATRIX_GETDATA_FAILED:
918 lpszError = TEXT("D3DERR_MAXTRIX_GETDATA_FAILED");
921 case D3DERR_SETVIEWPORTDATA_FAILED:
923 lpszError = TEXT("D3DERR_SETVIEWPORTDATA_FAILED");
926 case D3DERR_INVALIDCURRENTVIEWPORT:
928 lpszError = TEXT("D3DERR_INVALIDCURRENTVIEWPORT");
931 case D3DERR_INVALIDPRIMITIVETYPE:
933 lpszError = TEXT("D3DERR_INVALIDPRIMITIVETYPE");
936 case D3DERR_INVALIDVERTEXTYPE:
938 lpszError = TEXT("D3DERR_INVALIDVERTEXTYPE");
941 case D3DERR_TEXTURE_BADSIZE:
943 lpszError = TEXT("D3DERR_TEXTURE_BADSIZE");
946 case D3DERR_MATERIAL_CREATE_FAILED:
948 lpszError = TEXT("D3DERR_MATERIAL_CREATE_FAILED");
951 case D3DERR_MATERIAL_DESTROY_FAILED:
953 lpszError = TEXT("D3DERR_MATERIAL_DESTROY_FAILED");
956 case D3DERR_MATERIAL_SETDATA_FAILED:
958 lpszError = TEXT("D3DERR_MATERIAL_SETDATA_FAILED");
961 case D3DERR_MATERIAL_GETDATA_FAILED:
963 lpszError = TEXT("D3DERR_MATERIAL_GETDATA_FAILED");
966 case D3DERR_INVALIDPALETTE:
968 lpszError = TEXT("D3DERR_INVALIDPALETTE");
971 case D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY:
973 lpszError = TEXT("D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY");
976 case D3DERR_ZBUFF_NEEDS_VIDEOMEMORY:
978 lpszError = TEXT("D3DERR_ZBUFF_NEEDS_VIDEOMEMORY");
981 case D3DERR_SURFACENOTINVIDMEM:
983 lpszError = TEXT("D3DERR_SURFACENOTINVIDMEM");
986 case D3DERR_LIGHT_SET_FAILED:
988 lpszError = TEXT("D3DERR_LIGHT_SET_FAILED");
991 case D3DERR_LIGHTHASVIEWPORT:
993 lpszError = TEXT("D3DERR_LIGHTHASVIEWPORT");
996 case D3DERR_LIGHTNOTINTHISVIEWPORT:
998 lpszError = TEXT("D3DERR_LIGHTNOTINTHISVIEWPORT");
1001 case D3DERR_SCENE_IN_SCENE:
1003 lpszError = TEXT("D3DERR_SCENE_IN_SCENE");
1006 case D3DERR_SCENE_NOT_IN_SCENE:
1008 lpszError = TEXT("D3DERR_SCENE_NOT_IN_SCENE");
1011 case D3DERR_SCENE_BEGIN_FAILED:
1013 lpszError = TEXT("D3DERR_SCENE_BEGIN_FAILED");
1016 case D3DERR_SCENE_END_FAILED:
1018 lpszError = TEXT("D3DERR_SCENE_END_FAILED");
1021 case D3DERR_INBEGIN:
1023 lpszError = TEXT("D3DERR_INBEGIN");
1026 case D3DERR_NOTINBEGIN:
1028 lpszError = TEXT("D3DERR_NOTINBEGIN");
1031 case D3DERR_NOVIEWPORTS:
1033 lpszError = TEXT("D3DERR_NOVIEWPORTS");
1036 case D3DERR_VIEWPORTDATANOTSET:
1038 lpszError = TEXT("D3DERR_VIEWPORTDATANOTSET");
1041 case D3DERR_VIEWPORTHASNODEVICE:
1043 lpszError = TEXT("D3DERR_VIEWPORTHASNODEVICE");
1048 // D3D Retained Mode Errors
1051 case D3DRMERR_BADOBJECT:
1053 lpszError = TEXT("D3DRMERR_BADOBJECT");
1056 case D3DRMERR_BADTYPE:
1058 lpszError = TEXT("D3DRMERR_BADTYPE");
1061 case D3DRMERR_BADALLOC:
1063 lpszError = TEXT("D3DRMERR_BADALLOC");
1066 case D3DRMERR_FACEUSED:
1068 lpszError = TEXT("D3DRMERR_FACEUSED");
1071 case D3DRMERR_NOTFOUND:
1073 lpszError = TEXT("D3DRMERR_NOTFOUND");
1076 case D3DRMERR_NOTDONEYET:
1078 lpszError = TEXT("D3DRMERR_NOTDONEYET");
1081 case D3DRMERR_FILENOTFOUND:
1083 lpszError = TEXT("D3DRMERR_FILENOTFOUND");
1086 case D3DRMERR_BADFILE:
1088 lpszError = TEXT("D3DRMERR_BADFILE");
1091 case D3DRMERR_BADDEVICE:
1093 lpszError = TEXT("D3DRMERR_BADDEVICE");
1096 case D3DRMERR_BADVALUE:
1098 lpszError = TEXT("D3DRMERR_BADVALUE");
1101 case D3DRMERR_BADMAJORVERSION:
1103 lpszError = TEXT("D3DRMERR_BADMAJORVERSION");
1106 case D3DRMERR_BADMINORVERSION:
1108 lpszError = TEXT("D3DRMERR_BADMINORVERSION");
1111 case D3DRMERR_UNABLETOEXECUTE:
1113 lpszError = TEXT("D3DRMERR_BADMINORVERSION");
1115 #endif // D3DRM_ERRORS
1119 // Application defined errors
1121 case APPERR_GENERIC:
1123 lpszError = TEXT("APPERR_GENERIC");
1126 case APPERR_INVALIDPARAMS:
1127 // Invalid Parameters passed into function
1128 lpszError = TEXT("APPERR_INVALIDPARAMS");
1131 case APPERR_NOTINITIALIZED:
1132 // Programmer error, called function without proper initialization
1133 lpszError = TEXT("APPERR_NOT_INITIALIZED");
1137 // Unknown DD/D3D/App Error
1138 wsprintf (szMsg, "Unknown Error #%ld", (DWORD)(hResult & 0x0000FFFFL));
1143 // Copy DD/D3D Error string to buff
1144 cLen = strlen (lpszError);
1145 if (cLen >= cchError)
1147 cLen = cchError - 1;
1152 strncpy (lpszErrorBuff, lpszError, cLen);
1153 lpszErrorBuff[cLen] = 0;
1157 } // End GetDDErrorString
1163 **-----------------------------------------------------------------------------
1165 **-----------------------------------------------------------------------------