⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dxutil.h

📁 一款不错的射击类游戏
💻 H
字号:
//-----------------------------------------------------------------------------
// File: DXUtil.h
//
// Desc: Helper functions and typing shortcuts for DirectX programming.
//
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#ifndef DXUTIL_H
#define DXUTIL_H


//-----------------------------------------------------------------------------
// Miscellaneous helper functions
//-----------------------------------------------------------------------------
#define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);   (p)=NULL; } }
#define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }

//-----------------------------------------------------------------------------
// Name: DXUtil_GetDXSDKMediaPath() and DXUtil_FindMediaFile() 
// Desc: Returns the DirectX SDK path, as stored in the system registry
//       during the SDK install.
//-----------------------------------------------------------------------------
class CDXUtil
{
public:
	static const TCHAR* DXUtil_GetDXSDKMediaPath();
	static HRESULT      DXUtil_FindMediaFile( TCHAR* strPath, TCHAR* strFilename );
	//-----------------------------------------------------------------------------
	// Name: DXUtil_Read*RegKey() and DXUtil_Write*RegKey()
	// Desc: Helper functions to read/write a string registry key 
	//-----------------------------------------------------------------------------
	static HRESULT DXUtil_WriteStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue );
	static HRESULT DXUtil_WriteIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD dwValue );
	static HRESULT DXUtil_WriteGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID guidValue );
	static HRESULT DXUtil_WriteBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL bValue );

	static HRESULT DXUtil_ReadStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue, DWORD dwLength, TCHAR* strDefault );
	static HRESULT DXUtil_ReadIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD* pdwValue, DWORD dwDefault );
	static HRESULT DXUtil_ReadGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID* pGuidValue, GUID& guidDefault );
	static HRESULT DXUtil_ReadBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL* pbValue, BOOL bDefault );




	//-----------------------------------------------------------------------------
	// Name: DXUtil_Timer()
	// Desc: Performs timer opertations. Use the following commands:
	//          TIMER_RESET           - to reset the timer
	//          TIMER_START           - to start the timer
	//          TIMER_STOP            - to stop (or pause) the timer
	//          TIMER_ADVANCE         - to advance the timer by 0.1 seconds
	//          TIMER_GETABSOLUTETIME - to get the absolute system time
	//          TIMER_GETAPPTIME      - to get the current time
	//          TIMER_GETELAPSEDTIME  - to get the time that elapsed between 
	//                                  TIMER_GETELAPSEDTIME calls
	//-----------------------------------------------------------------------------
	enum TIMER_COMMAND { TIMER_RESET, TIMER_START, TIMER_STOP, TIMER_ADVANCE,
						 TIMER_GETABSOLUTETIME, TIMER_GETAPPTIME, TIMER_GETELAPSEDTIME };
	static FLOAT __stdcall DXUtil_Timer( TIMER_COMMAND command );




	//-----------------------------------------------------------------------------
	// UNICODE support for converting between CHAR, TCHAR, and WCHAR strings
	//-----------------------------------------------------------------------------
	static VOID DXUtil_ConvertAnsiStringToWide( WCHAR* wstrDestination, const CHAR* strSource, int cchDestChar = -1 );
	static VOID DXUtil_ConvertWideStringToAnsi( CHAR* strDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
	static VOID DXUtil_ConvertGenericStringToAnsi( CHAR* strDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
	static VOID DXUtil_ConvertGenericStringToWide( WCHAR* wstrDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
	static VOID DXUtil_ConvertAnsiStringToGeneric( TCHAR* tstrDestination, const CHAR* strSource, int cchDestChar = -1 );
	static VOID DXUtil_ConvertWideStringToGeneric( TCHAR* tstrDestination, const WCHAR* wstrSource, int cchDestChar = -1 );




	//-----------------------------------------------------------------------------
	// GUID to String converting 
	//-----------------------------------------------------------------------------
	static VOID DXUtil_ConvertGUIDToString( const GUID* pGuidIn, TCHAR* strOut );
	static BOOL DXUtil_ConvertStringToGUID( const TCHAR* strIn, GUID* pGuidOut );




	//-----------------------------------------------------------------------------
	// Debug printing support
	//-----------------------------------------------------------------------------
	static VOID    DXUtil_Trace( TCHAR* strMsg, ... );
	static HRESULT _DbgOut( TCHAR*, DWORD, HRESULT, TCHAR* );
};

#if defined(DEBUG) | defined(_DEBUG)
	#define DXTRACE           CDXUtil::DXUtil_Trace
#else
    #define DXTRACE           sizeof
#endif

#if defined(DEBUG) | defined(_DEBUG)
	#define DEBUG_MSG(str)    CDXUti::_DbgOut( __FILE__, (DWORD)__LINE__, 0, str )
#else
    #define DEBUG_MSG(str)    (0L)
#endif




#endif // DXUTIL_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -