|
| 1 | +//-------------------------------------------------------------------------------------- |
| 2 | +// File: DXErr.h |
| 3 | +// |
| 4 | +// DirectX Error Library |
| 5 | +// |
| 6 | +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF |
| 7 | +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO |
| 8 | +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A |
| 9 | +// PARTICULAR PURPOSE. |
| 10 | +// |
| 11 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 12 | +//-------------------------------------------------------------------------------------- |
| 13 | + |
| 14 | +// This version only supports UNICODE. |
| 15 | + |
| 16 | +#pragma once |
| 17 | + |
| 18 | +#if !defined(NOMINMAX) |
| 19 | +#define NOMINMAX |
| 20 | +#endif |
| 21 | + |
| 22 | +#include <windows.h> |
| 23 | +#include <sal.h> |
| 24 | + |
| 25 | +#ifdef __cplusplus |
| 26 | +extern "C" { |
| 27 | +#endif |
| 28 | + |
| 29 | +//-------------------------------------------------------------------------------------- |
| 30 | +// DXGetErrorString |
| 31 | +//-------------------------------------------------------------------------------------- |
| 32 | +const WCHAR* WINAPI DXGetErrorStringW( _In_ HRESULT hr ); |
| 33 | + |
| 34 | +#define DXGetErrorString DXGetErrorStringW |
| 35 | + |
| 36 | +//-------------------------------------------------------------------------------------- |
| 37 | +// DXGetErrorDescription has to be modified to return a copy in a buffer rather than |
| 38 | +// the original static string. |
| 39 | +//-------------------------------------------------------------------------------------- |
| 40 | +void WINAPI DXGetErrorDescriptionW( _In_ HRESULT hr, _Out_cap_(count) WCHAR* desc, _In_ size_t count ); |
| 41 | + |
| 42 | +#define DXGetErrorDescription DXGetErrorDescriptionW |
| 43 | + |
| 44 | +//-------------------------------------------------------------------------------------- |
| 45 | +// DXTrace |
| 46 | +// |
| 47 | +// Desc: Outputs a formatted error message to the debug stream |
| 48 | +// |
| 49 | +// Args: WCHAR* strFile The current file, typically passed in using the |
| 50 | +// __FILEW__ macro. |
| 51 | +// DWORD dwLine The current line number, typically passed in using the |
| 52 | +// __LINE__ macro. |
| 53 | +// HRESULT hr An HRESULT that will be traced to the debug stream. |
| 54 | +// CHAR* strMsg A string that will be traced to the debug stream (may be NULL) |
| 55 | +// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. |
| 56 | +// |
| 57 | +// Return: The hr that was passed in. |
| 58 | +//-------------------------------------------------------------------------------------- |
| 59 | +HRESULT WINAPI DXTraceW( _In_z_ const WCHAR* strFile, _In_ DWORD dwLine, _In_ HRESULT hr, _In_opt_ const WCHAR* strMsg, _In_ bool bPopMsgBox ); |
| 60 | + |
| 61 | +#define DXTrace DXTraceW |
| 62 | + |
| 63 | +//-------------------------------------------------------------------------------------- |
| 64 | +// |
| 65 | +// Helper macros |
| 66 | +// |
| 67 | +//-------------------------------------------------------------------------------------- |
| 68 | +#if defined(DEBUG) || defined(_DEBUG) |
| 69 | +#define DXTRACE_MSG(str) DXTrace( __FILEW__, (DWORD)__LINE__, 0, str, false ) |
| 70 | +#define DXTRACE_ERR(str,hr) DXTrace( __FILEW__, (DWORD)__LINE__, hr, str, false ) |
| 71 | +#define DXTRACE_ERR_MSGBOX(str,hr) DXTrace( __FILEW__, (DWORD)__LINE__, hr, str, true ) |
| 72 | +#else |
| 73 | +#define DXTRACE_MSG(str) (0L) |
| 74 | +#define DXTRACE_ERR(str,hr) (hr) |
| 75 | +#define DXTRACE_ERR_MSGBOX(str,hr) (hr) |
| 76 | +#endif |
| 77 | + |
| 78 | +#ifdef __cplusplus |
| 79 | +} |
| 80 | +#endif //__cplusplus |
0 commit comments