dxutil.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:5k
源码类别:

游戏

开发平台:

Visual C++

  1. //-----------------------------------------------------------------------------
  2. // File: DXUtil.h
  3. //
  4. // Desc: Helper functions and typing shortcuts for DirectX programming.
  5. //
  6. // Copyright (c) 1997-2000 Microsoft Corporation. All rights reserved
  7. //-----------------------------------------------------------------------------
  8. #ifndef DXUTIL_H
  9. #define DXUTIL_H
  10. //-----------------------------------------------------------------------------
  11. // Miscellaneous helper functions
  12. //-----------------------------------------------------------------------------
  13. #define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
  14. #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);   (p)=NULL; } }
  15. #define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }
  16. //-----------------------------------------------------------------------------
  17. // Name: DXUtil_GetDXSDKMediaPath() and DXUtil_FindMediaFile() 
  18. // Desc: Returns the DirectX SDK path, as stored in the system registry
  19. //       during the SDK install.
  20. //-----------------------------------------------------------------------------
  21. const TCHAR* DXUtil_GetDXSDKMediaPath();
  22. HRESULT      DXUtil_FindMediaFile( TCHAR* strPath, TCHAR* strFilename );
  23. //-----------------------------------------------------------------------------
  24. // Name: DXUtil_Read*RegKey() and DXUtil_Write*RegKey()
  25. // Desc: Helper functions to read/write a string registry key 
  26. //-----------------------------------------------------------------------------
  27. HRESULT DXUtil_WriteStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue );
  28. HRESULT DXUtil_WriteIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD dwValue );
  29. HRESULT DXUtil_WriteGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID guidValue );
  30. HRESULT DXUtil_WriteBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL bValue );
  31. HRESULT DXUtil_ReadStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue, DWORD dwLength, TCHAR* strDefault );
  32. HRESULT DXUtil_ReadIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD* pdwValue, DWORD dwDefault );
  33. HRESULT DXUtil_ReadGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID* pGuidValue, GUID& guidDefault );
  34. HRESULT DXUtil_ReadBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL* pbValue, BOOL bDefault );
  35. //-----------------------------------------------------------------------------
  36. // Name: DXUtil_Timer()
  37. // Desc: Performs timer opertations. Use the following commands:
  38. //          TIMER_RESET           - to reset the timer
  39. //          TIMER_START           - to start the timer
  40. //          TIMER_STOP            - to stop (or pause) the timer
  41. //          TIMER_ADVANCE         - to advance the timer by 0.1 seconds
  42. //          TIMER_GETABSOLUTETIME - to get the absolute system time
  43. //          TIMER_GETAPPTIME      - to get the current time
  44. //          TIMER_GETELAPSEDTIME  - to get the time that elapsed between 
  45. //                                  TIMER_GETELAPSEDTIME calls
  46. //-----------------------------------------------------------------------------
  47. enum TIMER_COMMAND { TIMER_RESET, TIMER_START, TIMER_STOP, TIMER_ADVANCE,
  48.                      TIMER_GETABSOLUTETIME, TIMER_GETAPPTIME, TIMER_GETELAPSEDTIME };
  49. FLOAT __stdcall DXUtil_Timer( TIMER_COMMAND command );
  50. //-----------------------------------------------------------------------------
  51. // UNICODE support for converting between CHAR, TCHAR, and WCHAR strings
  52. //-----------------------------------------------------------------------------
  53. VOID DXUtil_ConvertAnsiStringToWide( WCHAR* wstrDestination, const CHAR* strSource, int cchDestChar = -1 );
  54. VOID DXUtil_ConvertWideStringToAnsi( CHAR* strDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
  55. VOID DXUtil_ConvertGenericStringToAnsi( CHAR* strDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
  56. VOID DXUtil_ConvertGenericStringToWide( WCHAR* wstrDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
  57. VOID DXUtil_ConvertAnsiStringToGeneric( TCHAR* tstrDestination, const CHAR* strSource, int cchDestChar = -1 );
  58. VOID DXUtil_ConvertWideStringToGeneric( TCHAR* tstrDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
  59. //-----------------------------------------------------------------------------
  60. // Debug printing support
  61. //-----------------------------------------------------------------------------
  62. VOID    DXUtil_Trace( TCHAR* strMsg, ... );
  63. HRESULT _DbgOut( TCHAR*, DWORD, HRESULT, TCHAR* );
  64. #if defined(DEBUG) | defined(_DEBUG)
  65.     #define DXTRACE           DXUtil_Trace
  66. #else
  67.     #define DXTRACE           sizeof
  68. #endif
  69. #if defined(DEBUG) | defined(_DEBUG)
  70.     #define DEBUG_MSG(str)    _DbgOut( __FILE__, (DWORD)__LINE__, 0, str )
  71. #else
  72.     #define DEBUG_MSG(str)    (0L)
  73. #endif
  74. #endif // DXUTIL_H