DXGL r439 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r438‎ | r439 | r440 >
Date:16:48, 17 May 2014
Author:admin
Status:new
Tags:
Comment:
Convert glExtensions and trace to C.
Modified paths:
  • /ddraw/common.h (modified) (history)
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/ddraw.vcxproj.filters (modified) (history)
  • /ddraw/glExtensions.c (added) (history)
  • /ddraw/glExtensions.cpp (deleted) (history)
  • /ddraw/glExtensions.h (modified) (history)
  • /ddraw/glRenderWindow.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/trace.c (added) (history)
  • /ddraw/trace.cpp (deleted) (history)
  • /ddraw/trace.h (modified) (history)

Diff [purge]

Index: ddraw/glExtensions.cpp
@@ -1,168 +0,0 @@
2 -// DXGL
3 -// Copyright (C) 2011-2014 William Feely
4 -
5 -// This library is free software; you can redistribute it and/or
6 -// modify it under the terms of the GNU Lesser General Public
7 -// License as published by the Free Software Foundation; either
8 -// version 2.1 of the License, or (at your option) any later version.
9 -
10 -// This library is distributed in the hope that it will be useful,
11 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 -// Lesser General Public License for more details.
14 -
15 -// You should have received a copy of the GNU Lesser General Public
16 -// License along with this library; if not, write to the Free Software
17 -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 -
19 -#include "common.h"
20 -#include "glExtensions.h"
21 -
22 -
23 -glExtensions::glExtensions()
24 -{
25 - atimem = false;
26 - const GLubyte *glversion = glGetString(GL_VERSION);
27 - glver_minor = 0;
28 - if(!sscanf((char*)glversion,"%d.%d",&glver_major,&glver_minor)) glver_major = 0;
29 - if((glver_major >= 2) || ((glver_major >= 1) && (glver_minor >= 2)))
30 - glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)wglGetProcAddress("glDrawRangeElements");
31 - if((glver_major >= 2) || ((glver_major >= 1) && (glver_minor >= 3)))
32 - {
33 - glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTexture");
34 - glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)wglGetProcAddress("glClientActiveTexture");
35 - }
36 - if((glver_major >= 2) || ((glver_major >= 1) && (glver_minor >= 5)))
37 - {
38 - glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers");
39 - glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers");
40 - glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
41 - glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");
42 - glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer");
43 - glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer");
44 - }
45 - if(glver_major >= 2)
46 - {
47 - glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
48 - glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource");
49 - glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
50 - glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader");
51 - glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
52 - glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram");
53 - glGetProgramiv = (PFNGLGETPROGRAMIVPROC)wglGetProcAddress("glGetProgramiv");
54 - glAttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader");
55 - glDetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader");
56 - glLinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram");
57 - glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
58 - glGetShaderiv = (PFNGLGETSHADERIVPROC)wglGetProcAddress("glGetShaderiv");
59 - glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog");
60 - glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog");
61 - glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation");
62 - glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i");
63 - glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i");
64 - glUniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i");
65 - glUniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i");
66 - glUniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv");
67 - glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f");
68 - glUniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f");
69 - glUniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f");
70 - glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
71 - glUniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv");
72 - glUniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv");
73 - glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv");
74 - glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv");
75 - glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation");
76 - glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
77 - glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
78 - glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray");
79 - }
80 - else
81 - {
82 - MessageBox(NULL,_T("DXGL requires an OpenGL 2.0 or higher compatible graphics card to function. \
83 -Please contact your graphics card manufacturer for an updated driver. This program will now exit."),_T("Fatal error"),
84 - MB_OK|MB_ICONERROR);
85 - ExitProcess(-1);
86 - }
87 - const GLubyte *glextensions = glGetString(GL_EXTENSIONS);
88 - if(strstr((char*)glextensions,"GL_ARB_framebuffer_object") || (glver_major >= 3)) GLEXT_ARB_framebuffer_object = 1;
89 - else GLEXT_ARB_framebuffer_object = 0;
90 - if(strstr((char*)glextensions,"GL_EXT_framebuffer_object")) GLEXT_EXT_framebuffer_object = 1;
91 - else GLEXT_EXT_framebuffer_object = 0;
92 - if(strstr((char*)glextensions,"GL_NV_packed_depth_stencil")) GLEXT_NV_packed_depth_stencil = 1;
93 - else GLEXT_NV_packed_depth_stencil = 0;
94 - if(strstr((char*)glextensions,"GL_EXT_packed_depth_stencil")) GLEXT_EXT_packed_depth_stencil = 1;
95 - else GLEXT_EXT_packed_depth_stencil = 0;
96 - if(strstr((char*)glextensions,"GL_ARB_depth_buffer_float") || (glver_major >= 3)) GLEXT_ARB_depth_buffer_float = 1;
97 - else GLEXT_ARB_depth_buffer_float = 0;
98 - if(strstr((char*)glextensions,"GL_ARB_depth_texture") || (glver_major >= 2)
99 - || ((glver_major >= 1) && (glver_minor >= 4))) GLEXT_ARB_depth_texture = 1;
100 - else GLEXT_ARB_depth_texture = 0;
101 - if(strstr((char*)glextensions,"GL_NVX_gpu_memory_info")) GLEXT_NVX_gpu_memory_info = 1;
102 - else GLEXT_NVX_gpu_memory_info = 0;
103 - if(strstr((char*)glextensions,"GL_ATI_meminfo")) GLEXT_ATI_meminfo = 1;
104 - else GLEXT_ATI_meminfo = 0;
105 - if(strstr((char*)glextensions,"GL_ARB_ES2_compatibility") || (glver_major >= 5)
106 - || ((glver_major >= 4) && (glver_minor >= 1))) GLEXT_ARB_ES2_compatibility = 1;
107 - else GLEXT_ARB_ES2_compatibility = 0;
108 - if(strstr((char*)glextensions,"GL_EXT_direct_state_access")) GLEXT_EXT_direct_state_access = 1;
109 - else GLEXT_EXT_direct_state_access = 0;
110 - if(strstr((char*)glextensions,"GL_ARB_sampler_objects") || (glver_major >= 4)
111 - || ((glver_major >= 3) && (glver_minor >= 3))) GLEXT_ARB_sampler_objects = 1;
112 - else GLEXT_ARB_sampler_objects = 0;
113 - bool broken_fbo = true;
114 - if(GLEXT_ARB_framebuffer_object)
115 - {
116 - glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers");
117 - if(!glGenFramebuffers) GLEXT_ARB_framebuffer_object = 0;
118 - glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer");
119 - glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers");
120 - glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer");
121 - glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D");
122 - glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress("glCheckFramebufferStatus");
123 - glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers");
124 - broken_fbo = false;
125 - }
126 - if(GLEXT_EXT_framebuffer_object)
127 - {
128 - glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)wglGetProcAddress("glGenFramebuffersEXT");
129 - if(!glGenFramebuffersEXT) GLEXT_EXT_framebuffer_object = 0;
130 - glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)wglGetProcAddress("glBindFramebufferEXT");
131 - glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)wglGetProcAddress("glGenRenderbuffersEXT");
132 - glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)wglGetProcAddress("glBindRenderbufferEXT");
133 - glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)wglGetProcAddress("glFramebufferTexture2DEXT");
134 - glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress("glCheckFramebufferStatusEXT");
135 - glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)wglGetProcAddress("glDeleteFramebuffersEXT");
136 - broken_fbo = false;
137 - }
138 - if(GLEXT_EXT_direct_state_access)
139 - {
140 - glTextureParameterfEXT = (PFNGLTEXTUREPARAMETERFEXTPROC)wglGetProcAddress("glTextureParameterfEXT");
141 - glTextureParameterfvEXT = (PFNGLTEXTUREPARAMETERFVEXTPROC)wglGetProcAddress("glTextureParameterfvEXT");
142 - glTextureParameteriEXT = (PFNGLTEXTUREPARAMETERIEXTPROC)wglGetProcAddress("glTextureParameteriEXT");
143 - glTextureParameterivEXT = (PFNGLTEXTUREPARAMETERIVEXTPROC)wglGetProcAddress("glTextureParameterivEXT");
144 - glTextureImage2DEXT = (PFNGLTEXTUREIMAGE2DEXTPROC)wglGetProcAddress("glTextureImage2DEXT");
145 - glTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)wglGetProcAddress("glTextureSubImage2DEXT");
146 - glGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)wglGetProcAddress("glGetTextureImageEXT");
147 - glMatrixLoadfEXT = (PFNGLMATRIXLOADFEXTPROC)wglGetProcAddress("glMatrixLoadfEXT");
148 - glMatrixMultfEXT = (PFNGLMATRIXMULTFEXTPROC)wglGetProcAddress("glMatrixMultfEXT");
149 - }
150 - if(GLEXT_ARB_sampler_objects)
151 - {
152 - glBindSampler = (PFNGLBINDSAMPLERPROC)wglGetProcAddress("glBindSampler");
153 - glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)wglGetProcAddress("glDeleteSamplers");
154 - glGenSamplers = (PFNGLGENSAMPLERSPROC)wglGetProcAddress("glGenSamplers");
155 - glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)wglGetProcAddress("glSamplerParameterf");
156 - glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)wglGetProcAddress("glSamplerParameteri");
157 - glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)wglGetProcAddress("glSamplerParameterfv");
158 - glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)wglGetProcAddress("glSamplerParameteriv");
159 - }
160 - if(broken_fbo)
161 - {
162 - MessageBox(NULL,_T("DXGL requires support for OpenGL Framebuffer Objects to function. \
163 -Please contact your graphics card manufacturer for an updated driver. This program will now exit."),_T("Fatal error"),
164 - MB_OK|MB_ICONERROR);
165 - ExitProcess(-1);
166 - }
167 - wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
168 - wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT");
169 -}
Index: ddraw/trace.cpp
@@ -1,1210 +0,0 @@
2 -// DXGL
3 -// Copyright (C) 2013 William Feely
4 -
5 -// This library is free software; you can redistribute it and/or
6 -// modify it under the terms of the GNU Lesser General Public
7 -// License as published by the Free Software Foundation; either
8 -// version 2.1 of the License, or (at your option) any later version.
9 -
10 -// This library is distributed in the hope that it will be useful,
11 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 -// Lesser General Public License for more details.
14 -
15 -// You should have received a copy of the GNU Lesser General Public
16 -// License along with this library; if not, write to the Free Software
17 -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 -
19 -#include "common.h"
20 -#include "trace.h"
21 -
22 -/* Data types:
23 --1 - C++ constructor/destructor
24 -0 - void
25 -1 - 8-bit signed
26 -2 - 8-bit unsigned
27 -3 - 8-bit hex
28 -4 - 16 bit signed
29 -5 - 16 bit unsigned
30 -6 - 16 bit hex
31 -7 - 32 bit signed
32 -8 - 32 bit unsigned
33 -9 - 32 bit hex
34 -10 - pointer to 64 bit hex
35 -11 - native signed
36 -12 - native unsigned
37 -13 - native hex
38 -14 - generic pointer
39 -15 - ASCII string
40 -16 - Unicode string
41 -17 - TCHAR string
42 -18 - ASCII character
43 -19 - pointer to 32 bit float
44 -20 - pointer to 64 bit float
45 -21 - c++ bool
46 -22 - int BOOL
47 -23 - HRESULT
48 -24 - GUID pointer
49 -25 - SIZE or POINT pointer
50 -26 - RECT pointer
51 -27 - D3DRENDERSTATETYPE
52 -28 - D3DTEXTURESTAGESTATETYPE
53 -29 - D3DTRANSFORMSTATETYPE
54 -30 - D3DLIGHTSTATETYPE
55 -*/
56 -
57 -#ifdef _TRACE
58 -static CRITICAL_SECTION trace_cs;
59 -static bool trace_ready = false;
60 -static bool trace_fail = false;
61 -bool trace_end = false;
62 -static HANDLE outfile = INVALID_HANDLE_VALUE;
63 -unsigned int trace_depth = 0;
64 -static void trace_decode_hresult(HRESULT hr)
65 -{
66 - DWORD byteswritten;
67 - char str[64];
68 - switch(hr)
69 - {
70 - case DD_OK:
71 - strcpy(str,"DD_OK");
72 - break;
73 - case DD_FALSE:
74 - strcpy(str,"DD_FALSE");
75 - break;
76 - case DDERR_ALREADYINITIALIZED:
77 - strcpy(str,"DDERR_ALREADYINITIALIZED");
78 - break;
79 - case DDERR_CANNOTATTACHSURFACE:
80 - strcpy(str,"DDERR_CANNOTATTACHSURFACE");
81 - break;
82 - case DDERR_CANNOTDETACHSURFACE:
83 - strcpy(str,"DDERR_CANNOTDETACHSURFACE");
84 - break;
85 - case DDERR_CURRENTLYNOTAVAIL:
86 - strcpy(str,"DDERR_CURRENTLYNOTAVAIL");
87 - break;
88 - case DDERR_EXCEPTION:
89 - strcpy(str,"DDERR_EXCEPTION");
90 - break;
91 - case DDERR_GENERIC:
92 - strcpy(str,"DDERR_GENERIC");
93 - break;
94 - case DDERR_INCOMPATIBLEPRIMARY:
95 - strcpy(str,"DDERR_INCOMPATIBLEPRIMARY");
96 - break;
97 - case DDERR_INVALIDCAPS:
98 - strcpy(str,"DDERR_INVALIDCAPS");
99 - break;
100 - case DDERR_INVALIDCLIPLIST:
101 - strcpy(str,"DDERR_INVALIDCLIPLIST");
102 - break;
103 - case DDERR_INVALIDMODE:
104 - strcpy(str,"DDERR_INVALIDMODE");
105 - break;
106 - case DDERR_INVALIDPARAMS:
107 - strcpy(str,"DDERR_INVALIDPARAMS");
108 - break;
109 - case DDERR_INVALIDPIXELFORMAT:
110 - strcpy(str,"DDERR_INVALIDPIXELFORMAT");
111 - break;
112 - case DDERR_INVALIDRECT:
113 - strcpy(str,"DDERR_INVALIDRECT");
114 - break;
115 - case DDERR_NOTFOUND:
116 - strcpy(str,"DDERR_NOTFOUND");
117 - break;
118 - case DDERR_OUTOFMEMORY:
119 - strcpy(str,"DDERR_OUTOFMEMORY");
120 - break;
121 - case DDERR_OUTOFVIDEOMEMORY:
122 - strcpy(str,"DDERR_OUTOFVIDEOMEMORY");
123 - break;
124 - case DDERR_SURFACEALREADYATTACHED:
125 - strcpy(str,"DDERR_SURFACEALREADYATTACHED");
126 - break;
127 - case DDERR_SURFACEBUSY:
128 - strcpy(str,"DDERR_SURFACEBUSY");
129 - break;
130 - case DDERR_CANTLOCKSURFACE:
131 - strcpy(str,"DDERR_CANTLOCKSURFACE");
132 - break;
133 - case DDERR_SURFACELOST:
134 - strcpy(str,"DDERR_SURFACELOST");
135 - break;
136 - case DDERR_SURFACENOTATTACHED:
137 - strcpy(str,"DDERR_SURFACENOTATTACHED");
138 - break;
139 - case DDERR_UNSUPPORTED:
140 - strcpy(str,"DDERR_UNSUPPORTED");
141 - break;
142 - case DDERR_UNSUPPORTEDFORMAT:
143 - strcpy(str,"DDERR_UNSUPPORTEDFORMAT");
144 - break;
145 - case DDERR_UNSUPPORTEDMASK:
146 - strcpy(str,"DDERR_UNSUPPORTEDMASK");
147 - break;
148 - case DDERR_WASSTILLDRAWING:
149 - strcpy(str,"DDERR_WASSTILLDRAWING");
150 - break;
151 - case DDERR_INVALIDDIRECTDRAWGUID:
152 - strcpy(str,"DDERR_INVALIDDIRECTDRAWGUID");
153 - break;
154 - case DDERR_DIRECTDRAWALREADYCREATED:
155 - strcpy(str,"DDERR_DIRECTDRAWALREADYCREATED");
156 - break;
157 - case DDERR_NODIRECTDRAWHW:
158 - strcpy(str,"DDERR_NODIRECTDRAWHW");
159 - break;
160 - case DDERR_PRIMARYSURFACEALREADYEXISTS:
161 - strcpy(str,"DDERR_PRIMARYSURFACEALREADYEXISTS");
162 - break;
163 - case DDERR_CLIPPERISUSINGHWND:
164 - strcpy(str,"DDERR_CLIPPERISUSINGHWND");
165 - break;
166 - case DDERR_NOCLIPPERATTACHED:
167 - strcpy(str,"DDERR_NOCLIPPERATTACHED");
168 - break;
169 - case DDERR_NOHWND:
170 - strcpy(str,"DDERR_NOHWND");
171 - break;
172 - case DDERR_HWNDSUBCLASSED:
173 - strcpy(str,"DDERR_HWNDSUBCLASSED");
174 - break;
175 - case DDERR_HWNDALREADYSET:
176 - strcpy(str,"DDERR_HWNDALREADYSET");
177 - break;
178 - case DDERR_NOPALETTEATTACHED:
179 - strcpy(str,"DDERR_NOPALETTEATTACHED");
180 - break;
181 - case DDERR_NOPALETTEHW:
182 - strcpy(str,"DDERR_NOPALETTEHW");
183 - break;
184 - case DDERR_BLTFASTCANTCLIP:
185 - strcpy(str,"DDERR_BLTFASTCANTCLIP");
186 - break;
187 - case DDERR_OVERLAYNOTVISIBLE:
188 - strcpy(str,"DDERR_OVERLAYNOTVISIBLE");
189 - break;
190 - case DDERR_NOOVERLAYDEST:
191 - strcpy(str,"DDERR_NOOVERLAYDEST");
192 - break;
193 - case DDERR_EXCLUSIVEMODEALREADYSET:
194 - strcpy(str,"DDERR_EXCLUSIVEMODEALREADYSET");
195 - break;
196 - case DDERR_NOTFLIPPABLE:
197 - strcpy(str,"DDERR_NOTFLIPPABLE");
198 - break;
199 - case DDERR_CANTDUPLICATE:
200 - strcpy(str,"DDERR_CANTDUPLICATE");
201 - break;
202 - case DDERR_NOTLOCKED:
203 - strcpy(str,"DDERR_NOTLOCKED");
204 - break;
205 - case DDERR_CANTCREATEDC:
206 - strcpy(str,"DDERR_CANTCREATEDC");
207 - break;
208 - case DDERR_NODC:
209 - strcpy(str,"DDERR_NODC");
210 - break;
211 - case DDERR_WRONGMODE:
212 - strcpy(str,"DDERR_WRONGMODE");
213 - break;
214 - case DDERR_IMPLICITLYCREATED:
215 - strcpy(str,"DDERR_IMPLICITLYCREATED");
216 - break;
217 - case DDERR_NOTPALETTIZED:
218 - strcpy(str,"DDERR_NOTPALETTIZED");
219 - break;
220 - case DDERR_UNSUPPORTEDMODE:
221 - strcpy(str,"DDERR_UNSUPPORTEDMODE");
222 - break;
223 - case DDERR_INVALIDSURFACETYPE:
224 - strcpy(str,"DDERR_INVALIDSURFACETYPE");
225 - break;
226 - case DDERR_NOTONMIPMAPSUBLEVEL:
227 - strcpy(str,"DDERR_NOTONMIPMAPSUBLEVEL");
228 - break;
229 - case DDERR_DCALREADYCREATED:
230 - strcpy(str,"DDERR_DCALREADYCREATED");
231 - break;
232 - case DDERR_CANTPAGELOCK:
233 - strcpy(str,"DDERR_CANTPAGELOCK");
234 - break;
235 - case DDERR_CANTPAGEUNLOCK:
236 - strcpy(str,"DDERR_CANTPAGEUNLOCK");
237 - break;
238 - case DDERR_NOTPAGELOCKED:
239 - strcpy(str,"DDERR_NOTPAGELOCKED");
240 - break;
241 - case DDERR_MOREDATA:
242 - strcpy(str,"DDERR_MOREDATA");
243 - break;
244 - case DDERR_NOTINITIALIZED:
245 - strcpy(str,"DDERR_NOTINITIALIZED");
246 - break;
247 - case E_NOINTERFACE:
248 - strcpy(str,"E_NOINTERFACE");
249 - break;
250 - case CLASS_E_NOAGGREGATION:
251 - strcpy(str,"CLASS_E_NOAGGREGATION");
252 - break;
253 - default:
254 - sprintf(str,"(HRESULT)0x%08X",hr);
255 - break;
256 - }
257 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
258 -}
259 -
260 -static void trace_decode_d3drenderstate(DWORD rs)
261 -{
262 - DWORD byteswritten;
263 - char str[64];
264 - switch(rs)
265 - {
266 - case D3DRENDERSTATE_TEXTUREHANDLE:
267 - strcpy(str,"D3DRENDERSTATE_TEXTUREHANDLE");
268 - break;
269 - case D3DRENDERSTATE_ANTIALIAS:
270 - strcpy(str,"D3DRENDERSTATE_ANTIALIAS");
271 - break;
272 - case D3DRENDERSTATE_TEXTUREADDRESS:
273 - strcpy(str,"D3DRENDERSTATE_TEXTUREADDRESS");
274 - break;
275 - case D3DRENDERSTATE_TEXTUREPERSPECTIVE:
276 - strcpy(str,"D3DRENDERSTATE_TEXTUREPERSPECTIVE");
277 - break;
278 - case D3DRENDERSTATE_WRAPU:
279 - strcpy(str,"D3DRENDERSTATE_WRAPU");
280 - break;
281 - case D3DRENDERSTATE_WRAPV:
282 - strcpy(str,"D3DRENDERSTATE_WRAPV");
283 - break;
284 - case D3DRENDERSTATE_ZENABLE:
285 - strcpy(str,"D3DRENDERSTATE_ZENABLE");
286 - break;
287 - case D3DRENDERSTATE_FILLMODE:
288 - strcpy(str,"D3DRENDERSTATE_FILLMODE");
289 - break;
290 - case D3DRENDERSTATE_SHADEMODE:
291 - strcpy(str,"D3DRENDERSTATE_SHADEMODE");
292 - break;
293 - case D3DRENDERSTATE_LINEPATTERN:
294 - strcpy(str,"D3DRENDERSTATE_LINEPATTERN");
295 - break;
296 - case D3DRENDERSTATE_MONOENABLE:
297 - strcpy(str,"D3DRENDERSTATE_MONOENABLE");
298 - break;
299 - case D3DRENDERSTATE_ROP2:
300 - strcpy(str,"D3DRENDERSTATE_ROP2");
301 - break;
302 - case D3DRENDERSTATE_PLANEMASK:
303 - strcpy(str,"D3DRENDERSTATE_PLANEMASK");
304 - break;
305 - case D3DRENDERSTATE_ZWRITEENABLE:
306 - strcpy(str,"D3DRENDERSTATE_ZWRITEENABLE");
307 - break;
308 - case D3DRENDERSTATE_ALPHATESTENABLE:
309 - strcpy(str,"D3DRENDERSTATE_ALPHATESTENABLE");
310 - break;
311 - case D3DRENDERSTATE_LASTPIXEL:
312 - strcpy(str,"D3DRENDERSTATE_LASTPIXEL");
313 - break;
314 - case D3DRENDERSTATE_TEXTUREMAG:
315 - strcpy(str,"D3DRENDERSTATE_TEXTUREMAG");
316 - break;
317 - case D3DRENDERSTATE_TEXTUREMIN:
318 - strcpy(str,"D3DRENDERSTATE_TEXTUREMIN");
319 - break;
320 - case D3DRENDERSTATE_SRCBLEND:
321 - strcpy(str,"D3DRENDERSTATE_SRCBLEND");
322 - break;
323 - case D3DRENDERSTATE_DESTBLEND:
324 - strcpy(str,"D3DRENDERSTATE_DESTBLEND");
325 - break;
326 - case D3DRENDERSTATE_TEXTUREMAPBLEND:
327 - strcpy(str,"D3DRENDERSTATE_TEXTUREMAPBLEND");
328 - break;
329 - case D3DRENDERSTATE_CULLMODE:
330 - strcpy(str,"D3DRENDERSTATE_CULLMODE");
331 - break;
332 - case D3DRENDERSTATE_ZFUNC:
333 - strcpy(str,"D3DRENDERSTATE_ZFUNC");
334 - break;
335 - case D3DRENDERSTATE_ALPHAREF:
336 - strcpy(str,"D3DRENDERSTATE_ALPHAREF");
337 - break;
338 - case D3DRENDERSTATE_ALPHAFUNC:
339 - strcpy(str,"D3DRENDERSTATE_ALPHAFUNC");
340 - break;
341 - case D3DRENDERSTATE_DITHERENABLE:
342 - strcpy(str,"D3DRENDERSTATE_DITHERENABLE");
343 - break;
344 - case D3DRENDERSTATE_ALPHABLENDENABLE:
345 - strcpy(str,"D3DRENDERSTATE_ALPHABLENDENABLE");
346 - break;
347 - case D3DRENDERSTATE_FOGENABLE:
348 - strcpy(str,"D3DRENDERSTATE_FOGENABLE");
349 - break;
350 - case D3DRENDERSTATE_SPECULARENABLE:
351 - strcpy(str,"D3DRENDERSTATE_SPECULARENABLE");
352 - break;
353 - case D3DRENDERSTATE_ZVISIBLE:
354 - strcpy(str,"D3DRENDERSTATE_ZVISIBLE");
355 - break;
356 - case D3DRENDERSTATE_SUBPIXEL:
357 - strcpy(str,"D3DRENDERSTATE_SUBPIXEL");
358 - break;
359 - case D3DRENDERSTATE_SUBPIXELX:
360 - strcpy(str,"D3DRENDERSTATE_SUBPIXELX");
361 - break;
362 - case D3DRENDERSTATE_STIPPLEDALPHA:
363 - strcpy(str,"D3DRENDERSTATE_STIPPLEDALPHA");
364 - break;
365 - case D3DRENDERSTATE_FOGCOLOR:
366 - strcpy(str,"D3DRENDERSTATE_FOGCOLOR");
367 - break;
368 - case D3DRENDERSTATE_FOGTABLEMODE:
369 - strcpy(str,"D3DRENDERSTATE_FOGTABLEMODE");
370 - break;
371 - case D3DRENDERSTATE_FOGSTART:
372 - strcpy(str,"D3DRENDERSTATE_FOGSTART");
373 - break;
374 - case D3DRENDERSTATE_FOGEND:
375 - strcpy(str,"D3DRENDERSTATE_FOGEND");
376 - break;
377 - case D3DRENDERSTATE_FOGDENSITY:
378 - strcpy(str,"D3DRENDERSTATE_FOGDENSITY");
379 - break;
380 - case D3DRENDERSTATE_STIPPLEENABLE:
381 - strcpy(str,"D3DRENDERSTATE_STIPPLEENABLE");
382 - break;
383 - case D3DRENDERSTATE_EDGEANTIALIAS:
384 - strcpy(str,"D3DRENDERSTATE_EDGEANTIALIAS");
385 - break;
386 - case D3DRENDERSTATE_COLORKEYENABLE:
387 - strcpy(str,"D3DRENDERSTATE_COLORKEYENABLE");
388 - break;
389 - case 42: // DX5 D3DRENDERSTATE_ALPHABLENDENABLE
390 - strcpy(str,"D3DRENDERSTATE_ALPHABLENDENABLE(DX5)");
391 - break;
392 - case D3DRENDERSTATE_BORDERCOLOR:
393 - strcpy(str,"D3DRENDERSTATE_BORDERCOLOR");
394 - break;
395 - case D3DRENDERSTATE_TEXTUREADDRESSU:
396 - strcpy(str,"D3DRENDERSTATE_TEXTUREADDRESSU");
397 - break;
398 - case D3DRENDERSTATE_TEXTUREADDRESSV:
399 - strcpy(str,"D3DRENDERSTATE_TEXTUREADDRESSV");
400 - break;
401 - case D3DRENDERSTATE_MIPMAPLODBIAS:
402 - strcpy(str,"D3DRENDERSTATE_MIPMAPLODBIAS");
403 - break;
404 - case D3DRENDERSTATE_ZBIAS:
405 - strcpy(str,"D3DRENDERSTATE_ZBIAS");
406 - break;
407 - case D3DRENDERSTATE_RANGEFOGENABLE:
408 - strcpy(str,"D3DRENDERSTATE_RANGEFOGENABLE");
409 - break;
410 - case D3DRENDERSTATE_ANISOTROPY:
411 - strcpy(str,"D3DRENDERSTATE_ANISOTROPY");
412 - break;
413 - case D3DRENDERSTATE_FLUSHBATCH:
414 - strcpy(str,"D3DRENDERSTATE_FLUSHBATCH");
415 - break;
416 - case D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT:
417 - strcpy(str,"D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT");
418 - break;
419 - case D3DRENDERSTATE_STENCILENABLE:
420 - strcpy(str,"D3DRENDERSTATE_STENCILENABLE");
421 - break;
422 - case D3DRENDERSTATE_STENCILFAIL:
423 - strcpy(str,"D3DRENDERSTATE_STENCILFAIL");
424 - break;
425 - case D3DRENDERSTATE_STENCILZFAIL:
426 - strcpy(str,"D3DRENDERSTATE_STENCILZFAIL");
427 - break;
428 - case D3DRENDERSTATE_STENCILPASS:
429 - strcpy(str,"D3DRENDERSTATE_STENCILPASS");
430 - break;
431 - case D3DRENDERSTATE_STENCILFUNC:
432 - strcpy(str,"D3DRENDERSTATE_STENCILFUNC");
433 - break;
434 - case D3DRENDERSTATE_STENCILREF:
435 - strcpy(str,"D3DRENDERSTATE_STENCILREF");
436 - break;
437 - case D3DRENDERSTATE_STENCILMASK:
438 - strcpy(str,"D3DRENDERSTATE_STENCILMASK");
439 - break;
440 - case D3DRENDERSTATE_STENCILWRITEMASK:
441 - strcpy(str,"D3DRENDERSTATE_STENCILWRITEMASK");
442 - break;
443 - case D3DRENDERSTATE_TEXTUREFACTOR:
444 - strcpy(str,"D3DRENDERSTATE_TEXTUREFACTOR");
445 - break;
446 - case D3DRENDERSTATE_STIPPLEPATTERN00:
447 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN00");
448 - break;
449 - case D3DRENDERSTATE_STIPPLEPATTERN01:
450 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN01");
451 - break;
452 - case D3DRENDERSTATE_STIPPLEPATTERN02:
453 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN02");
454 - break;
455 - case D3DRENDERSTATE_STIPPLEPATTERN03:
456 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN03");
457 - break;
458 - case D3DRENDERSTATE_STIPPLEPATTERN04:
459 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN04");
460 - break;
461 - case D3DRENDERSTATE_STIPPLEPATTERN05:
462 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN05");
463 - break;
464 - case D3DRENDERSTATE_STIPPLEPATTERN06:
465 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN06");
466 - break;
467 - case D3DRENDERSTATE_STIPPLEPATTERN07:
468 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN07");
469 - break;
470 - case D3DRENDERSTATE_STIPPLEPATTERN08:
471 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN08");
472 - break;
473 - case D3DRENDERSTATE_STIPPLEPATTERN09:
474 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN09");
475 - break;
476 - case D3DRENDERSTATE_STIPPLEPATTERN10:
477 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN10");
478 - break;
479 - case D3DRENDERSTATE_STIPPLEPATTERN11:
480 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN11");
481 - break;
482 - case D3DRENDERSTATE_STIPPLEPATTERN12:
483 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN12");
484 - break;
485 - case D3DRENDERSTATE_STIPPLEPATTERN13:
486 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN13");
487 - break;
488 - case D3DRENDERSTATE_STIPPLEPATTERN14:
489 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN14");
490 - break;
491 - case D3DRENDERSTATE_STIPPLEPATTERN15:
492 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN15");
493 - break;
494 - case D3DRENDERSTATE_STIPPLEPATTERN16:
495 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN16");
496 - break;
497 - case D3DRENDERSTATE_STIPPLEPATTERN17:
498 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN17");
499 - break;
500 - case D3DRENDERSTATE_STIPPLEPATTERN18:
501 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN18");
502 - break;
503 - case D3DRENDERSTATE_STIPPLEPATTERN19:
504 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN19");
505 - break;
506 - case D3DRENDERSTATE_STIPPLEPATTERN20:
507 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN20");
508 - break;
509 - case D3DRENDERSTATE_STIPPLEPATTERN21:
510 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN21");
511 - break;
512 - case D3DRENDERSTATE_STIPPLEPATTERN22:
513 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN22");
514 - break;
515 - case D3DRENDERSTATE_STIPPLEPATTERN23:
516 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN23");
517 - break;
518 - case D3DRENDERSTATE_STIPPLEPATTERN24:
519 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN24");
520 - break;
521 - case D3DRENDERSTATE_STIPPLEPATTERN25:
522 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN25");
523 - break;
524 - case D3DRENDERSTATE_STIPPLEPATTERN26:
525 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN26");
526 - break;
527 - case D3DRENDERSTATE_STIPPLEPATTERN27:
528 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN27");
529 - break;
530 - case D3DRENDERSTATE_STIPPLEPATTERN28:
531 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN28");
532 - break;
533 - case D3DRENDERSTATE_STIPPLEPATTERN29:
534 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN29");
535 - break;
536 - case D3DRENDERSTATE_STIPPLEPATTERN30:
537 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN30");
538 - break;
539 - case D3DRENDERSTATE_STIPPLEPATTERN31:
540 - strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN31");
541 - break;
542 - case D3DRENDERSTATE_WRAP0:
543 - strcpy(str,"D3DRENDERSTATE_WRAP0");
544 - break;
545 - case D3DRENDERSTATE_WRAP1:
546 - strcpy(str,"D3DRENDERSTATE_WRAP1");
547 - break;
548 - case D3DRENDERSTATE_WRAP2:
549 - strcpy(str,"D3DRENDERSTATE_WRAP2");
550 - break;
551 - case D3DRENDERSTATE_WRAP3:
552 - strcpy(str,"D3DRENDERSTATE_WRAP3");
553 - break;
554 - case D3DRENDERSTATE_WRAP4:
555 - strcpy(str,"D3DRENDERSTATE_WRAP4");
556 - break;
557 - case D3DRENDERSTATE_WRAP5:
558 - strcpy(str,"D3DRENDERSTATE_WRAP5");
559 - break;
560 - case D3DRENDERSTATE_WRAP6:
561 - strcpy(str,"D3DRENDERSTATE_WRAP6");
562 - break;
563 - case D3DRENDERSTATE_WRAP7:
564 - strcpy(str,"D3DRENDERSTATE_WRAP7");
565 - break;
566 - case D3DRENDERSTATE_CLIPPING:
567 - strcpy(str,"D3DRENDERSTATE_CLIPPING");
568 - break;
569 - case D3DRENDERSTATE_LIGHTING:
570 - strcpy(str,"D3DRENDERSTATE_LIGHTING");
571 - break;
572 - case D3DRENDERSTATE_EXTENTS:
573 - strcpy(str,"D3DRENDERSTATE_EXTENTS");
574 - break;
575 - case D3DRENDERSTATE_AMBIENT:
576 - strcpy(str,"D3DRENDERSTATE_AMBIENT");
577 - break;
578 - case D3DRENDERSTATE_FOGVERTEXMODE:
579 - strcpy(str,"D3DRENDERSTATE_FOGVERTEXMODE");
580 - break;
581 - case D3DRENDERSTATE_COLORVERTEX:
582 - strcpy(str,"D3DRENDERSTATE_COLORVERTEX");
583 - break;
584 - case D3DRENDERSTATE_LOCALVIEWER:
585 - strcpy(str,"D3DRENDERSTATE_LOCALVIEWER");
586 - break;
587 - case D3DRENDERSTATE_NORMALIZENORMALS:
588 - strcpy(str,"D3DRENDERSTATE_NORMALIZENORMALS");
589 - break;
590 - case D3DRENDERSTATE_COLORKEYBLENDENABLE:
591 - strcpy(str,"D3DRENDERSTATE_COLORKEYBLENDENABLE");
592 - break;
593 - case D3DRENDERSTATE_DIFFUSEMATERIALSOURCE:
594 - strcpy(str,"D3DRENDERSTATE_DIFFUSEMATERIALSOURCE");
595 - break;
596 - case D3DRENDERSTATE_SPECULARMATERIALSOURCE:
597 - strcpy(str,"D3DRENDERSTATE_SPECULARMATERIALSOURCE");
598 - break;
599 - case D3DRENDERSTATE_AMBIENTMATERIALSOURCE:
600 - strcpy(str,"D3DRENDERSTATE_AMBIENTMATERIALSOURCE");
601 - break;
602 - case D3DRENDERSTATE_EMISSIVEMATERIALSOURCE:
603 - strcpy(str,"D3DRENDERSTATE_EMISSIVEMATERIALSOURCE");
604 - break;
605 - case D3DRENDERSTATE_VERTEXBLEND:
606 - strcpy(str,"D3DRENDERSTATE_VERTEXBLEND");
607 - break;
608 - case D3DRENDERSTATE_CLIPPLANEENABLE:
609 - strcpy(str,"D3DRENDERSTATE_CLIPPLANEENABLE");
610 - break;
611 - default:
612 - sprintf(str,"(D3DRENDERSTATETYPE)%u",rs);
613 - break;
614 - }
615 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
616 -}
617 -
618 -static void trace_decode_d3dtexturestagestate(DWORD ts)
619 -{
620 - DWORD byteswritten;
621 - char str[64];
622 - switch(ts)
623 - {
624 - case D3DTSS_COLOROP:
625 - strcpy(str,"D3DTSS_COLOROP");
626 - break;
627 - case D3DTSS_COLORARG1:
628 - strcpy(str,"D3DTSS_COLORARG1");
629 - break;
630 - case D3DTSS_COLORARG2:
631 - strcpy(str,"D3DTSS_COLORARG2");
632 - break;
633 - case D3DTSS_ALPHAOP:
634 - strcpy(str,"D3DTSS_ALPHAOP");
635 - break;
636 - case D3DTSS_ALPHAARG1:
637 - strcpy(str,"D3DTSS_ALPHAARG1");
638 - break;
639 - case D3DTSS_ALPHAARG2:
640 - strcpy(str,"D3DTSS_ALPHAARG2");
641 - break;
642 - case D3DTSS_BUMPENVMAT00:
643 - strcpy(str,"D3DTSS_BUMPENVMAT00");
644 - break;
645 - case D3DTSS_BUMPENVMAT01:
646 - strcpy(str,"D3DTSS_BUMPENVMAT01");
647 - break;
648 - case D3DTSS_BUMPENVMAT10:
649 - strcpy(str,"D3DTSS_BUMPENVMAT10");
650 - break;
651 - case D3DTSS_BUMPENVMAT11:
652 - strcpy(str,"D3DTSS_BUMPENVMAT11");
653 - break;
654 - case D3DTSS_TEXCOORDINDEX:
655 - strcpy(str,"D3DTSS_TEXCOORDINDEX");
656 - break;
657 - case D3DTSS_ADDRESS:
658 - strcpy(str,"D3DTSS_ADDRESS");
659 - break;
660 - case D3DTSS_ADDRESSU:
661 - strcpy(str,"D3DTSS_ADDRESSU");
662 - break;
663 - case D3DTSS_ADDRESSV:
664 - strcpy(str,"D3DTSS_ADDRESSV");
665 - break;
666 - case D3DTSS_BORDERCOLOR:
667 - strcpy(str,"D3DTSS_BORDERCOLOR");
668 - break;
669 - case D3DTSS_MAGFILTER:
670 - strcpy(str,"D3DTSS_MAGFILTER");
671 - break;
672 - case D3DTSS_MINFILTER:
673 - strcpy(str,"D3DTSS_MINFILTER");
674 - break;
675 - case D3DTSS_MIPFILTER:
676 - strcpy(str,"D3DTSS_MIPFILTER");
677 - break;
678 - case D3DTSS_MIPMAPLODBIAS:
679 - strcpy(str,"D3DTSS_MIPMAPLODBIAS");
680 - break;
681 - case D3DTSS_MAXMIPLEVEL:
682 - strcpy(str,"D3DTSS_MAXMIPLEVEL");
683 - break;
684 - case D3DTSS_MAXANISOTROPY:
685 - strcpy(str,"D3DTSS_MAXANISOTROPY");
686 - break;
687 - case D3DTSS_BUMPENVLSCALE:
688 - strcpy(str,"D3DTSS_BUMPENVLSCALE");
689 - break;
690 - case D3DTSS_BUMPENVLOFFSET:
691 - strcpy(str,"D3DTSS_BUMPENVLOFFSET");
692 - break;
693 - case D3DTSS_TEXTURETRANSFORMFLAGS:
694 - strcpy(str,"D3DTSS_TEXTURETRANSFORMFLAGS");
695 - break;
696 - default:
697 - sprintf(str,"(D3DTEXTURESTAGESTATETYPE)%u",ts);
698 - break;
699 - }
700 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
701 -}
702 -
703 -static void trace_decode_d3dtransformstate(DWORD ts)
704 -{
705 - DWORD byteswritten;
706 - char str[64];
707 - switch(ts)
708 - {
709 - case D3DTRANSFORMSTATE_WORLD:
710 - strcpy(str,"D3DTRANSFORMSTATE_WORLD");
711 - break;
712 - case D3DTRANSFORMSTATE_VIEW:
713 - strcpy(str,"D3DTRANSFORMSTATE_VIEW");
714 - break;
715 - case D3DTRANSFORMSTATE_PROJECTION:
716 - strcpy(str,"D3DTRANSFORMSTATE_PROJECTION");
717 - break;
718 - case D3DTRANSFORMSTATE_WORLD1:
719 - strcpy(str,"D3DTRANSFORMSTATE_WORLD1");
720 - break;
721 - case D3DTRANSFORMSTATE_WORLD2:
722 - strcpy(str,"D3DTRANSFORMSTATE_WORLD2");
723 - break;
724 - case D3DTRANSFORMSTATE_WORLD3:
725 - strcpy(str,"D3DTRANSFORMSTATE_WORLD3");
726 - break;
727 - case D3DTRANSFORMSTATE_TEXTURE0:
728 - strcpy(str,"D3DTRANSFORMSTATE_TEXTURE0");
729 - break;
730 - case D3DTRANSFORMSTATE_TEXTURE1:
731 - strcpy(str,"D3DTRANSFORMSTATE_TEXTURE1");
732 - break;
733 - case D3DTRANSFORMSTATE_TEXTURE2:
734 - strcpy(str,"D3DTRANSFORMSTATE_TEXTURE2");
735 - break;
736 - case D3DTRANSFORMSTATE_TEXTURE3:
737 - strcpy(str,"D3DTRANSFORMSTATE_TEXTURE3");
738 - break;
739 - case D3DTRANSFORMSTATE_TEXTURE4:
740 - strcpy(str,"D3DTRANSFORMSTATE_TEXTURE4");
741 - break;
742 - case D3DTRANSFORMSTATE_TEXTURE5:
743 - strcpy(str,"D3DTRANSFORMSTATE_TEXTURE5");
744 - break;
745 - case D3DTRANSFORMSTATE_TEXTURE6:
746 - strcpy(str,"D3DTRANSFORMSTATE_TEXTURE6");
747 - break;
748 - case D3DTRANSFORMSTATE_TEXTURE7:
749 - strcpy(str,"D3DTRANSFORMSTATE_TEXTURE7");
750 - break;
751 - default:
752 - sprintf(str,"(D3DTRANSFORMSTATETYPE)%u",ts);
753 - break;
754 - }
755 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
756 -}
757 -
758 -static void trace_decode_d3dlightstate(DWORD ls)
759 -{
760 - DWORD byteswritten;
761 - char str[64];
762 - switch(ls)
763 - {
764 - case D3DLIGHTSTATE_MATERIAL:
765 - strcpy(str,"D3DLIGHTSTATE_MATERIAL");
766 - break;
767 - case D3DLIGHTSTATE_AMBIENT:
768 - strcpy(str,"D3DLIGHTSTATE_AMBIENT");
769 - break;
770 - case D3DLIGHTSTATE_COLORMODEL:
771 - strcpy(str,"D3DLIGHTSTATE_COLORMODEL");
772 - break;
773 - case D3DLIGHTSTATE_FOGMODE:
774 - strcpy(str,"D3DLIGHTSTATE_FOGMODE");
775 - break;
776 - case D3DLIGHTSTATE_FOGSTART:
777 - strcpy(str,"D3DLIGHTSTATE_FOGSTART");
778 - break;
779 - case D3DLIGHTSTATE_FOGEND:
780 - strcpy(str,"D3DLIGHTSTATE_FOGEND");
781 - break;
782 - case D3DLIGHTSTATE_FOGDENSITY:
783 - strcpy(str,"D3DLIGHTSTATE_FOGDENSITY");
784 - break;
785 - case D3DLIGHTSTATE_COLORVERTEX:
786 - strcpy(str,"D3DLIGHTSTATE_COLORVERTEX");
787 - break;
788 - default:
789 - sprintf(str,"(D3DTRANSFORMSTATETYPE)%u",ls);
790 - break;
791 - }
792 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
793 -}
794 -
795 -static void trace_decode_guid(GUID *guid)
796 -{
797 - DWORD byteswritten;
798 - char str[64];
799 - if(*guid == CLSID_DirectDraw) strcpy(str,"CLSID_DirectDraw");
800 - else if(*guid == CLSID_DirectDraw7) strcpy(str,"CLSID_DirectDraw7");
801 - else if(*guid == CLSID_DirectDrawClipper) strcpy(str,"CLSID_DirectDrawClipper");
802 - else if(*guid == IID_IDirectDraw) strcpy(str,"IID_IDirectDraw");
803 - else if(*guid == IID_IDirectDraw2) strcpy(str,"IID_IDirectDraw2");
804 - else if(*guid == IID_IDirectDraw4) strcpy(str,"IID_IDirectDraw4");
805 - else if(*guid == IID_IDirectDraw7) strcpy(str,"IID_IDirectDraw7");
806 - else if(*guid == IID_IDirectDrawSurface) strcpy(str,"IID_IDirectDrawSurface");
807 - else if(*guid == IID_IDirectDrawSurface2) strcpy(str,"IID_IDirectDrawSurface2");
808 - else if(*guid == IID_IDirectDrawSurface3) strcpy(str,"IID_IDirectDrawSurface3");
809 - else if(*guid == IID_IDirectDrawSurface4) strcpy(str,"IID_IDirectDrawSurface4");
810 - else if(*guid == IID_IDirectDrawSurface7) strcpy(str,"IID_IDirectDrawSurface7");
811 - else if(*guid == IID_IDirectDrawPalette) strcpy(str,"IID_IDirectDrawPalette");
812 - else if(*guid == IID_IDirectDrawClipper) strcpy(str,"IID_IDirectDrawClipper");
813 - else if(*guid == IID_IDirectDrawColorControl) strcpy(str,"IID_IDirectDrawColorControl");
814 - else if(*guid == IID_IDirectDrawGammaControl) strcpy(str,"IID_IDirectDrawGammaControl");
815 - else if(*guid == IID_IDirect3D) strcpy(str,"IID_IDirect3D");
816 - else if(*guid == IID_IDirect3D2) strcpy(str,"IID_IDirect3D2");
817 - else if(*guid == IID_IDirect3D3) strcpy(str,"IID_IDirect3D3");
818 - else if(*guid == IID_IDirect3D7) strcpy(str,"IID_IDirect3D7");
819 - else
820 - {
821 - OLECHAR guidstr[41] = {0};
822 - StringFromGUID2(*guid,guidstr,40);
823 - WideCharToMultiByte(CP_UTF8,0,guidstr,-1,str,64,NULL,NULL);
824 - }
825 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
826 -}
827 -static void trace_decode_size(SIZE *size)
828 -{
829 - DWORD byteswritten;
830 - char str[64];
831 - sprintf(str,"{%d,%d}",size->cx,size->cy);
832 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
833 -}
834 -static void trace_decode_rect(RECT *rect)
835 -{
836 - DWORD byteswritten;
837 - char str[64];
838 - sprintf(str,"{%d,%d,%d,%d}",rect->left,rect->top,rect->right,rect->bottom);
839 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
840 -}
841 -static void init_trace()
842 -{
843 - TCHAR path[MAX_PATH+1];
844 - InitializeCriticalSection(&trace_cs);
845 - GetModuleFileName(NULL,path,MAX_PATH);
846 - TCHAR *path_truncate = _tcsrchr(path,_T('\\'));
847 - if(path_truncate) *(path_truncate+1) = 0;
848 - _tcscat(path,_T("dxgl.log"));
849 - outfile = CreateFile(path,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
850 - if(outfile == INVALID_HANDLE_VALUE)
851 - {
852 - trace_fail = true;
853 - return;
854 - }
855 - trace_ready = true;
856 -}
857 -static void trace_decode_arg(int type, void *arg)
858 -{
859 - DWORD byteswritten;
860 - char str[128];
861 - char *mbcsbuffer;
862 - int buffersize;
863 - str[0] = 0;
864 - switch(type)
865 - {
866 - case -1: // C++ constructor/destructor
867 - // No return type in a constructor or destructor.
868 - break;
869 - case 0: // void
870 - WriteFile(outfile,"void",4,&byteswritten,NULL);
871 - break;
872 - case 1: // 8-bit signed
873 - sprintf(str,"%d",(signed char)arg);
874 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
875 - break;
876 - case 2: // 8-bit unsigned
877 - sprintf(str,"%u",(unsigned char)arg);
878 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
879 - break;
880 - case 3: // 8-bit hex
881 - sprintf(str,"0x%02X",(unsigned char)arg);
882 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
883 - break;
884 - case 4: // 16-bit signed
885 - sprintf(str,"%d",(signed short)arg);
886 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
887 - break;
888 - case 5: // 16-bit unsigned
889 - sprintf(str,"%u",(unsigned short)arg);
890 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
891 - break;
892 - case 6: // 16-bit hex
893 - sprintf(str,"0x%04X",(unsigned short)arg);
894 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
895 - break;
896 - case 7: // 32-bit signed
897 - sprintf(str,"%d",(signed long)arg);
898 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
899 - break;
900 - case 8: // 32-bit unsigned
901 - sprintf(str,"%u",(unsigned long)arg);
902 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
903 - break;
904 - case 9: // 32-bit hex
905 - sprintf(str,"0x%08X",(unsigned long)arg);
906 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
907 - break;
908 - case 10: // pointer to 64-bit hex
909 - sprintf(str,"0x%016I64X",(unsigned __int64)*(unsigned __int64*)arg);
910 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
911 - break;
912 - case 11: // native signed
913 - sprintf(str,"%d",(signed int)arg);
914 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
915 - break;
916 - case 12: // native unsigned
917 - sprintf(str,"%u",(unsigned int)arg);
918 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
919 - break;
920 - case 13: // native hex
921 - sprintf(str,"0x%08X",(unsigned int)arg);
922 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
923 - break;
924 - case 14: // generic pointer
925 - if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
926 - else
927 - {
928 -#ifdef _M_X64
929 - sprintf(str,"0x%016I64X",arg);
930 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
931 -#else
932 - sprintf(str,"0x%08X",arg);
933 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
934 -#endif
935 - }
936 - break;
937 - case 15: // ASCII string
938 - if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
939 - else
940 - {
941 - WriteFile(outfile,"\"",1,&byteswritten,NULL);
942 - WriteFile(outfile,arg,strlen((char*)arg),&byteswritten,NULL);
943 - WriteFile(outfile,"\"",1,&byteswritten,NULL);
944 - }
945 - break;
946 - case 16: // Unicode string
947 - if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
948 - else
949 - {
950 - WriteFile(outfile,"L\"",1,&byteswritten,NULL);
951 - buffersize = WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,NULL,0,NULL,NULL);
952 - mbcsbuffer = (char*)malloc(buffersize);
953 - if(!mbcsbuffer) WriteFile(outfile,"OUT OF MEMORY",13,&byteswritten,NULL);
954 - else
955 - {
956 - WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,mbcsbuffer,buffersize,NULL,NULL);
957 - WriteFile(outfile,mbcsbuffer,strlen(mbcsbuffer),&byteswritten,NULL);
958 - free(mbcsbuffer);
959 - }
960 - WriteFile(outfile,"\"",1,&byteswritten,NULL);
961 - }
962 - break;
963 - case 17: // TCHAR string
964 - if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
965 -#ifdef _UNICODE
966 - else
967 - {
968 - WriteFile(outfile,"_T(\"",1,&byteswritten,NULL);
969 - buffersize = WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,NULL,0,NULL,NULL);
970 - mbcsbuffer = (char*)malloc(buffersize);
971 - if(!mbcsbuffer) WriteFile(outfile,"OUT OF MEMORY",13,&byteswritten,NULL);
972 - else
973 - {
974 - WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,mbcsbuffer,buffersize,NULL,NULL);
975 - WriteFile(outfile,mbcsbuffer,strlen(mbcsbuffer),&byteswritten,NULL);
976 - free(mbcsbuffer);
977 - }
978 - WriteFile(outfile,"\")",1,&byteswritten,NULL);
979 - }
980 -#else
981 - else
982 - {
983 - WriteFile(outfile,"_T(\"",1,&byteswritten,NULL);
984 - WriteFile(outfile,arg,strlen((char*)arg),&byteswritten,NULL);
985 - WriteFile(outfile,"\")",1,&byteswritten,NULL);
986 - }
987 -#endif
988 - break;
989 - case 18: // ASCII character
990 - if(!(unsigned char)arg) WriteFile(outfile,"\'\\0\'",4,&byteswritten,NULL);
991 - else
992 - {
993 - str[0] = str[2] = '\'';
994 - str[1] = (unsigned char)arg;
995 - str[3] = NULL;
996 - WriteFile(outfile,str,3,&byteswritten,NULL);
997 - }
998 - break;
999 - case 19: // pointer to 32 bit float
1000 - sprintf(str,"%f",arg);
1001 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
1002 - break;
1003 - case 20: // pointer to 64 bit float
1004 - sprintf(str,"%lf",arg);
1005 - WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
1006 - break;
1007 - case 21: // c++ bool
1008 - if((bool)arg) WriteFile(outfile,"true",4,&byteswritten,NULL);
1009 - else WriteFile(outfile,"false",5,&byteswritten,NULL);
1010 - break;
1011 - case 22: // c++ bool
1012 - if(arg) WriteFile(outfile,"TRUE",4,&byteswritten,NULL);
1013 - else WriteFile(outfile,"FALSE",5,&byteswritten,NULL);
1014 - break;
1015 - case 23: // HRESULT
1016 - trace_decode_hresult((HRESULT)arg);
1017 - break;
1018 - case 24: // GUID pointer
1019 - if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
1020 - else if(arg == (void*)DDCREATE_HARDWAREONLY) WriteFile(outfile,"DDCREATE_HARDWAREONLY",21,&byteswritten,NULL);
1021 - else if(arg == (void*)DDCREATE_EMULATIONONLY) WriteFile(outfile,"DDCREATE_EMULATIONONLY",22,&byteswritten,NULL);
1022 - else trace_decode_guid((GUID*)arg);
1023 - break;
1024 - case 25: // SIZE or POINT pointer
1025 - if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
1026 - else trace_decode_size((SIZE*)arg);
1027 - break;
1028 - case 26: // RECT pointer
1029 - if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
1030 - else trace_decode_rect((RECT*)arg);
1031 - break;
1032 - case 27: // D3DRENDERSTATETYPE
1033 - trace_decode_d3drenderstate((DWORD)arg);
1034 - break;
1035 - case 28: // D3DTEXTURESTAGESTATETYPE
1036 - trace_decode_d3dtexturestagestate((DWORD)arg);
1037 - break;
1038 - case 29: // D3DTRANSFORMSTATETYPE
1039 - trace_decode_d3dtransformstate((DWORD)arg);
1040 - break;
1041 - case 30: // D3DLIGHTSTATETYPE
1042 - trace_decode_d3dlightstate((DWORD)arg);
1043 - break;
1044 - default:
1045 - WriteFile(outfile,"Unknown type",12,&byteswritten,NULL);
1046 - break;
1047 - }
1048 -}
1049 -static void end_trace()
1050 -{
1051 - DWORD byteswritten;
1052 - WriteFile(outfile,"Trace cancelled by CTRL+Break\r\n",31,&byteswritten,NULL);
1053 - CloseHandle(outfile);
1054 - outfile = INVALID_HANDLE_VALUE;
1055 - trace_fail = true;
1056 -}
1057 -void trace_enter(const char *function, int paramcount, ...)
1058 -{
1059 - if(trace_fail) return;
1060 - if(!trace_ready) init_trace();
1061 - EnterCriticalSection(&trace_cs);
1062 - if(trace_end)
1063 - {
1064 - end_trace();
1065 - LeaveCriticalSection(&trace_cs);
1066 - return;
1067 - }
1068 - va_list args;
1069 - va_start(args,paramcount);
1070 - DWORD byteswritten;
1071 - for(unsigned int i = 0; i < trace_depth; i++)
1072 - WriteFile(outfile," ",4,&byteswritten,NULL);
1073 - WriteFile(outfile,function,strlen(function),&byteswritten,NULL);
1074 - WriteFile(outfile,"(",1,&byteswritten,NULL);
1075 - for(int i = 0; i < paramcount; i++)
1076 - {
1077 - if(i != 0) WriteFile(outfile,", ",2,&byteswritten,NULL);
1078 - int argtype = va_arg(args,int);
1079 - trace_decode_arg(argtype,va_arg(args,void*));
1080 - }
1081 - WriteFile(outfile,");\r\n",4,&byteswritten,NULL);
1082 - trace_depth++;
1083 - LeaveCriticalSection(&trace_cs);
1084 -}
1085 -void trace_exit(const char *function, int argtype, void *arg)
1086 -{
1087 - if(trace_fail) return;
1088 - if(!trace_ready) init_trace();
1089 - EnterCriticalSection(&trace_cs);
1090 - if(trace_end)
1091 - {
1092 - end_trace();
1093 - LeaveCriticalSection(&trace_cs);
1094 - return;
1095 - }
1096 - if(trace_depth) trace_depth--;
1097 - DWORD byteswritten;
1098 - for(unsigned int i = 0; i < trace_depth; i++)
1099 - WriteFile(outfile," ",4,&byteswritten,NULL);
1100 - WriteFile(outfile,function,strlen(function),&byteswritten,NULL);
1101 - WriteFile(outfile," returned ",10,&byteswritten,NULL);
1102 - trace_decode_arg(argtype,arg);
1103 - WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
1104 - LeaveCriticalSection(&trace_cs);
1105 -}
1106 -void *trace_ret(const char *function, int argtype, void *arg)
1107 -{
1108 - trace_exit(function,argtype,arg);
1109 - return arg;
1110 -}
1111 -void trace_var(const char *function, const char *var, int argtype, void *arg)
1112 -{
1113 - if(trace_fail) return;
1114 - if(!trace_ready) init_trace();
1115 - EnterCriticalSection(&trace_cs);
1116 - if(trace_end)
1117 - {
1118 - end_trace();
1119 - LeaveCriticalSection(&trace_cs);
1120 - return;
1121 - }
1122 - DWORD byteswritten;
1123 - for(unsigned int i = 0; i < trace_depth-1; i++)
1124 - WriteFile(outfile," ",4,&byteswritten,NULL);
1125 - WriteFile(outfile,function,strlen(function),&byteswritten,NULL);
1126 - WriteFile(outfile,": ",2,&byteswritten,NULL);
1127 - WriteFile(outfile,var,strlen(var),&byteswritten,NULL);
1128 - WriteFile(outfile," set to ",8,&byteswritten,NULL);
1129 - trace_decode_arg(argtype,arg);
1130 - WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
1131 - LeaveCriticalSection(&trace_cs);
1132 -}
1133 -
1134 -void trace_sysinfo()
1135 -{
1136 - if(trace_fail) return;
1137 - if(!trace_ready) init_trace();
1138 - EnterCriticalSection(&trace_cs);
1139 - if(trace_end)
1140 - {
1141 - end_trace();
1142 - LeaveCriticalSection(&trace_cs);
1143 - return;
1144 - }
1145 - DWORD byteswritten;
1146 - OSVERSIONINFOA osver;
1147 - DWORD buildver;
1148 - char osstring[256];
1149 - osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
1150 - GetVersionExA(&osver);
1151 - if(osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) buildver = LOWORD(osver.dwBuildNumber);
1152 - else buildver = osver.dwBuildNumber;
1153 - if((osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) || (osver.dwPlatformId == VER_PLATFORM_WIN32s))
1154 - sprintf(osstring,"Windows %u.%u.%u",osver.dwMajorVersion,osver.dwMinorVersion,buildver);
1155 - else sprintf(osstring,"Windows NT %u.%u.%u",osver.dwMajorVersion,osver.dwMinorVersion,buildver);
1156 - if(osver.szCSDVersion[0])
1157 - {
1158 - strcat(osstring,", ");
1159 - strcat(osstring,osver.szCSDVersion);
1160 - }
1161 - if(((osver.dwMajorVersion == 5) && (osver.dwMinorVersion >= 1)) || (osver.dwMajorVersion >= 6))
1162 - {
1163 - strcat(osstring,", ");
1164 - HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
1165 - BOOL (WINAPI *iswow64)(HANDLE,PBOOL) = NULL;
1166 - if(hKernel32) iswow64 = (BOOL(WINAPI*)(HANDLE,PBOOL))GetProcAddress(hKernel32,"IsWow64Process");
1167 - BOOL is64 = FALSE;
1168 - if(iswow64) iswow64(GetCurrentProcess(),&is64);
1169 - if(hKernel32) FreeLibrary(hKernel32);
1170 - if(is64) strcat(osstring,"64-bit");
1171 - else strcat(osstring,"32-bit");
1172 - }
1173 - strcat(osstring,"\r\n");
1174 - for(unsigned int i = 0; i < trace_depth-1; i++)
1175 - WriteFile(outfile," ",4,&byteswritten,NULL);
1176 - WriteFile(outfile,"Windows version: ",18,&byteswritten,NULL);
1177 - WriteFile(outfile,osstring,strlen(osstring),&byteswritten,NULL);
1178 - for(unsigned int i = 0; i < trace_depth-1; i++)
1179 - WriteFile(outfile," ",4,&byteswritten,NULL);
1180 - WriteFile(outfile,"GL_VENDOR: ",12,&byteswritten,NULL);
1181 - const GLubyte *glstring;
1182 - glstring = glGetString(GL_VENDOR);
1183 - if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
1184 - WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
1185 - for(unsigned int i = 0; i < trace_depth-1; i++)
1186 - WriteFile(outfile," ",4,&byteswritten,NULL);
1187 - WriteFile(outfile,"GL_RENDERER: ",14,&byteswritten,NULL);
1188 - glstring = glGetString(GL_RENDERER);
1189 - if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
1190 - WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
1191 - for(unsigned int i = 0; i < trace_depth-1; i++)
1192 - WriteFile(outfile," ",4,&byteswritten,NULL);
1193 - WriteFile(outfile,"GL_VERSION: ",13,&byteswritten,NULL);
1194 - glstring = glGetString(GL_VERSION);
1195 - if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
1196 - WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
1197 - for(unsigned int i = 0; i < trace_depth-1; i++)
1198 - WriteFile(outfile," ",4,&byteswritten,NULL);
1199 - WriteFile(outfile,"GL_SHADING_LANGUAGE_VERSION: ",30,&byteswritten,NULL);
1200 - glstring = glGetString(GL_SHADING_LANGUAGE_VERSION);
1201 - if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
1202 - WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
1203 - for(unsigned int i = 0; i < trace_depth-1; i++)
1204 - WriteFile(outfile," ",4,&byteswritten,NULL);
1205 - WriteFile(outfile,"GL_EXTENSIONS: ",16,&byteswritten,NULL);
1206 - glstring = glGetString(GL_EXTENSIONS);
1207 - if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
1208 - WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
1209 - LeaveCriticalSection(&trace_cs);
1210 -}
1211 -#endif
\ No newline at end of file
Index: ddraw/common.h
@@ -31,10 +31,17 @@
3232 #include "include/GL/glext.h"
3333 #include "include/GL/wglext.h"
3434 #include "glExtensions.h"
 35+#ifdef __cplusplus
