Simple D3DError module

This is a discussion on Simple D3DError module within the Game Programming forums, part of the General Programming Boards category; This is a simple module that allows you to convert the enum from D3DERR to the appropriate text. It might ...

  1. #1
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596

    Simple D3DError module

    This is a simple module that allows you to convert the enum from D3DERR to the appropriate text. It might not be the most efficient, but it works.

    D3DError.h
    Code:
    #ifndef D3DERROR
    #define D3DERROR
    #include <d3dx9.h>
    #include <d3d9.h>
     
    namespace D3DError
    {
      char *GetTextFromD3DError(HRESULT hr);
    }
     
    #endif
    D3DError.cpp
    Code:
    #include "D3DError.h"
    char *D3DError::GetTextFromD3DError(HRESULT hr)
    {
      char *text="Undefined error";
      
      switch (hr)
      {
    	case D3D_OK:
    	  text="D3D_OK";break;
    	case D3DOK_NOAUTOGEN:
    	  text="D3DOK_NOAUTOGEN";break;
    	case D3DERR_CONFLICTINGRENDERSTATE:
    	  text="D3DERR_CONFLICTINGRENDERSTATE";break;
    	case D3DERR_CONFLICTINGTEXTUREFILTER:
    	  text="D3DERR_CONFLICTINGTEXTUREFILTER";break;
    	case D3DERR_CONFLICTINGTEXTUREPALETTE:
    	  text="D3DERR_CONFLICTINGTEXTUREPALETTE";break;
    	case D3DERR_DEVICELOST:
    	  text="D3DERR_DEVICELOST";break;
    	case D3DERR_DEVICENOTRESET:
    	  text="D3DERR_DEVICENOTRESET";break;
    	case D3DERR_DRIVERINTERNALERROR:
    	  text="D3DERR_DRIVERINTERNALERROR";break;
    	case D3DERR_INVALIDCALL:
    	  text="D3DERR_INVALIDCALL";break;
    	case D3DERR_INVALIDDEVICE:
    	  text="D3DERR_INVALIDDEVICE";break;
    	case D3DERR_MOREDATA:
    	  text="D3DERR_MOREDATA";break;
    	case D3DERR_NOTAVAILABLE:
    	  text="D3DERR_NOTAVAILABLE";break;
    	case D3DERR_NOTFOUND:
    	  text="D3DERR_NOTFOUND";break;
    	case D3DERR_OUTOFVIDEOMEMORY:
    	  text="D3DERR_OUTOFVIDEOMEMORY";break;
    	case D3DERR_TOOMANYOPERATIONS:
    	  text="D3DERR_TOOMANYOPERATIONS";break;
    	case D3DERR_UNSUPPORTEDALPHAARG:
    	  text="D3DERR_UNSUPPORTEDALPHAARG";break;
    	case D3DERR_UNSUPPORTEDALPHAOPERATION:
    	  text="D3DERR_UNSUPPORTEDALPHAOPERATION";break;
    	case D3DERR_UNSUPPORTEDCOLORARG:
    	  text="D3DERR_UNSUPPORTEDCOLORARG";break;
    	case D3DERR_UNSUPPORTEDCOLOROPERATION:
    	  text="D3DERR_UNSUPPORTEDCOLOROPERATION";break;
    	case D3DERR_UNSUPPORTEDFACTORVALUE:
    	  text="D3DERR_UNSUPPORTEDFACTORVALUE";break;
    	case D3DERR_UNSUPPORTEDTEXTUREFILTER:
    	  text="D3DERR_UNSUPPORTEDTEXTUREFILTER";break;
    	case D3DERR_WRONGTEXTUREFORMAT:
    	  text="D3DERR_WRONGTEXTUREFORMAT";break;
    	case E_FAIL:
    	  text="E_FAIL";break;
    	case E_INVALIDARG:
    	  text="E_INVALIDARG";break;
    	case E_OUTOFMEMORY:
    	  text="E_OUTOFMEMORY";break;
      } 
      return text;
    }

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Why reinvent the wheel?

    DXGetErrorString9

    For the lazy...

    Code:
     TCHAR *DXGetErrorString9(HRESULT hr);
    Header: dxerr9.h
    Import Library: dxerr9.lib
    Min OS: Windows 98
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Cause I was looking for the wheel that already had been invented and didn't find it



    Thanks Mr. Wizard for showing me that was a complete waste of time. I looked all over the SDK for something like it.
    Last edited by VirtualAce; 07-08-2004 at 11:04 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating very simple text editor using c
    By if13121 in forum C Programming
    Replies: 9
    Last Post: 10-19-2010, 05:26 PM
  2. Simple message encryption
    By Vicious in forum C++ Programming
    Replies: 10
    Last Post: 11-07-2004, 10:48 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Simple simple program
    By Ryback in forum C++ Programming
    Replies: 10
    Last Post: 09-09-2004, 05:48 AM
  5. Need help with simple DAQ program
    By canada-paul in forum C++ Programming
    Replies: 12
    Last Post: 03-15-2002, 07:52 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21