00001
00013
00014 #ifndef ___SimpleDX10_SimpleDX10_DebugPrint_H___
00015 #define ___SimpleDX10_SimpleDX10_DebugPrint_H___
00016
00017
00018
00019
00020
00021 #define __file__ (strrchr(__FILE__,'\\') + 1 )
00022 #define __line__ __LINE__
00023 #define __func__ __FUNCSIG__
00024
00025 #if defined( DEBUG ) || defined( _DEBUG )
00026 #define DEBUG_PRINT(...) DebugPrint( __file__, __line__, __func__, __VA_ARGS__ )
00027 #else
00028 #define DEBUG_PRINT(...)
00029 #endif
00030
00031 #define SAFE_RELEASE(p) if(p) { p->Release(); p = NULL; }
00032
00033
00044 static inline void DebugPrint(const char *file, int line, const char *func, const char *fmt, ... )
00045 {
00046 va_list args;
00047 int len;
00048 char buffer[MAX_PATH];
00049 char str[MAX_PATH];
00050 wchar_t wStr[MAX_PATH];
00051
00052 va_start( args, fmt );
00053 len = _vscprintf( fmt, args ) + 1;
00054 vsprintf_s( buffer, MAX_PATH, fmt, args );
00055 va_end( args );
00056
00057 memset(str, 0x0, MAX_PATH);
00058 sprintf_s(str, MAX_PATH, "%s, %s: %d: %s\n", buffer, file, line, func);
00059
00060 MultiByteToWideChar(CP_OEMCP, 0, str, MAX_PATH, wStr, MAX_PATH);
00061
00062 OutputDebugString(static_cast<LPCTSTR>(wStr));
00063 }
00064
00065 #endif // ___SimpleDX10_SimpleDX10_DebugPrint_H___
00066
00067
00068
00069