3536 #include "ShaderManager.h"
 37+#endif
3638
3739 extern const GUID device_template;
3840
 41+#ifdef _MSC_VER
 42+#define INLINE __inline
 43+#else
 44+#define INLINE __inline__
 45+#endif
3946
4047 #ifdef _DEBUG
4148 #define DEBUGBREAK DebugBreak();
@@ -79,10 +86,10 @@
8087 #define ERR(error) return error;
8188 #endif
8289
83 -static inline int NextMultipleOf8(int number){return ((number+7) & (~7));}
84 -static inline int NextMultipleOf4(int number){return ((number+3) & (~3));}
85 -static inline int NextMultipleOf2(int number){return ((number+1) & (~1));}
86 -static inline void dwordto4float(DWORD in, GLfloat *out)
 90+static INLINE int NextMultipleOf8(int number){return ((number+7) & (~7));}
 91+static INLINE int NextMultipleOf4(int number){return ((number+3) & (~3));}
 92+static INLINE int NextMultipleOf2(int number){return ((number+1) & (~1));}
 93+static INLINE void dwordto4float(DWORD in, GLfloat *out)
8794 {
8895 out[0] = (GLfloat)((in>>16) & 0xff) / 255.0f;
8996 out[1] = (GLfloat)((in>>8) & 0xff) / 255.0f;
@@ -90,7 +97,7 @@
9198 out[3] = (GLfloat)((in>>24) & 0xff) / 255.0f;
9299 }
93100
94 -static inline void dwordto4int(DWORD in, GLint *out)
 101+static INLINE void dwordto4int(DWORD in, GLint *out)
