2 * DirectX 8 error routines
4 * Copyright 2004 Robert Reif
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Add error codes for D3D8, D3DX8, DDRAW, DPLAY8, DMUSIC, DINPUT and DSHOW.
24 * Sort list for faster lookup.
30 #define COM_NO_WINDOWS_H
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(dxerr);
50 const CHAR* descriptionA;
51 const WCHAR* descriptionW;
56 const char * WINAPI DXGetErrorString8A(HRESULT hr)
59 TRACE("(0x%08lx)\n", hr);
61 for (i = 0; i < sizeof(info)/sizeof(info[0]); i++) {
63 return info[i].resultA;
69 const WCHAR * WINAPI DXGetErrorString8W(HRESULT hr)
71 static const WCHAR unknown[] = { 'U', 'n', 'k', 'n', 'o', 'w', 'n', 0 };
73 TRACE("(0x%08lx)\n", hr);
75 for (i = 0; i < sizeof(info)/sizeof(info[0]); i++) {
76 if (hr == info[i].hr) {
77 return info[i].resultW;
84 const char * WINAPI DXGetErrorDescription8A(HRESULT hr)
87 TRACE("(0x%08lx)\n", hr);
89 for (i = 0; i < sizeof(info)/sizeof(info[0]); i++) {
91 return info[i].descriptionA;
97 const WCHAR * WINAPI DXGetErrorDescription8W(HRESULT hr)
99 static const WCHAR na[] = { 'n', '/', 'a', 0 };
101 TRACE("(0x%08lx)\n", hr);
103 for (i = 0; i < sizeof(info)/sizeof(info[0]); i++) {
104 if (hr == info[i].hr) {
105 return info[i].descriptionW;
112 HRESULT WINAPI DXTraceA(const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox)
115 TRACE("(%p,%ld,0x%08lx,%p,%d)\n", strFile, dwLine, hr, strMsg, bPopMsgBox);
118 snprintf(msg, sizeof(msg), "File: %s\nLine: %ld\nError Code: %s (0x%08lx)\nCalling: %s",
119 strFile, dwLine, DXGetErrorString8A(hr), hr, strMsg);
120 MessageBoxA(0, msg, "Unexpected error encountered", MB_OK|MB_ICONERROR);
122 snprintf(msg, sizeof(msg), "%s(%ld): %s (hr=%s (0x%08lx))", strFile,
123 dwLine, strMsg, DXGetErrorString8A(hr), hr);
124 OutputDebugStringA(msg);
130 HRESULT WINAPI DXTraceW(const char* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, BOOL bPopMsgBox)
133 TRACE("(%p,%ld,0x%08lx,%p,%d)\n", strFile, dwLine, hr, strMsg, bPopMsgBox);
136 static const WCHAR format[] = { 'F','i','l','e',':',' ','%','s','\\','n','L','i','n',
137 'e',':',' ','%','l','d','\\','n','E','r','r','o','r',' ','C','o',
138 'd','e',':',' ','%','s',' ','(','0','x','%','0','8','l','x',')',
139 '\\','n','C','a','l','l','i','n','g',':',' ','%','s',0 };
140 static const WCHAR caption[] = { 'U','n','e','x','p','e','c','t','e','d',' ','e','r',
141 'r','o','r',' ','e','n','c','o','u','n','t','e','r','e','d',0 };
142 /* FIXME: should use wsnprintf */
143 wsprintfW(msg, format, strFile, dwLine,
144 DXGetErrorString8W(hr), hr, strMsg);
145 MessageBoxW(0, msg, caption, MB_OK|MB_ICONERROR);
147 static const WCHAR format[] = { '%','s','(','%','l','d',')',':',' ','%','s',' ','(',
148 'h','r','=','%','s',' ','(','0','x','%','0','8','l','x',')',')',' ',
150 /* FIXME: should use wsnprintf */
151 wsprintfW(msg, format, strFile, dwLine, strMsg,
152 DXGetErrorString8W(hr), hr);
153 OutputDebugStringW(msg);