95102 {
96103 out[0] = (GLint)((in>>16) & 0xff);
97104 out[1] = (GLint)((in>>8) & 0xff);
@@ -107,6 +114,7 @@
108115 extern CRITICAL_SECTION dll_cs;
109116
110117 #include "trace.h"
111 -
 118+#ifdef __cplusplus
112119 #include "../cfgmgr/cfgmgr.h"
 120+#endif
113121 #endif //_COMMON_H
Index: ddraw/ddraw.vcxproj
@@ -345,7 +345,9 @@
346346 <ClCompile Include="glDirectDrawClipper.cpp" />
347347 <ClCompile Include="glDirectDrawPalette.cpp" />
348348 <ClCompile Include="glDirectDrawSurface.cpp" />
349 - <ClCompile Include="glExtensions.cpp" />
 349+ <ClCompile Include="glExtensions.c">
 350+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">NotUsing</PrecompiledHeader>
 351+ </ClCompile>
350352 <ClCompile Include="glRenderer.cpp" />
351353 <ClCompile Include="glRenderWindow.cpp" />
352354 <ClCompile Include="glUtil.cpp" />
@@ -364,7 +366,9 @@
365367 <ClCompile Include="ShaderManager.cpp" />
366368 <ClCompile Include="TextureManager.cpp" />
367369 <ClCompile Include="timer.cpp" />
368 - <ClCompile Include="trace.cpp" />
 370+ <ClCompile Include="trace.c">
 371+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">NotUsing</PrecompiledHeader>
 372+ </ClCompile>
369373 <ClCompile Include="util.cpp" />
370374 </ItemGroup>
371375 <ItemGroup>
Index: ddraw/ddraw.vcxproj.filters
@@ -157,9 +157,6 @@
158158 <ClCompile Include="glDirectDrawPalette.cpp">
159159 <Filter>Source Files</Filter>
160160 </ClCompile>
161 - <ClCompile Include="glExtensions.cpp">
162 - <Filter>Source Files</Filter>
163 - </ClCompile>
164161 <ClCompile Include="precomp.cpp">
165162 <Filter>Source Files</Filter>
166163 </ClCompile>
@@ -205,9 +202,6 @@
206203 <ClCompile Include="glDirect3DExecuteBuffer.cpp">
207204 <Filter>Source Files</Filter>
208205 </ClCompile>
209 - <ClCompile Include="trace.cpp">
210 - <Filter>Source Files</Filter>
211 - </ClCompile>
212206 <ClCompile Include="util.cpp">
213207 <Filter>Source Files</Filter>
214208 </ClCompile>
@@ -229,6 +223,12 @@
230224 <ClCompile Include="ShaderGen3D.cpp">
231225 <Filter>Source Files</Filter>
232226 </ClCompile>
 227+ <ClCompile Include="glExtensions.c">
 228+ <Filter>Source Files</Filter>
 229+ </ClCompile>
 230+ <ClCompile Include="trace.c">
 231+ <Filter>Source Files</Filter>
 232+ </ClCompile>
233233 </ItemGroup>
234234 <ItemGroup>
235235 <ResourceCompile Include="ddraw.rc">
Index: ddraw/glExtensions.c
@@ -0,0 +1,172 @@
 2+// DXGL
 3+// Copyright (C) 2011-2014 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#include "common.h"
 20+#include "glExtensions.h"
 21+
 22+
 23+void glExtensions_Init(glExtensions *ext)
 24+{
 25+ const GLubyte *glversion;
 26+ const GLubyte *glextensions;
 27+ BOOL broken_fbo;
 28+ ZeroMemory(ext, sizeof(glExtensions));
 29+ ext->atimem = FALSE;
 30+ glversion = glGetString(GL_VERSION);
 31+ ext->glver_minor = 0;
 32+ if(!sscanf((char*)glversion,"%d.%d",&ext->glver_major,&ext->glver_minor)) ext->glver_major = 0;
 33+ if((ext->glver_major >= 2) || ((ext->glver_major >= 1) && (ext->glver_minor >= 2)))
 34+ ext->glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)wglGetProcAddress("glDrawRangeElements");
 35+ if((ext->glver_major >= 2) || ((ext->glver_major >= 1) && (ext->glver_minor >= 3)))
 36+ {
 37+ ext->glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTexture");
 38+ ext->glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)wglGetProcAddress("glClientActiveTexture");
 39+ }
 40+ if((ext->glver_major >= 2) || ((ext->glver_major >= 1) && (ext->glver_minor >= 5)))
 41+ {
 42+ ext->glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers");
 43+ ext->glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers");
 44+ ext->glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
 45+ ext->glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");
 46+ ext->glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer");
 47+ ext->glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer");
 48+ }
 49+ if(ext->glver_major >= 2)
 50+ {
 51+ ext->glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
 52+ ext->glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource");
 53+ ext->glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
 54+ ext->glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader");
 55+ ext->glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
 56+ ext->glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram");
 57+ ext->glGetProgramiv = (PFNGLGETPROGRAMIVPROC)wglGetProcAddress("glGetProgramiv");
 58+ ext->glAttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader");
 59+ ext->glDetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader");
 60+ ext->glLinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram");
 61+ ext->glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
 62+ ext->glGetShaderiv = (PFNGLGETSHADERIVPROC)wglGetProcAddress("glGetShaderiv");
 63+ ext->glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog");
 64+ ext->glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog");
 65+ ext->glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation");
 66+ ext->glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i");
 67+ ext->glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i");
 68+ ext->glUniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i");
 69+ ext->glUniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i");
 70+ ext->glUniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv");
 71+ ext->glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f");
 72+ ext->glUniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f");
 73+ ext->glUniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f");
 74+ ext->glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
 75+ ext->glUniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv");
 76+ ext->glUniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv");
 77+ ext->glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv");
 78+ ext->glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv");
 79+ ext->glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation");
 80+ ext->glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
 81+ ext->glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
 82+ ext->glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray");
 83+ }
 84+ else
 85+ {
 86+ MessageBox(NULL,_T("DXGL requires an OpenGL 2.0 or higher compatible graphics card to function. \
 87+Please contact your graphics card manufacturer for an updated driver. This program will now exit."),_T("Fatal error"),
 88+ MB_OK|MB_ICONERROR);
 89+ ExitProcess(-1);
 90+ }
 91+ glextensions = glGetString(GL_EXTENSIONS);
 92+ if(strstr((char*)glextensions,"GL_ARB_framebuffer_object") || (ext->glver_major >= 3)) ext->GLEXT_ARB_framebuffer_object = 1;
 93+ else ext->GLEXT_ARB_framebuffer_object = 0;
 94+ if(strstr((char*)glextensions,"GL_EXT_framebuffer_object")) ext->GLEXT_EXT_framebuffer_object = 1;
 95+ else ext->GLEXT_EXT_framebuffer_object = 0;
 96+ if(strstr((char*)glextensions,"GL_NV_packed_depth_stencil")) ext->GLEXT_NV_packed_depth_stencil = 1;
 97+ else ext->GLEXT_NV_packed_depth_stencil = 0;
 98+ if(strstr((char*)glextensions,"GL_EXT_packed_depth_stencil")) ext->GLEXT_EXT_packed_depth_stencil = 1;
 99+ else ext->GLEXT_EXT_packed_depth_stencil = 0;
 100+ if(strstr((char*)glextensions,"GL_ARB_depth_buffer_float") || (ext->glver_major >= 3)) ext->GLEXT_ARB_depth_buffer_float = 1;
 101+ else ext->GLEXT_ARB_depth_buffer_float = 0;
 102+ if(strstr((char*)glextensions,"GL_ARB_depth_texture") || (ext->glver_major >= 2)
 103+ || ((ext->glver_major >= 1) && (ext->glver_minor >= 4))) ext->GLEXT_ARB_depth_texture = 1;
 104+ else ext->GLEXT_ARB_depth_texture = 0;
 105+ if(strstr((char*)glextensions,"GL_NVX_gpu_memory_info")) ext->GLEXT_NVX_gpu_memory_info = 1;
 106+ else ext->GLEXT_NVX_gpu_memory_info = 0;
 107+ if(strstr((char*)glextensions,"GL_ATI_meminfo")) ext->GLEXT_ATI_meminfo = 1;
 108+ else ext->GLEXT_ATI_meminfo = 0;
 109+ if(strstr((char*)glextensions,"GL_ARB_ES2_compatibility") || (ext->glver_major >= 5)
 110+ || ((ext->glver_major >= 4) && (ext->glver_minor >= 1))) ext->GLEXT_ARB_ES2_compatibility = 1;
 111+ else ext->GLEXT_ARB_ES2_compatibility = 0;
 112+ if(strstr((char*)glextensions,"GL_EXT_direct_state_access")) ext->GLEXT_EXT_direct_state_access = 1;
 113+ else ext->GLEXT_EXT_direct_state_access = 0;
 114+ if(strstr((char*)glextensions,"GL_ARB_sampler_objects") || (ext->glver_major >= 4)
 115+ || ((ext->glver_major >= 3) && (ext->glver_minor >= 3))) ext->GLEXT_ARB_sampler_objects = 1;
 116+ else ext->GLEXT_ARB_sampler_objects = 0;
 117+ broken_fbo = TRUE;
 118+ if(ext->GLEXT_ARB_framebuffer_object)
 119+ {
 120+ ext->glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers");
 121+ if(!ext->glGenFramebuffers) ext->GLEXT_ARB_framebuffer_object = 0;
 122+ ext->glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer");
 123+ ext->glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers");
 124+ ext->glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer");
 125+ ext->glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D");
 126+ ext->glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress("glCheckFramebufferStatus");
 127+ ext->glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers");
 128+ broken_fbo = FALSE;
 129+ }
 130+ if(ext->GLEXT_EXT_framebuffer_object)
 131+ {
 132+ ext->glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)wglGetProcAddress("glGenFramebuffersEXT");
 133+ if(!ext->glGenFramebuffersEXT) ext->GLEXT_EXT_framebuffer_object = 0;
 134+ ext->glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)wglGetProcAddress("glBindFramebufferEXT");
 135+ ext->glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)wglGetProcAddress("glGenRenderbuffersEXT");
 136+ ext->glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)wglGetProcAddress("glBindRenderbufferEXT");
 137+ ext->glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)wglGetProcAddress("glFramebufferTexture2DEXT");
 138+ ext->glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress("glCheckFramebufferStatusEXT");
 139+ ext->glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)wglGetProcAddress("glDeleteFramebuffersEXT");
 140+ broken_fbo = FALSE;
 141+ }
 142+ if(ext->GLEXT_EXT_direct_state_access)
 143+ {
 144+ ext->glTextureParameterfEXT = (PFNGLTEXTUREPARAMETERFEXTPROC)wglGetProcAddress("glTextureParameterfEXT");
 145+ ext->glTextureParameterfvEXT = (PFNGLTEXTUREPARAMETERFVEXTPROC)wglGetProcAddress("glTextureParameterfvEXT");
 146+ ext->glTextureParameteriEXT = (PFNGLTEXTUREPARAMETERIEXTPROC)wglGetProcAddress("glTextureParameteriEXT");
 147+ ext->glTextureParameterivEXT = (PFNGLTEXTUREPARAMETERIVEXTPROC)wglGetProcAddress("glTextureParameterivEXT");
 148+ ext->glTextureImage2DEXT = (PFNGLTEXTUREIMAGE2DEXTPROC)wglGetProcAddress("glTextureImage2DEXT");
 149+ ext->glTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)wglGetProcAddress("glTextureSubImage2DEXT");
 150+ ext->glGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)wglGetProcAddress("glGetTextureImageEXT");
 151+ ext->glMatrixLoadfEXT = (PFNGLMATRIXLOADFEXTPROC)wglGetProcAddress("glMatrixLoadfEXT");
 152+ ext->glMatrixMultfEXT = (PFNGLMATRIXMULTFEXTPROC)wglGetProcAddress("glMatrixMultfEXT");
 153+ }
 154+ if(ext->GLEXT_ARB_sampler_objects)
 155+ {
 156+ ext->glBindSampler = (PFNGLBINDSAMPLERPROC)wglGetProcAddress("glBindSampler");
 157+ ext->glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)wglGetProcAddress("glDeleteSamplers");
 158+ ext->glGenSamplers = (PFNGLGENSAMPLERSPROC)wglGetProcAddress("glGenSamplers");
 159+ ext->glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)wglGetProcAddress("glSamplerParameterf");
 160+ ext->glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)wglGetProcAddress("glSamplerParameteri");
 161+ ext->glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)wglGetProcAddress("glSamplerParameterfv");
 162+ ext->glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)wglGetProcAddress("glSamplerParameteriv");
 163+ }
 164+ if(broken_fbo)
 165+ {
 166+ MessageBox(NULL,_T("DXGL requires support for OpenGL Framebuffer Objects to function. \
 167+Please contact your graphics card manufacturer for an updated driver. This program will now exit."),_T("Fatal error"),
 168+ MB_OK|MB_ICONERROR);
 169+ ExitProcess(-1);
 170+ }
 171+ ext->wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
 172+ ext->wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT");
 173+}
Index: ddraw/glExtensions.h
@@ -30,9 +30,12 @@
3131 #define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
3232 #define GL_RGB565 0x8D62
3333
34 -class glExtensions
 34+#ifdef __cplusplus
 35+extern "C" {
 36+#endif
 37+
 38+typedef struct
3539 {
36 -public:
3740 GLuint(APIENTRY *glCreateShader) (GLenum type);
3841 void (APIENTRY *glShaderSource) (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
3942 void (APIENTRY *glCompileShader) (GLuint shader);
@@ -132,13 +135,13 @@
133136 int GLEXT_ARB_sampler_objects;
134137 int glver_major;
135138 int glver_minor;
 139+ BOOL atimem;
 140+} glExtensions;
136141
137 - glExtensions();
 142+void glExtensions_Init(glExtensions *ext);
138143
139 -private:
140 - bool atimem;
 144+#ifdef __cplusplus
 145+}
 146+#endif
141147
142 -};
143 -
144 -
145148 #endif //_GLEXTENSIONS_H
Index: ddraw/glRenderWindow.cpp
@@ -200,7 +200,7 @@
201201 #ifdef _DEBUG
202202 case WM_HOTKEY:
203203 #ifdef _TRACE
204 - trace_end = true;
 204+ trace_end = TRUE;
205205 CreateThread(NULL,0,BeepThread,NULL,0,NULL);
206206 UnregisterHotKey(hWnd,1);
207207 hotkeyregistered = false;
Index: ddraw/glRenderer.cpp
@@ -656,7 +656,7 @@
657657 }
658658 delete shaders;
659659 delete texman;
660 - delete ext;
 660+ free(ext);
661661 delete util;
662662 ext = NULL;
663663 wglMakeCurrent(NULL,NULL);
@@ -794,7 +794,8 @@
795795 }
796796 InterlockedDecrement(&gllock);
797797 LeaveCriticalSection(&dll_cs);
798 - ext = new glExtensions();
 798+ ext = (glExtensions *)malloc(sizeof(glExtensions));
 799+ glExtensions_Init(ext);
799800 util = new glUtil(ext);
800801 _SetSwap(1);
801802 SwapBuffers(hDC);
Index: ddraw/trace.c
@@ -0,0 +1,1219 @@
 2+// DXGL
 3+// Copyright (C) 2013 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#include "common.h"
 20+#include "trace.h"
 21+
 22+/* Data types:
 23+-1 - C++ constructor/destructor
 24+0 - void
 25+1 - 8-bit signed
 26+2 - 8-bit unsigned
 27+3 - 8-bit hex
 28+4 - 16 bit signed
 29+5 - 16 bit unsigned
 30+6 - 16 bit hex
 31+7 - 32 bit signed
 32+8 - 32 bit unsigned
 33+9 - 32 bit hex
 34+10 - pointer to 64 bit hex
 35+11 - native signed
 36+12 - native unsigned
 37+13 - native hex
 38+14 - generic pointer
 39+15 - ASCII string
 40+16 - Unicode string
 41+17 - TCHAR string
 42+18 - ASCII character
 43+19 - pointer to 32 bit float
 44+20 - pointer to 64 bit float
 45+21 - c++ bool
 46+22 - int BOOL
 47+23 - HRESULT
 48+24 - GUID pointer
 49+25 - SIZE or POINT pointer
 50+26 - RECT pointer
 51+27 - D3DRENDERSTATETYPE
 52+28 - D3DTEXTURESTAGESTATETYPE
 53+29 - D3DTRANSFORMSTATETYPE
 54+30 - D3DLIGHTSTATETYPE
 55+*/
 56+
 57+#ifdef _TRACE
 58+static CRITICAL_SECTION trace_cs;
 59+static BOOL trace_ready = FALSE;
 60+static BOOL trace_fail = FALSE;
 61+BOOL trace_end = FALSE;
 62+static HANDLE outfile = INVALID_HANDLE_VALUE;
 63+unsigned int trace_depth = 0;
 64+static void trace_decode_hresult(HRESULT hr)
 65+{
 66+ DWORD byteswritten;
 67+ char str[64];
 68+ switch(hr)
 69+ {
 70+ case DD_OK:
 71+ strcpy(str,"DD_OK");
 72+ break;
 73+ case DD_FALSE:
 74+ strcpy(str,"DD_FALSE");
 75+ break;
 76+ case DDERR_ALREADYINITIALIZED:
 77+ strcpy(str,"DDERR_ALREADYINITIALIZED");
 78+ break;
 79+ case DDERR_CANNOTATTACHSURFACE:
 80+ strcpy(str,"DDERR_CANNOTATTACHSURFACE");
 81+ break;
 82+ case DDERR_CANNOTDETACHSURFACE:
 83+ strcpy(str,"DDERR_CANNOTDETACHSURFACE");
 84+ break;
 85+ case DDERR_CURRENTLYNOTAVAIL:
 86+ strcpy(str,"DDERR_CURRENTLYNOTAVAIL");
 87+ break;
 88+ case DDERR_EXCEPTION:
 89+ strcpy(str,"DDERR_EXCEPTION");
 90+ break;
 91+ case DDERR_GENERIC:
 92+ strcpy(str,"DDERR_GENERIC");
 93+ break;
 94+ case DDERR_INCOMPATIBLEPRIMARY:
 95+ strcpy(str,"DDERR_INCOMPATIBLEPRIMARY");
 96+ break;
 97+ case DDERR_INVALIDCAPS:
 98+ strcpy(str,"DDERR_INVALIDCAPS");
 99+ break;
 100+ case DDERR_INVALIDCLIPLIST:
 101+ strcpy(str,"DDERR_INVALIDCLIPLIST");
 102+ break;
 103+ case DDERR_INVALIDMODE:
 104+ strcpy(str,"DDERR_INVALIDMODE");
 105+ break;
 106+ case DDERR_INVALIDPARAMS:
 107+ strcpy(str,"DDERR_INVALIDPARAMS");
 108+ break;
 109+ case DDERR_INVALIDPIXELFORMAT:
 110+ strcpy(str,"DDERR_INVALIDPIXELFORMAT");
 111+ break;
 112+ case DDERR_INVALIDRECT:
 113+ strcpy(str,"DDERR_INVALIDRECT");
 114+ break;
 115+ case DDERR_NOTFOUND:
 116+ strcpy(str,"DDERR_NOTFOUND");
 117+ break;
 118+ case DDERR_OUTOFMEMORY:
 119+ strcpy(str,"DDERR_OUTOFMEMORY");
 120+ break;
 121+ case DDERR_OUTOFVIDEOMEMORY:
 122+ strcpy(str,"DDERR_OUTOFVIDEOMEMORY");
 123+ break;
 124+ case DDERR_SURFACEALREADYATTACHED:
 125+ strcpy(str,"DDERR_SURFACEALREADYATTACHED");
 126+ break;
 127+ case DDERR_SURFACEBUSY:
 128+ strcpy(str,"DDERR_SURFACEBUSY");
 129+ break;
 130+ case DDERR_CANTLOCKSURFACE:
 131+ strcpy(str,"DDERR_CANTLOCKSURFACE");
 132+ break;
 133+ case DDERR_SURFACELOST:
 134+ strcpy(str,"DDERR_SURFACELOST");
 135+ break;
 136+ case DDERR_SURFACENOTATTACHED:
 137+ strcpy(str,"DDERR_SURFACENOTATTACHED");
 138+ break;
 139+ case DDERR_UNSUPPORTED:
 140+ strcpy(str,"DDERR_UNSUPPORTED");
 141+ break;
 142+ case DDERR_UNSUPPORTEDFORMAT:
 143+ strcpy(str,"DDERR_UNSUPPORTEDFORMAT");
 144+ break;
 145+ case DDERR_UNSUPPORTEDMASK:
 146+ strcpy(str,"DDERR_UNSUPPORTEDMASK");
 147+ break;
 148+ case DDERR_WASSTILLDRAWING:
 149+ strcpy(str,"DDERR_WASSTILLDRAWING");
 150+ break;
 151+ case DDERR_INVALIDDIRECTDRAWGUID:
 152+ strcpy(str,"DDERR_INVALIDDIRECTDRAWGUID");
 153+ break;
 154+ case DDERR_DIRECTDRAWALREADYCREATED:
 155+ strcpy(str,"DDERR_DIRECTDRAWALREADYCREATED");
 156+ break;
 157+ case DDERR_NODIRECTDRAWHW:
 158+ strcpy(str,"DDERR_NODIRECTDRAWHW");
 159+ break;
 160+ case DDERR_PRIMARYSURFACEALREADYEXISTS:
 161+ strcpy(str,"DDERR_PRIMARYSURFACEALREADYEXISTS");
 162+ break;
 163+ case DDERR_CLIPPERISUSINGHWND:
 164+ strcpy(str,"DDERR_CLIPPERISUSINGHWND");
 165+ break;
 166+ case DDERR_NOCLIPPERATTACHED:
 167+ strcpy(str,"DDERR_NOCLIPPERATTACHED");
 168+ break;
 169+ case DDERR_NOHWND:
 170+ strcpy(str,"DDERR_NOHWND");
 171+ break;
 172+ case DDERR_HWNDSUBCLASSED:
 173+ strcpy(str,"DDERR_HWNDSUBCLASSED");
 174+ break;
 175+ case DDERR_HWNDALREADYSET:
 176+ strcpy(str,"DDERR_HWNDALREADYSET");
 177+ break;
 178+ case DDERR_NOPALETTEATTACHED:
 179+ strcpy(str,"DDERR_NOPALETTEATTACHED");
 180+ break;
 181+ case DDERR_NOPALETTEHW:
 182+ strcpy(str,"DDERR_NOPALETTEHW");
 183+ break;
 184+ case DDERR_BLTFASTCANTCLIP:
 185+ strcpy(str,"DDERR_BLTFASTCANTCLIP");
 186+ break;
 187+ case DDERR_OVERLAYNOTVISIBLE:
 188+ strcpy(str,"DDERR_OVERLAYNOTVISIBLE");
 189+ break;
 190+ case DDERR_NOOVERLAYDEST:
 191+ strcpy(str,"DDERR_NOOVERLAYDEST");
 192+ break;
 193+ case DDERR_EXCLUSIVEMODEALREADYSET:
 194+ strcpy(str,"DDERR_EXCLUSIVEMODEALREADYSET");
 195+ break;
 196+ case DDERR_NOTFLIPPABLE:
 197+ strcpy(str,"DDERR_NOTFLIPPABLE");
 198+ break;
 199+ case DDERR_CANTDUPLICATE:
 200+ strcpy(str,"DDERR_CANTDUPLICATE");
 201+ break;
 202+ case DDERR_NOTLOCKED:
 203+ strcpy(str,"DDERR_NOTLOCKED");
 204+ break;
 205+ case DDERR_CANTCREATEDC:
 206+ strcpy(str,"DDERR_CANTCREATEDC");
 207+ break;
 208+ case DDERR_NODC:
 209+ strcpy(str,"DDERR_NODC");
 210+ break;
 211+ case DDERR_WRONGMODE:
 212+ strcpy(str,"DDERR_WRONGMODE");
 213+ break;
 214+ case DDERR_IMPLICITLYCREATED:
 215+ strcpy(str,"DDERR_IMPLICITLYCREATED");
 216+ break;
 217+ case DDERR_NOTPALETTIZED:
 218+ strcpy(str,"DDERR_NOTPALETTIZED");
 219+ break;
 220+ case DDERR_UNSUPPORTEDMODE:
 221+ strcpy(str,"DDERR_UNSUPPORTEDMODE");
 222+ break;
 223+ case DDERR_INVALIDSURFACETYPE:
 224+ strcpy(str,"DDERR_INVALIDSURFACETYPE");
 225+ break;
 226+ case DDERR_NOTONMIPMAPSUBLEVEL:
 227+ strcpy(str,"DDERR_NOTONMIPMAPSUBLEVEL");
 228+ break;
 229+ case DDERR_DCALREADYCREATED:
 230+ strcpy(str,"DDERR_DCALREADYCREATED");
 231+ break;
 232+ case DDERR_CANTPAGELOCK:
 233+ strcpy(str,"DDERR_CANTPAGELOCK");
 234+ break;
 235+ case DDERR_CANTPAGEUNLOCK:
 236+ strcpy(str,"DDERR_CANTPAGEUNLOCK");
 237+ break;
 238+ case DDERR_NOTPAGELOCKED:
 239+ strcpy(str,"DDERR_NOTPAGELOCKED");
 240+ break;
 241+ case DDERR_MOREDATA:
 242+ strcpy(str,"DDERR_MOREDATA");
 243+ break;
 244+ case DDERR_NOTINITIALIZED:
 245+ strcpy(str,"DDERR_NOTINITIALIZED");
 246+ break;
 247+ case E_NOINTERFACE:
 248+ strcpy(str,"E_NOINTERFACE");
 249+ break;
 250+ case CLASS_E_NOAGGREGATION:
 251+ strcpy(str,"CLASS_E_NOAGGREGATION");
 252+ break;
 253+ default:
 254+ sprintf(str,"(HRESULT)0x%08X",hr);
 255+ break;
 256+ }
 257+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 258+}
 259+
 260+static void trace_decode_d3drenderstate(DWORD rs)
 261+{
 262+ DWORD byteswritten;
 263+ char str[64];
 264+ switch(rs)
 265+ {
 266+ case D3DRENDERSTATE_TEXTUREHANDLE:
 267+ strcpy(str,"D3DRENDERSTATE_TEXTUREHANDLE");
 268+ break;
 269+ case D3DRENDERSTATE_ANTIALIAS:
 270+ strcpy(str,"D3DRENDERSTATE_ANTIALIAS");
 271+ break;
 272+ case D3DRENDERSTATE_TEXTUREADDRESS:
 273+ strcpy(str,"D3DRENDERSTATE_TEXTUREADDRESS");
 274+ break;
 275+ case D3DRENDERSTATE_TEXTUREPERSPECTIVE:
 276+ strcpy(str,"D3DRENDERSTATE_TEXTUREPERSPECTIVE");
 277+ break;
 278+ case D3DRENDERSTATE_WRAPU:
 279+ strcpy(str,"D3DRENDERSTATE_WRAPU");
 280+ break;
 281+ case D3DRENDERSTATE_WRAPV:
 282+ strcpy(str,"D3DRENDERSTATE_WRAPV");
 283+ break;
 284+ case D3DRENDERSTATE_ZENABLE:
 285+ strcpy(str,"D3DRENDERSTATE_ZENABLE");
 286+ break;
 287+ case D3DRENDERSTATE_FILLMODE:
 288+ strcpy(str,"D3DRENDERSTATE_FILLMODE");
 289+ break;
 290+ case D3DRENDERSTATE_SHADEMODE:
 291+ strcpy(str,"D3DRENDERSTATE_SHADEMODE");
 292+ break;
 293+ case D3DRENDERSTATE_LINEPATTERN:
 294+ strcpy(str,"D3DRENDERSTATE_LINEPATTERN");
 295+ break;
 296+ case D3DRENDERSTATE_MONOENABLE:
 297+ strcpy(str,"D3DRENDERSTATE_MONOENABLE");
 298+ break;
 299+ case D3DRENDERSTATE_ROP2:
 300+ strcpy(str,"D3DRENDERSTATE_ROP2");
 301+ break;
 302+ case D3DRENDERSTATE_PLANEMASK:
 303+ strcpy(str,"D3DRENDERSTATE_PLANEMASK");
 304+ break;
 305+ case D3DRENDERSTATE_ZWRITEENABLE:
 306+ strcpy(str,"D3DRENDERSTATE_ZWRITEENABLE");
 307+ break;
 308+ case D3DRENDERSTATE_ALPHATESTENABLE:
 309+ strcpy(str,"D3DRENDERSTATE_ALPHATESTENABLE");
 310+ break;
 311+ case D3DRENDERSTATE_LASTPIXEL:
 312+ strcpy(str,"D3DRENDERSTATE_LASTPIXEL");
 313+ break;
 314+ case D3DRENDERSTATE_TEXTUREMAG:
 315+ strcpy(str,"D3DRENDERSTATE_TEXTUREMAG");
 316+ break;
 317+ case D3DRENDERSTATE_TEXTUREMIN:
 318+ strcpy(str,"D3DRENDERSTATE_TEXTUREMIN");
 319+ break;
 320+ case D3DRENDERSTATE_SRCBLEND:
 321+ strcpy(str,"D3DRENDERSTATE_SRCBLEND");
 322+ break;
 323+ case D3DRENDERSTATE_DESTBLEND:
 324+ strcpy(str,"D3DRENDERSTATE_DESTBLEND");
 325+ break;
 326+ case D3DRENDERSTATE_TEXTUREMAPBLEND:
 327+ strcpy(str,"D3DRENDERSTATE_TEXTUREMAPBLEND");
 328+ break;
 329+ case D3DRENDERSTATE_CULLMODE:
 330+ strcpy(str,"D3DRENDERSTATE_CULLMODE");
 331+ break;
 332+ case D3DRENDERSTATE_ZFUNC:
 333+ strcpy(str,"D3DRENDERSTATE_ZFUNC");
 334+ break;
 335+ case D3DRENDERSTATE_ALPHAREF:
 336+ strcpy(str,"D3DRENDERSTATE_ALPHAREF");
 337+ break;
 338+ case D3DRENDERSTATE_ALPHAFUNC:
 339+ strcpy(str,"D3DRENDERSTATE_ALPHAFUNC");
 340+ break;
 341+ case D3DRENDERSTATE_DITHERENABLE:
 342+ strcpy(str,"D3DRENDERSTATE_DITHERENABLE");
 343+ break;
 344+ case D3DRENDERSTATE_ALPHABLENDENABLE:
 345+ strcpy(str,"D3DRENDERSTATE_ALPHABLENDENABLE");
 346+ break;
 347+ case D3DRENDERSTATE_FOGENABLE:
 348+ strcpy(str,"D3DRENDERSTATE_FOGENABLE");
 349+ break;
 350+ case D3DRENDERSTATE_SPECULARENABLE:
 351+ strcpy(str,"D3DRENDERSTATE_SPECULARENABLE");
 352+ break;
 353+ case D3DRENDERSTATE_ZVISIBLE:
 354+ strcpy(str,"D3DRENDERSTATE_ZVISIBLE");
 355+ break;
 356+ case D3DRENDERSTATE_SUBPIXEL:
 357+ strcpy(str,"D3DRENDERSTATE_SUBPIXEL");
 358+ break;
 359+ case D3DRENDERSTATE_SUBPIXELX:
 360+ strcpy(str,"D3DRENDERSTATE_SUBPIXELX");
 361+ break;
 362+ case D3DRENDERSTATE_STIPPLEDALPHA:
 363+ strcpy(str,"D3DRENDERSTATE_STIPPLEDALPHA");
 364+ break;
 365+ case D3DRENDERSTATE_FOGCOLOR:
 366+ strcpy(str,"D3DRENDERSTATE_FOGCOLOR");
 367+ break;
 368+ case D3DRENDERSTATE_FOGTABLEMODE:
 369+ strcpy(str,"D3DRENDERSTATE_FOGTABLEMODE");
 370+ break;
 371+ case D3DRENDERSTATE_FOGSTART:
 372+ strcpy(str,"D3DRENDERSTATE_FOGSTART");
 373+ break;
 374+ case D3DRENDERSTATE_FOGEND:
 375+ strcpy(str,"D3DRENDERSTATE_FOGEND");
 376+ break;
 377+ case D3DRENDERSTATE_FOGDENSITY:
 378+ strcpy(str,"D3DRENDERSTATE_FOGDENSITY");
 379+ break;
 380+ case D3DRENDERSTATE_STIPPLEENABLE:
 381+ strcpy(str,"D3DRENDERSTATE_STIPPLEENABLE");
 382+ break;
 383+ case D3DRENDERSTATE_EDGEANTIALIAS:
 384+ strcpy(str,"D3DRENDERSTATE_EDGEANTIALIAS");
 385+ break;
 386+ case D3DRENDERSTATE_COLORKEYENABLE:
 387+ strcpy(str,"D3DRENDERSTATE_COLORKEYENABLE");
 388+ break;
 389+ case 42: // DX5 D3DRENDERSTATE_ALPHABLENDENABLE
 390+ strcpy(str,"D3DRENDERSTATE_ALPHABLENDENABLE(DX5)");
 391+ break;
 392+ case D3DRENDERSTATE_BORDERCOLOR:
 393+ strcpy(str,"D3DRENDERSTATE_BORDERCOLOR");
 394+ break;
 395+ case D3DRENDERSTATE_TEXTUREADDRESSU:
 396+ strcpy(str,"D3DRENDERSTATE_TEXTUREADDRESSU");
 397+ break;
 398+ case D3DRENDERSTATE_TEXTUREADDRESSV:
 399+ strcpy(str,"D3DRENDERSTATE_TEXTUREADDRESSV");
 400+ break;
 401+ case D3DRENDERSTATE_MIPMAPLODBIAS:
 402+ strcpy(str,"D3DRENDERSTATE_MIPMAPLODBIAS");
 403+ break;
 404+ case D3DRENDERSTATE_ZBIAS:
 405+ strcpy(str,"D3DRENDERSTATE_ZBIAS");
 406+ break;
 407+ case D3DRENDERSTATE_RANGEFOGENABLE:
 408+ strcpy(str,"D3DRENDERSTATE_RANGEFOGENABLE");
 409+ break;
 410+ case D3DRENDERSTATE_ANISOTROPY:
 411+ strcpy(str,"D3DRENDERSTATE_ANISOTROPY");
 412+ break;
 413+ case D3DRENDERSTATE_FLUSHBATCH:
 414+ strcpy(str,"D3DRENDERSTATE_FLUSHBATCH");
 415+ break;
 416+ case D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT:
 417+ strcpy(str,"D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT");
 418+ break;
 419+ case D3DRENDERSTATE_STENCILENABLE:
 420+ strcpy(str,"D3DRENDERSTATE_STENCILENABLE");
 421+ break;
 422+ case D3DRENDERSTATE_STENCILFAIL:
 423+ strcpy(str,"D3DRENDERSTATE_STENCILFAIL");
 424+ break;
 425+ case D3DRENDERSTATE_STENCILZFAIL:
 426+ strcpy(str,"D3DRENDERSTATE_STENCILZFAIL");
 427+ break;
 428+ case D3DRENDERSTATE_STENCILPASS:
 429+ strcpy(str,"D3DRENDERSTATE_STENCILPASS");
 430+ break;
 431+ case D3DRENDERSTATE_STENCILFUNC:
 432+ strcpy(str,"D3DRENDERSTATE_STENCILFUNC");
 433+ break;
 434+ case D3DRENDERSTATE_STENCILREF:
 435+ strcpy(str,"D3DRENDERSTATE_STENCILREF");
 436+ break;
 437+ case D3DRENDERSTATE_STENCILMASK:
 438+ strcpy(str,"D3DRENDERSTATE_STENCILMASK");
 439+ break;
 440+ case D3DRENDERSTATE_STENCILWRITEMASK:
 441+ strcpy(str,"D3DRENDERSTATE_STENCILWRITEMASK");
 442+ break;
 443+ case D3DRENDERSTATE_TEXTUREFACTOR:
 444+ strcpy(str,"D3DRENDERSTATE_TEXTUREFACTOR");
 445+ break;
 446+ case D3DRENDERSTATE_STIPPLEPATTERN00:
 447+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN00");
 448+ break;
 449+ case D3DRENDERSTATE_STIPPLEPATTERN01:
 450+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN01");
 451+ break;
 452+ case D3DRENDERSTATE_STIPPLEPATTERN02:
 453+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN02");
 454+ break;
 455+ case D3DRENDERSTATE_STIPPLEPATTERN03:
 456+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN03");
 457+ break;
 458+ case D3DRENDERSTATE_STIPPLEPATTERN04:
 459+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN04");
 460+ break;
 461+ case D3DRENDERSTATE_STIPPLEPATTERN05:
 462+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN05");
 463+ break;
 464+ case D3DRENDERSTATE_STIPPLEPATTERN06:
 465+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN06");
 466+ break;
 467+ case D3DRENDERSTATE_STIPPLEPATTERN07:
 468+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN07");
 469+ break;
 470+ case D3DRENDERSTATE_STIPPLEPATTERN08:
 471+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN08");
 472+ break;
 473+ case D3DRENDERSTATE_STIPPLEPATTERN09:
 474+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN09");
 475+ break;
 476+ case D3DRENDERSTATE_STIPPLEPATTERN10:
 477+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN10");
 478+ break;
 479+ case D3DRENDERSTATE_STIPPLEPATTERN11:
 480+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN11");
 481+ break;
 482+ case D3DRENDERSTATE_STIPPLEPATTERN12:
 483+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN12");
 484+ break;
 485+ case D3DRENDERSTATE_STIPPLEPATTERN13:
 486+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN13");
 487+ break;
 488+ case D3DRENDERSTATE_STIPPLEPATTERN14:
 489+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN14");
 490+ break;
 491+ case D3DRENDERSTATE_STIPPLEPATTERN15:
 492+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN15");
 493+ break;
 494+ case D3DRENDERSTATE_STIPPLEPATTERN16:
 495+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN16");
 496+ break;
 497+ case D3DRENDERSTATE_STIPPLEPATTERN17:
 498+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN17");
 499+ break;
 500+ case D3DRENDERSTATE_STIPPLEPATTERN18:
 501+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN18");
 502+ break;
 503+ case D3DRENDERSTATE_STIPPLEPATTERN19:
 504+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN19");
 505+ break;
 506+ case D3DRENDERSTATE_STIPPLEPATTERN20:
 507+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN20");
 508+ break;
 509+ case D3DRENDERSTATE_STIPPLEPATTERN21:
 510+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN21");
 511+ break;
 512+ case D3DRENDERSTATE_STIPPLEPATTERN22:
 513+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN22");
 514+ break;
 515+ case D3DRENDERSTATE_STIPPLEPATTERN23:
 516+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN23");
 517+ break;
 518+ case D3DRENDERSTATE_STIPPLEPATTERN24:
 519+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN24");
 520+ break;
 521+ case D3DRENDERSTATE_STIPPLEPATTERN25:
 522+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN25");
 523+ break;
 524+ case D3DRENDERSTATE_STIPPLEPATTERN26:
 525+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN26");
 526+ break;
 527+ case D3DRENDERSTATE_STIPPLEPATTERN27:
 528+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN27");
 529+ break;
 530+ case D3DRENDERSTATE_STIPPLEPATTERN28:
 531+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN28");
 532+ break;
 533+ case D3DRENDERSTATE_STIPPLEPATTERN29:
 534+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN29");
 535+ break;
 536+ case D3DRENDERSTATE_STIPPLEPATTERN30:
 537+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN30");
 538+ break;
 539+ case D3DRENDERSTATE_STIPPLEPATTERN31:
 540+ strcpy(str,"D3DRENDERSTATE_STIPPLEPATTERN31");
 541+ break;
 542+ case D3DRENDERSTATE_WRAP0:
 543+ strcpy(str,"D3DRENDERSTATE_WRAP0");
 544+ break;
 545+ case D3DRENDERSTATE_WRAP1:
 546+ strcpy(str,"D3DRENDERSTATE_WRAP1");
 547+ break;
 548+ case D3DRENDERSTATE_WRAP2:
 549+ strcpy(str,"D3DRENDERSTATE_WRAP2");
 550+ break;
 551+ case D3DRENDERSTATE_WRAP3:
 552+ strcpy(str,"D3DRENDERSTATE_WRAP3");
 553+ break;
 554+ case D3DRENDERSTATE_WRAP4:
 555+ strcpy(str,"D3DRENDERSTATE_WRAP4");
 556+ break;
 557+ case D3DRENDERSTATE_WRAP5:
 558+ strcpy(str,"D3DRENDERSTATE_WRAP5");
 559+ break;
 560+ case D3DRENDERSTATE_WRAP6:
 561+ strcpy(str,"D3DRENDERSTATE_WRAP6");
 562+ break;
 563+ case D3DRENDERSTATE_WRAP7:
 564+ strcpy(str,"D3DRENDERSTATE_WRAP7");
 565+ break;
 566+ case D3DRENDERSTATE_CLIPPING:
 567+ strcpy(str,"D3DRENDERSTATE_CLIPPING");
 568+ break;
 569+ case D3DRENDERSTATE_LIGHTING:
 570+ strcpy(str,"D3DRENDERSTATE_LIGHTING");
 571+ break;
 572+ case D3DRENDERSTATE_EXTENTS:
 573+ strcpy(str,"D3DRENDERSTATE_EXTENTS");
 574+ break;
 575+ case D3DRENDERSTATE_AMBIENT:
 576+ strcpy(str,"D3DRENDERSTATE_AMBIENT");
 577+ break;
 578+ case D3DRENDERSTATE_FOGVERTEXMODE:
 579+ strcpy(str,"D3DRENDERSTATE_FOGVERTEXMODE");
 580+ break;
 581+ case D3DRENDERSTATE_COLORVERTEX:
 582+ strcpy(str,"D3DRENDERSTATE_COLORVERTEX");
 583+ break;
 584+ case D3DRENDERSTATE_LOCALVIEWER:
 585+ strcpy(str,"D3DRENDERSTATE_LOCALVIEWER");
 586+ break;
 587+ case D3DRENDERSTATE_NORMALIZENORMALS:
 588+ strcpy(str,"D3DRENDERSTATE_NORMALIZENORMALS");
 589+ break;
 590+ case D3DRENDERSTATE_COLORKEYBLENDENABLE:
 591+ strcpy(str,"D3DRENDERSTATE_COLORKEYBLENDENABLE");
 592+ break;
 593+ case D3DRENDERSTATE_DIFFUSEMATERIALSOURCE:
 594+ strcpy(str,"D3DRENDERSTATE_DIFFUSEMATERIALSOURCE");
 595+ break;
 596+ case D3DRENDERSTATE_SPECULARMATERIALSOURCE:
 597+ strcpy(str,"D3DRENDERSTATE_SPECULARMATERIALSOURCE");
 598+ break;
 599+ case D3DRENDERSTATE_AMBIENTMATERIALSOURCE:
 600+ strcpy(str,"D3DRENDERSTATE_AMBIENTMATERIALSOURCE");
 601+ break;
 602+ case D3DRENDERSTATE_EMISSIVEMATERIALSOURCE:
 603+ strcpy(str,"D3DRENDERSTATE_EMISSIVEMATERIALSOURCE");
 604+ break;
 605+ case D3DRENDERSTATE_VERTEXBLEND:
 606+ strcpy(str,"D3DRENDERSTATE_VERTEXBLEND");
 607+ break;
 608+ case D3DRENDERSTATE_CLIPPLANEENABLE:
 609+ strcpy(str,"D3DRENDERSTATE_CLIPPLANEENABLE");
 610+ break;
 611+ default:
 612+ sprintf(str,"(D3DRENDERSTATETYPE)%u",rs);
 613+ break;
 614+ }
 615+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 616+}
 617+
 618+static void trace_decode_d3dtexturestagestate(DWORD ts)
 619+{
 620+ DWORD byteswritten;
 621+ char str[64];
 622+ switch(ts)
 623+ {
 624+ case D3DTSS_COLOROP:
 625+ strcpy(str,"D3DTSS_COLOROP");
 626+ break;
 627+ case D3DTSS_COLORARG1:
 628+ strcpy(str,"D3DTSS_COLORARG1");
 629+ break;
 630+ case D3DTSS_COLORARG2:
 631+ strcpy(str,"D3DTSS_COLORARG2");
 632+ break;
 633+ case D3DTSS_ALPHAOP:
 634+ strcpy(str,"D3DTSS_ALPHAOP");
 635+ break;
 636+ case D3DTSS_ALPHAARG1:
 637+ strcpy(str,"D3DTSS_ALPHAARG1");
 638+ break;
 639+ case D3DTSS_ALPHAARG2:
 640+ strcpy(str,"D3DTSS_ALPHAARG2");
 641+ break;
 642+ case D3DTSS_BUMPENVMAT00:
 643+ strcpy(str,"D3DTSS_BUMPENVMAT00");
 644+ break;
 645+ case D3DTSS_BUMPENVMAT01:
 646+ strcpy(str,"D3DTSS_BUMPENVMAT01");
 647+ break;
 648+ case D3DTSS_BUMPENVMAT10:
 649+ strcpy(str,"D3DTSS_BUMPENVMAT10");
 650+ break;
 651+ case D3DTSS_BUMPENVMAT11:
 652+ strcpy(str,"D3DTSS_BUMPENVMAT11");
 653+ break;
 654+ case D3DTSS_TEXCOORDINDEX:
 655+ strcpy(str,"D3DTSS_TEXCOORDINDEX");
 656+ break;
 657+ case D3DTSS_ADDRESS:
 658+ strcpy(str,"D3DTSS_ADDRESS");
 659+ break;
 660+ case D3DTSS_ADDRESSU:
 661+ strcpy(str,"D3DTSS_ADDRESSU");
 662+ break;
 663+ case D3DTSS_ADDRESSV:
 664+ strcpy(str,"D3DTSS_ADDRESSV");
 665+ break;
 666+ case D3DTSS_BORDERCOLOR:
 667+ strcpy(str,"D3DTSS_BORDERCOLOR");
 668+ break;
 669+ case D3DTSS_MAGFILTER:
 670+ strcpy(str,"D3DTSS_MAGFILTER");
 671+ break;
 672+ case D3DTSS_MINFILTER:
 673+ strcpy(str,"D3DTSS_MINFILTER");
 674+ break;
 675+ case D3DTSS_MIPFILTER:
 676+ strcpy(str,"D3DTSS_MIPFILTER");
 677+ break;
 678+ case D3DTSS_MIPMAPLODBIAS:
 679+ strcpy(str,"D3DTSS_MIPMAPLODBIAS");
 680+ break;
 681+ case D3DTSS_MAXMIPLEVEL:
 682+ strcpy(str,"D3DTSS_MAXMIPLEVEL");
 683+ break;
 684+ case D3DTSS_MAXANISOTROPY:
 685+ strcpy(str,"D3DTSS_MAXANISOTROPY");
 686+ break;
 687+ case D3DTSS_BUMPENVLSCALE:
 688+ strcpy(str,"D3DTSS_BUMPENVLSCALE");
 689+ break;
 690+ case D3DTSS_BUMPENVLOFFSET:
 691+ strcpy(str,"D3DTSS_BUMPENVLOFFSET");
 692+ break;
 693+ case D3DTSS_TEXTURETRANSFORMFLAGS:
 694+ strcpy(str,"D3DTSS_TEXTURETRANSFORMFLAGS");
 695+ break;
 696+ default:
 697+ sprintf(str,"(D3DTEXTURESTAGESTATETYPE)%u",ts);
 698+ break;
 699+ }
 700+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 701+}
 702+
 703+static void trace_decode_d3dtransformstate(DWORD ts)
 704+{
 705+ DWORD byteswritten;
 706+ char str[64];
 707+ switch(ts)
 708+ {
 709+ case D3DTRANSFORMSTATE_WORLD:
 710+ strcpy(str,"D3DTRANSFORMSTATE_WORLD");
 711+ break;
 712+ case D3DTRANSFORMSTATE_VIEW:
 713+ strcpy(str,"D3DTRANSFORMSTATE_VIEW");
 714+ break;
 715+ case D3DTRANSFORMSTATE_PROJECTION:
 716+ strcpy(str,"D3DTRANSFORMSTATE_PROJECTION");
 717+ break;
 718+ case D3DTRANSFORMSTATE_WORLD1:
 719+ strcpy(str,"D3DTRANSFORMSTATE_WORLD1");
 720+ break;
 721+ case D3DTRANSFORMSTATE_WORLD2:
 722+ strcpy(str,"D3DTRANSFORMSTATE_WORLD2");
 723+ break;
 724+ case D3DTRANSFORMSTATE_WORLD3:
 725+ strcpy(str,"D3DTRANSFORMSTATE_WORLD3");
 726+ break;
 727+ case D3DTRANSFORMSTATE_TEXTURE0:
 728+ strcpy(str,"D3DTRANSFORMSTATE_TEXTURE0");
 729+ break;
 730+ case D3DTRANSFORMSTATE_TEXTURE1:
 731+ strcpy(str,"D3DTRANSFORMSTATE_TEXTURE1");
 732+ break;
 733+ case D3DTRANSFORMSTATE_TEXTURE2:
 734+ strcpy(str,"D3DTRANSFORMSTATE_TEXTURE2");
 735+ break;
 736+ case D3DTRANSFORMSTATE_TEXTURE3:
 737+ strcpy(str,"D3DTRANSFORMSTATE_TEXTURE3");
 738+ break;
 739+ case D3DTRANSFORMSTATE_TEXTURE4:
 740+ strcpy(str,"D3DTRANSFORMSTATE_TEXTURE4");
 741+ break;
 742+ case D3DTRANSFORMSTATE_TEXTURE5:
 743+ strcpy(str,"D3DTRANSFORMSTATE_TEXTURE5");
 744+ break;
 745+ case D3DTRANSFORMSTATE_TEXTURE6:
 746+ strcpy(str,"D3DTRANSFORMSTATE_TEXTURE6");
 747+ break;
 748+ case D3DTRANSFORMSTATE_TEXTURE7:
 749+ strcpy(str,"D3DTRANSFORMSTATE_TEXTURE7");
 750+ break;
 751+ default:
 752+ sprintf(str,"(D3DTRANSFORMSTATETYPE)%u",ts);
 753+ break;
 754+ }
 755+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 756+}
 757+
 758+static void trace_decode_d3dlightstate(DWORD ls)
 759+{
 760+ DWORD byteswritten;
 761+ char str[64];
 762+ switch(ls)
 763+ {
 764+ case D3DLIGHTSTATE_MATERIAL:
 765+ strcpy(str,"D3DLIGHTSTATE_MATERIAL");
 766+ break;
 767+ case D3DLIGHTSTATE_AMBIENT:
 768+ strcpy(str,"D3DLIGHTSTATE_AMBIENT");
 769+ break;
 770+ case D3DLIGHTSTATE_COLORMODEL:
 771+ strcpy(str,"D3DLIGHTSTATE_COLORMODEL");
 772+ break;
 773+ case D3DLIGHTSTATE_FOGMODE:
 774+ strcpy(str,"D3DLIGHTSTATE_FOGMODE");
 775+ break;
 776+ case D3DLIGHTSTATE_FOGSTART:
 777+ strcpy(str,"D3DLIGHTSTATE_FOGSTART");
 778+ break;
 779+ case D3DLIGHTSTATE_FOGEND:
 780+ strcpy(str,"D3DLIGHTSTATE_FOGEND");
 781+ break;
 782+ case D3DLIGHTSTATE_FOGDENSITY:
 783+ strcpy(str,"D3DLIGHTSTATE_FOGDENSITY");
 784+ break;
 785+ case D3DLIGHTSTATE_COLORVERTEX:
 786+ strcpy(str,"D3DLIGHTSTATE_COLORVERTEX");
 787+ break;
 788+ default:
 789+ sprintf(str,"(D3DTRANSFORMSTATETYPE)%u",ls);
 790+ break;
 791+ }
 792+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 793+}
 794+
 795+static void trace_decode_guid(GUID *guid)
 796+{
 797+ DWORD byteswritten;
 798+ char str[64];
 799+ if(!memcmp(guid,&CLSID_DirectDraw,sizeof(GUID))) strcpy(str,"CLSID_DirectDraw");
 800+ else if(!memcmp(guid,&CLSID_DirectDraw7,sizeof(GUID))) strcpy(str,"CLSID_DirectDraw7");
 801+ else if(!memcmp(guid,&CLSID_DirectDrawClipper,sizeof(GUID))) strcpy(str,"CLSID_DirectDrawClipper");
 802+ else if(!memcmp(guid,&IID_IDirectDraw,sizeof(GUID))) strcpy(str,"IID_IDirectDraw");
 803+ else if(!memcmp(guid,&IID_IDirectDraw2,sizeof(GUID))) strcpy(str,"IID_IDirectDraw2");
 804+ else if(!memcmp(guid,&IID_IDirectDraw4,sizeof(GUID))) strcpy(str,"IID_IDirectDraw4");
 805+ else if(!memcmp(guid,&IID_IDirectDraw7,sizeof(GUID))) strcpy(str,"IID_IDirectDraw7");
 806+ else if(!memcmp(guid,&IID_IDirectDrawSurface,sizeof(GUID))) strcpy(str,"IID_IDirectDrawSurface");
 807+ else if(!memcmp(guid,&IID_IDirectDrawSurface2,sizeof(GUID))) strcpy(str,"IID_IDirectDrawSurface2");
 808+ else if(!memcmp(guid,&IID_IDirectDrawSurface3,sizeof(GUID))) strcpy(str,"IID_IDirectDrawSurface3");
 809+ else if(!memcmp(guid,&IID_IDirectDrawSurface4,sizeof(GUID))) strcpy(str,"IID_IDirectDrawSurface4");
 810+ else if(!memcmp(guid,&IID_IDirectDrawSurface7,sizeof(GUID))) strcpy(str,"IID_IDirectDrawSurface7");
 811+ else if(!memcmp(guid,&IID_IDirectDrawPalette,sizeof(GUID))) strcpy(str,"IID_IDirectDrawPalette");
 812+ else if(!memcmp(guid,&IID_IDirectDrawClipper,sizeof(GUID))) strcpy(str,"IID_IDirectDrawClipper");
 813+ else if(!memcmp(guid,&IID_IDirectDrawColorControl,sizeof(GUID))) strcpy(str,"IID_IDirectDrawColorControl");
 814+ else if(!memcmp(guid,&IID_IDirectDrawGammaControl,sizeof(GUID))) strcpy(str,"IID_IDirectDrawGammaControl");
 815+ else if(!memcmp(guid,&IID_IDirect3D,sizeof(GUID))) strcpy(str,"IID_IDirect3D");
 816+ else if(!memcmp(guid,&IID_IDirect3D2,sizeof(GUID))) strcpy(str,"IID_IDirect3D2");
 817+ else if(!memcmp(guid,&IID_IDirect3D3,sizeof(GUID))) strcpy(str,"IID_IDirect3D3");
 818+ else if(!memcmp(guid,&IID_IDirect3D7,sizeof(GUID))) strcpy(str,"IID_IDirect3D7");
 819+ else
 820+ {
 821+ OLECHAR guidstr[41] = {0};
 822+ StringFromGUID2(guid,guidstr,40);
 823+ WideCharToMultiByte(CP_UTF8,0,guidstr,-1,str,64,NULL,NULL);
 824+ }
 825+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 826+}
 827+static void trace_decode_size(SIZE *size)
 828+{
 829+ DWORD byteswritten;
 830+ char str[64];
 831+ sprintf(str,"{%d,%d}",size->cx,size->cy);
 832+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 833+}
 834+static void trace_decode_rect(RECT *rect)
 835+{
 836+ DWORD byteswritten;
 837+ char str[64];
 838+ sprintf(str,"{%d,%d,%d,%d}",rect->left,rect->top,rect->right,rect->bottom);
 839+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 840+}
 841+static void init_trace()
 842+{
 843+ TCHAR path[MAX_PATH+1];
 844+ TCHAR *path_truncate;
 845+ InitializeCriticalSection(&trace_cs);
 846+ GetModuleFileName(NULL,path,MAX_PATH);
 847+ path_truncate = _tcsrchr(path,_T('\\'));
 848+ if(path_truncate) *(path_truncate+1) = 0;
 849+ _tcscat(path,_T("dxgl.log"));
 850+ outfile = CreateFile(path,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
 851+ if(outfile == INVALID_HANDLE_VALUE)
 852+ {
 853+ trace_fail = TRUE;
 854+ return;
 855+ }
 856+ trace_ready = TRUE;
 857+}
 858+static void trace_decode_arg(int type, void *arg)
 859+{
 860+ DWORD byteswritten;
 861+ char str[128];
 862+ char *mbcsbuffer;
 863+ int buffersize;
 864+ str[0] = 0;
 865+ switch(type)
 866+ {
 867+ case -1: // C++ constructor/destructor
 868+ // No return type in a constructor or destructor.
 869+ break;
 870+ case 0: // void
 871+ WriteFile(outfile,"void",4,&byteswritten,NULL);
 872+ break;
 873+ case 1: // 8-bit signed
 874+ sprintf(str,"%d",(signed char)arg);
 875+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 876+ break;
 877+ case 2: // 8-bit unsigned
 878+ sprintf(str,"%u",(unsigned char)arg);
 879+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 880+ break;
 881+ case 3: // 8-bit hex
 882+ sprintf(str,"0x%02X",(unsigned char)arg);
 883+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 884+ break;
 885+ case 4: // 16-bit signed
 886+ sprintf(str,"%d",(signed short)arg);
 887+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 888+ break;
 889+ case 5: // 16-bit unsigned
 890+ sprintf(str,"%u",(unsigned short)arg);
 891+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 892+ break;
 893+ case 6: // 16-bit hex
 894+ sprintf(str,"0x%04X",(unsigned short)arg);
 895+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 896+ break;
 897+ case 7: // 32-bit signed
 898+ sprintf(str,"%d",(signed long)arg);
 899+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 900+ break;
 901+ case 8: // 32-bit unsigned
 902+ sprintf(str,"%u",(unsigned long)arg);
 903+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 904+ break;
 905+ case 9: // 32-bit hex
 906+ sprintf(str,"0x%08X",(unsigned long)arg);
 907+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 908+ break;
 909+ case 10: // pointer to 64-bit hex
 910+ sprintf(str,"0x%016I64X",(unsigned __int64)*(unsigned __int64*)arg);
 911+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 912+ break;
 913+ case 11: // native signed
 914+ sprintf(str,"%d",(signed int)arg);
 915+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 916+ break;
 917+ case 12: // native unsigned
 918+ sprintf(str,"%u",(unsigned int)arg);
 919+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 920+ break;
 921+ case 13: // native hex
 922+ sprintf(str,"0x%08X",(unsigned int)arg);
 923+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 924+ break;
 925+ case 14: // generic pointer
 926+ if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
 927+ else
 928+ {
 929+#ifdef _M_X64
 930+ sprintf(str,"0x%016I64X",arg);
 931+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 932+#else
 933+ sprintf(str,"0x%08X",arg);
 934+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 935+#endif
 936+ }
 937+ break;
 938+ case 15: // ASCII string
 939+ if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
 940+ else
 941+ {
 942+ WriteFile(outfile,"\"",1,&byteswritten,NULL);
 943+ WriteFile(outfile,arg,strlen((char*)arg),&byteswritten,NULL);
 944+ WriteFile(outfile,"\"",1,&byteswritten,NULL);
 945+ }
 946+ break;
 947+ case 16: // Unicode string
 948+ if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
 949+ else
 950+ {
 951+ WriteFile(outfile,"L\"",1,&byteswritten,NULL);
 952+ buffersize = WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,NULL,0,NULL,NULL);
 953+ mbcsbuffer = (char*)malloc(buffersize);
 954+ if(!mbcsbuffer) WriteFile(outfile,"OUT OF MEMORY",13,&byteswritten,NULL);
 955+ else
 956+ {
 957+ WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,mbcsbuffer,buffersize,NULL,NULL);
 958+ WriteFile(outfile,mbcsbuffer,strlen(mbcsbuffer),&byteswritten,NULL);
 959+ free(mbcsbuffer);
 960+ }
 961+ WriteFile(outfile,"\"",1,&byteswritten,NULL);
 962+ }
 963+ break;
 964+ case 17: // TCHAR string
 965+ if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
 966+#ifdef _UNICODE
 967+ else
 968+ {
 969+ WriteFile(outfile,"_T(\"",1,&byteswritten,NULL);
 970+ buffersize = WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,NULL,0,NULL,NULL);
 971+ mbcsbuffer = (char*)malloc(buffersize);
 972+ if(!mbcsbuffer) WriteFile(outfile,"OUT OF MEMORY",13,&byteswritten,NULL);
 973+ else
 974+ {
 975+ WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,mbcsbuffer,buffersize,NULL,NULL);
 976+ WriteFile(outfile,mbcsbuffer,strlen(mbcsbuffer),&byteswritten,NULL);
 977+ free(mbcsbuffer);
 978+ }
 979+ WriteFile(outfile,"\")",1,&byteswritten,NULL);
 980+ }
 981+#else
 982+ else
 983+ {
 984+ WriteFile(outfile,"_T(\"",1,&byteswritten,NULL);
 985+ WriteFile(outfile,arg,strlen((char*)arg),&byteswritten,NULL);
 986+ WriteFile(outfile,"\")",1,&byteswritten,NULL);
 987+ }
 988+#endif
 989+ break;
 990+ case 18: // ASCII character
 991+ if(!(unsigned char)arg) WriteFile(outfile,"\'\\0\'",4,&byteswritten,NULL);
 992+ else
 993+ {
 994+ str[0] = str[2] = '\'';
 995+ str[1] = (unsigned char)arg;
 996+ str[3] = 0;
 997+ WriteFile(outfile,str,3,&byteswritten,NULL);
 998+ }
 999+ break;
 1000+ case 19: // pointer to 32 bit float
 1001+ sprintf(str,"%f",arg);
 1002+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 1003+ break;
 1004+ case 20: // pointer to 64 bit float
 1005+ sprintf(str,"%lf",arg);
 1006+ WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
 1007+ break;
 1008+ case 21: // c++ bool
 1009+ if((unsigned char)arg) WriteFile(outfile,"true",4,&byteswritten,NULL);
 1010+ else WriteFile(outfile,"false",5,&byteswritten,NULL);
 1011+ break;
 1012+ case 22: // c++ bool
 1013+ if(arg) WriteFile(outfile,"TRUE",4,&byteswritten,NULL);
 1014+ else WriteFile(outfile,"FALSE",5,&byteswritten,NULL);
 1015+ break;
 1016+ case 23: // HRESULT
 1017+ trace_decode_hresult((HRESULT)arg);
 1018+ break;
 1019+ case 24: // GUID pointer
 1020+ if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
 1021+ else if(arg == (void*)DDCREATE_HARDWAREONLY) WriteFile(outfile,"DDCREATE_HARDWAREONLY",21,&byteswritten,NULL);
 1022+ else if(arg == (void*)DDCREATE_EMULATIONONLY) WriteFile(outfile,"DDCREATE_EMULATIONONLY",22,&byteswritten,NULL);
 1023+ else trace_decode_guid((GUID*)arg);
 1024+ break;
 1025+ case 25: // SIZE or POINT pointer
 1026+ if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
 1027+ else trace_decode_size((SIZE*)arg);
 1028+ break;
 1029+ case 26: // RECT pointer
 1030+ if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
 1031+ else trace_decode_rect((RECT*)arg);
 1032+ break;
 1033+ case 27: // D3DRENDERSTATETYPE
 1034+ trace_decode_d3drenderstate((DWORD)arg);
 1035+ break;
 1036+ case 28: // D3DTEXTURESTAGESTATETYPE
 1037+ trace_decode_d3dtexturestagestate((DWORD)arg);
 1038+ break;
 1039+ case 29: // D3DTRANSFORMSTATETYPE
 1040+ trace_decode_d3dtransformstate((DWORD)arg);
 1041+ break;
 1042+ case 30: // D3DLIGHTSTATETYPE
 1043+ trace_decode_d3dlightstate((DWORD)arg);
 1044+ break;
 1045+ default:
 1046+ WriteFile(outfile,"Unknown type",12,&byteswritten,NULL);
 1047+ break;
 1048+ }
 1049+}
 1050+static void end_trace()
 1051+{
 1052+ DWORD byteswritten;
 1053+ WriteFile(outfile,"Trace cancelled by CTRL+Break\r\n",31,&byteswritten,NULL);
 1054+ CloseHandle(outfile);
 1055+ outfile = INVALID_HANDLE_VALUE;
 1056+ trace_fail = TRUE;
 1057+}
 1058+void trace_enter(const char *function, int paramcount, ...)
 1059+{
 1060+ va_list args;
 1061+ DWORD byteswritten;
 1062+ unsigned int i;
 1063+ int argtype;
 1064+ if (trace_fail) return;
 1065+ if(!trace_ready) init_trace();
 1066+ EnterCriticalSection(&trace_cs);
 1067+ if(trace_end)
 1068+ {
 1069+ end_trace();
 1070+ LeaveCriticalSection(&trace_cs);
 1071+ return;
 1072+ }
 1073+ va_start(args,paramcount);
 1074+ for(i = 0; i < trace_depth; i++)
 1075+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1076+ WriteFile(outfile,function,strlen(function),&byteswritten,NULL);
 1077+ WriteFile(outfile,"(",1,&byteswritten,NULL);
 1078+ for(i = 0; i < (unsigned)paramcount; i++)
 1079+ {
 1080+ if(i != 0) WriteFile(outfile,", ",2,&byteswritten,NULL);
 1081+ argtype = va_arg(args,int);
 1082+ trace_decode_arg(argtype,va_arg(args,void*));
 1083+ }
 1084+ WriteFile(outfile,");\r\n",4,&byteswritten,NULL);
 1085+ trace_depth++;
 1086+ LeaveCriticalSection(&trace_cs);
 1087+}
 1088+void trace_exit(const char *function, int argtype, void *arg)
 1089+{
 1090+ DWORD byteswritten;
 1091+ unsigned int i;
 1092+ if (trace_fail) return;
 1093+ if(!trace_ready) init_trace();
 1094+ EnterCriticalSection(&trace_cs);
 1095+ if(trace_end)
 1096+ {
 1097+ end_trace();
 1098+ LeaveCriticalSection(&trace_cs);
 1099+ return;
 1100+ }
 1101+ if(trace_depth) trace_depth--;
 1102+ for(i = 0; i < trace_depth; i++)
 1103+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1104+ WriteFile(outfile,function,strlen(function),&byteswritten,NULL);
 1105+ WriteFile(outfile," returned ",10,&byteswritten,NULL);
 1106+ trace_decode_arg(argtype,arg);
 1107+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1108+ LeaveCriticalSection(&trace_cs);
 1109+}
 1110+void *trace_ret(const char *function, int argtype, void *arg)
 1111+{
 1112+ trace_exit(function,argtype,arg);
 1113+ return arg;
 1114+}
 1115+void trace_var(const char *function, const char *var, int argtype, void *arg)
 1116+{
 1117+ DWORD byteswritten;
 1118+ unsigned int i;
 1119+ if (trace_fail) return;
 1120+ if(!trace_ready) init_trace();
 1121+ EnterCriticalSection(&trace_cs);
 1122+ if(trace_end)
 1123+ {
 1124+ end_trace();
 1125+ LeaveCriticalSection(&trace_cs);
 1126+ return;
 1127+ }
 1128+ for(i = 0; i < trace_depth-1; i++)
 1129+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1130+ WriteFile(outfile,function,strlen(function),&byteswritten,NULL);
 1131+ WriteFile(outfile,": ",2,&byteswritten,NULL);
 1132+ WriteFile(outfile,var,strlen(var),&byteswritten,NULL);
 1133+ WriteFile(outfile," set to ",8,&byteswritten,NULL);
 1134+ trace_decode_arg(argtype,arg);
 1135+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1136+ LeaveCriticalSection(&trace_cs);
 1137+}
 1138+
 1139+void trace_sysinfo()
 1140+{
 1141+ DWORD byteswritten;
 1142+ OSVERSIONINFOA osver;
 1143+ DWORD buildver;
 1144+ char osstring[256];
 1145+ HMODULE hKernel32;
 1146+ BOOL(WINAPI *iswow64)(HANDLE, PBOOL);
 1147+ BOOL is64;
 1148+ unsigned int i;
 1149+ const GLubyte *glstring;
 1150+ if (trace_fail) return;
 1151+ if(!trace_ready) init_trace();
 1152+ EnterCriticalSection(&trace_cs);
 1153+ if(trace_end)
 1154+ {
 1155+ end_trace();
 1156+ LeaveCriticalSection(&trace_cs);
 1157+ return;
 1158+ }
 1159+ osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
 1160+ GetVersionExA(&osver);
 1161+ if(osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) buildver = LOWORD(osver.dwBuildNumber);
 1162+ else buildver = osver.dwBuildNumber;
 1163+ if((osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) || (osver.dwPlatformId == VER_PLATFORM_WIN32s))
 1164+ sprintf(osstring,"Windows %u.%u.%u",osver.dwMajorVersion,osver.dwMinorVersion,buildver);
 1165+ else sprintf(osstring,"Windows NT %u.%u.%u",osver.dwMajorVersion,osver.dwMinorVersion,buildver);
 1166+ if(osver.szCSDVersion[0])
 1167+ {
 1168+ strcat(osstring,", ");
 1169+ strcat(osstring,osver.szCSDVersion);
 1170+ }
 1171+ if(((osver.dwMajorVersion == 5) && (osver.dwMinorVersion >= 1)) || (osver.dwMajorVersion >= 6))
 1172+ {
 1173+ strcat(osstring,", ");
 1174+ hKernel32 = LoadLibrary(_T("kernel32.dll"));
 1175+ iswow64 = NULL;
 1176+ if(hKernel32) iswow64 = (BOOL(WINAPI*)(HANDLE,PBOOL))GetProcAddress(hKernel32,"IsWow64Process");
 1177+ is64 = FALSE;
 1178+ if(iswow64) iswow64(GetCurrentProcess(),&is64);
 1179+ if(hKernel32) FreeLibrary(hKernel32);
 1180+ if(is64) strcat(osstring,"64-bit");
 1181+ else strcat(osstring,"32-bit");
 1182+ }
 1183+ strcat(osstring,"\r\n");
 1184+ for(i = 0; i < trace_depth-1; i++)
 1185+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1186+ WriteFile(outfile,"Windows version: ",18,&byteswritten,NULL);
 1187+ WriteFile(outfile,osstring,strlen(osstring),&byteswritten,NULL);
 1188+ for(i = 0; i < trace_depth-1; i++)
 1189+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1190+ WriteFile(outfile,"GL_VENDOR: ",12,&byteswritten,NULL);
 1191+ glstring = glGetString(GL_VENDOR);
 1192+ if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
 1193+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1194+ for(i = 0; i < trace_depth-1; i++)
 1195+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1196+ WriteFile(outfile,"GL_RENDERER: ",14,&byteswritten,NULL);
 1197+ glstring = glGetString(GL_RENDERER);
 1198+ if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
 1199+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1200+ for(i = 0; i < trace_depth-1; i++)
 1201+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1202+ WriteFile(outfile,"GL_VERSION: ",13,&byteswritten,NULL);
 1203+ glstring = glGetString(GL_VERSION);
 1204+ if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
 1205+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1206+ for(i = 0; i < trace_depth-1; i++)
 1207+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1208+ WriteFile(outfile,"GL_SHADING_LANGUAGE_VERSION: ",30,&byteswritten,NULL);
 1209+ glstring = glGetString(GL_SHADING_LANGUAGE_VERSION);
 1210+ if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
 1211+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1212+ for(i = 0; i < trace_depth-1; i++)
 1213+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1214+ WriteFile(outfile,"GL_EXTENSIONS: ",16,&byteswritten,NULL);
 1215+ glstring = glGetString(GL_EXTENSIONS);
 1216+ if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
 1217+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1218+ LeaveCriticalSection(&trace_cs);
 1219+}
 1220+#endif
\ No newline at end of file
Index: ddraw/trace.h
@@ -19,9 +19,13 @@
2020 #ifndef _TRACE_H
2121 #define _TRACE_H
2222
 23+#ifdef __cplusplus
 24+extern "C" {
 25+#endif
2326
 27+
2428 #ifdef _TRACE
25 -extern bool trace_end;
 29+extern BOOL trace_end;
2630 #define TRACE_ENTER(paramcount,...) trace_enter(__FUNCTION__,paramcount,__VA_ARGS__)
2731 #define TRACE_EXIT(argtype,arg) trace_exit(__FUNCTION__,argtype,(void*)arg)
2832 #define TRACE_VAR(var,argtype,arg) trace_var(__FUNCTION__,var,argtype,(void*)arg)
@@ -40,4 +44,8 @@
4145 #define TRACE_SYSINFO()
4246 #endif
4347
 48+#ifdef __cplusplus
 49+}
 50+#endif
 51+
4452 #endif //_TRACE_H
\ No newline at end of file