José Fonseca | 7ad4026 | 2009-09-30 17:17:12 +0100 | [diff] [blame] | 1 | ########################################################################## |
José Fonseca | 91af923 | 2009-04-13 16:15:28 +0100 | [diff] [blame] | 2 | # |
José Fonseca | 7ad4026 | 2009-09-30 17:17:12 +0100 | [diff] [blame] | 3 | # Copyright 2008-2009 VMware, Inc. |
| 4 | # All Rights Reserved. |
José Fonseca | 91af923 | 2009-04-13 16:15:28 +0100 | [diff] [blame] | 5 | # |
José Fonseca | 7ad4026 | 2009-09-30 17:17:12 +0100 | [diff] [blame] | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | # of this software and associated documentation files (the "Software"), to deal |
| 8 | # in the Software without restriction, including without limitation the rights |
| 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | # copies of the Software, and to permit persons to whom the Software is |
| 11 | # furnished to do so, subject to the following conditions: |
José Fonseca | 91af923 | 2009-04-13 16:15:28 +0100 | [diff] [blame] | 12 | # |
José Fonseca | 7ad4026 | 2009-09-30 17:17:12 +0100 | [diff] [blame] | 13 | # The above copyright notice and this permission notice shall be included in |
| 14 | # all copies or substantial portions of the Software. |
José Fonseca | 91af923 | 2009-04-13 16:15:28 +0100 | [diff] [blame] | 15 | # |
José Fonseca | 7ad4026 | 2009-09-30 17:17:12 +0100 | [diff] [blame] | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | # THE SOFTWARE. |
José Fonseca | 91af923 | 2009-04-13 16:15:28 +0100 | [diff] [blame] | 23 | # |
José Fonseca | 7ad4026 | 2009-09-30 17:17:12 +0100 | [diff] [blame] | 24 | ##########################################################################/ |
José Fonseca | 91af923 | 2009-04-13 16:15:28 +0100 | [diff] [blame] | 25 | |
| 26 | """d3d.h""" |
| 27 | |
José Fonseca | f20c126 | 2010-11-25 11:39:57 +0000 | [diff] [blame] | 28 | from winapi import * |
José Fonseca | 8384ccb | 2011-05-25 10:12:02 +0100 | [diff] [blame] | 29 | from ddraw import * |
José Fonseca | 91af923 | 2009-04-13 16:15:28 +0100 | [diff] [blame] | 30 | from d3dtypes import * |
| 31 | from d3dcaps import * |
| 32 | |
José Fonseca | 8384ccb | 2011-05-25 10:12:02 +0100 | [diff] [blame] | 33 | def OutPointer(type): |
| 34 | return Out(Pointer(type), "out") |
| 35 | |
José Fonseca | 91af923 | 2009-04-13 16:15:28 +0100 | [diff] [blame] | 36 | D3DNEXT = Flags(DWORD, [ |
| 37 | "D3DNEXT_NEXT", |
| 38 | "D3DNEXT_HEAD", |
| 39 | "D3DNEXT_TAIL", |
| 40 | ]) |
| 41 | |
| 42 | D3DDP = Flags(DWORD, [ |
| 43 | "D3DDP_WAIT", |
| 44 | "D3DDP_OUTOFORDER", |
| 45 | "D3DDP_DONOTCLIP", |
| 46 | "D3DDP_DONOTUPDATEEXTENTS", |
| 47 | "D3DDP_DONOTLIGHT", |
| 48 | ]) |
| 49 | |
| 50 | HRESULT = Enum("HRESULT", [ |
| 51 | "D3D_OK", |
| 52 | "D3DERR_BADMAJORVERSION", |
| 53 | "D3DERR_BADMINORVERSION", |
| 54 | "D3DERR_INVALID_DEVICE", |
| 55 | "D3DERR_INITFAILED", |
| 56 | "D3DERR_DEVICEAGGREGATED", |
| 57 | "D3DERR_EXECUTE_CREATE_FAILED", |
| 58 | "D3DERR_EXECUTE_DESTROY_FAILED", |
| 59 | "D3DERR_EXECUTE_LOCK_FAILED", |
| 60 | "D3DERR_EXECUTE_UNLOCK_FAILED", |
| 61 | "D3DERR_EXECUTE_LOCKED", |
| 62 | "D3DERR_EXECUTE_NOT_LOCKED", |
| 63 | "D3DERR_EXECUTE_FAILED", |
| 64 | "D3DERR_EXECUTE_CLIPPED_FAILED", |
| 65 | "D3DERR_TEXTURE_NO_SUPPORT", |
| 66 | "D3DERR_TEXTURE_CREATE_FAILED", |
| 67 | "D3DERR_TEXTURE_DESTROY_FAILED", |
| 68 | "D3DERR_TEXTURE_LOCK_FAILED", |
| 69 | "D3DERR_TEXTURE_UNLOCK_FAILED", |
| 70 | "D3DERR_TEXTURE_LOAD_FAILED", |
| 71 | "D3DERR_TEXTURE_SWAP_FAILED", |
| 72 | "D3DERR_TEXTURE_LOCKED", |
| 73 | "D3DERR_TEXTURE_NOT_LOCKED", |
| 74 | "D3DERR_TEXTURE_GETSURF_FAILED", |
| 75 | "D3DERR_MATRIX_CREATE_FAILED", |
| 76 | "D3DERR_MATRIX_DESTROY_FAILED", |
| 77 | "D3DERR_MATRIX_SETDATA_FAILED", |
| 78 | "D3DERR_MATRIX_GETDATA_FAILED", |
| 79 | "D3DERR_SETVIEWPORTDATA_FAILED", |
| 80 | "D3DERR_INVALIDCURRENTVIEWPORT", |
| 81 | "D3DERR_INVALIDPRIMITIVETYPE", |
| 82 | "D3DERR_INVALIDVERTEXTYPE", |
| 83 | "D3DERR_TEXTURE_BADSIZE", |
| 84 | "D3DERR_INVALIDRAMPTEXTURE", |
| 85 | "D3DERR_MATERIAL_CREATE_FAILED", |
| 86 | "D3DERR_MATERIAL_DESTROY_FAILED", |
| 87 | "D3DERR_MATERIAL_SETDATA_FAILED", |
| 88 | "D3DERR_MATERIAL_GETDATA_FAILED", |
| 89 | "D3DERR_INVALIDPALETTE", |
| 90 | "D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY", |
| 91 | "D3DERR_ZBUFF_NEEDS_VIDEOMEMORY", |
| 92 | "D3DERR_SURFACENOTINVIDMEM", |
| 93 | "D3DERR_LIGHT_SET_FAILED", |
| 94 | "D3DERR_LIGHTHASVIEWPORT", |
| 95 | "D3DERR_LIGHTNOTINTHISVIEWPORT", |
| 96 | "D3DERR_SCENE_IN_SCENE", |
| 97 | "D3DERR_SCENE_NOT_IN_SCENE", |
| 98 | "D3DERR_SCENE_BEGIN_FAILED", |
| 99 | "D3DERR_SCENE_END_FAILED", |
| 100 | "D3DERR_INBEGIN", |
| 101 | "D3DERR_NOTINBEGIN", |
| 102 | "D3DERR_NOVIEWPORTS", |
| 103 | "D3DERR_VIEWPORTDATANOTSET", |
| 104 | "D3DERR_VIEWPORTHASNODEVICE", |
| 105 | "D3DERR_NOCURRENTVIEWPORT", |
| 106 | "D3DERR_INVALIDVERTEXFORMAT", |
| 107 | "D3DERR_COLORKEYATTACHED", |
| 108 | "D3DERR_VERTEXBUFFEROPTIMIZED", |
| 109 | "D3DERR_VBUF_CREATE_FAILED", |
| 110 | "D3DERR_VERTEXBUFFERLOCKED", |
| 111 | "D3DERR_VERTEXBUFFERUNLOCKFAILED", |
| 112 | "D3DERR_ZBUFFER_NOTPRESENT", |
| 113 | "D3DERR_STENCILBUFFER_NOTPRESENT", |
| 114 | "D3DERR_WRONGTEXTUREFORMAT", |
| 115 | "D3DERR_UNSUPPORTEDCOLOROPERATION", |
| 116 | "D3DERR_UNSUPPORTEDCOLORARG", |
| 117 | "D3DERR_UNSUPPORTEDALPHAOPERATION", |
| 118 | "D3DERR_UNSUPPORTEDALPHAARG", |
| 119 | "D3DERR_TOOMANYOPERATIONS", |
| 120 | "D3DERR_CONFLICTINGTEXTUREFILTER", |
| 121 | "D3DERR_UNSUPPORTEDFACTORVALUE", |
| 122 | "D3DERR_CONFLICTINGRENDERSTATE", |
| 123 | "D3DERR_UNSUPPORTEDTEXTUREFILTER", |
| 124 | "D3DERR_TOOMANYPRIMITIVES", |
| 125 | "D3DERR_INVALIDMATRIX", |
| 126 | "D3DERR_TOOMANYVERTICES", |
| 127 | "D3DERR_CONFLICTINGTEXTUREPALETTE", |
| 128 | "D3DERR_INVALIDSTATEBLOCK", |
| 129 | "D3DERR_INBEGINSTATEBLOCK", |
| 130 | "D3DERR_NOTINBEGINSTATEBLOCK", |
| 131 | ]) |
| 132 | |
| 133 | IDirect3D = Interface("IDirect3D", IUnknown) |
| 134 | IDirect3D2 = Interface("IDirect3D2", IUnknown) |
| 135 | IDirect3D3 = Interface("IDirect3D3", IUnknown) |
| 136 | IDirect3D7 = Interface("IDirect3D7", IUnknown) |
| 137 | IDirect3DDevice = Interface("IDirect3DDevice", IUnknown) |
| 138 | IDirect3DDevice2 = Interface("IDirect3DDevice2", IUnknown) |
| 139 | IDirect3DDevice3 = Interface("IDirect3DDevice3", IUnknown) |
| 140 | IDirect3DDevice7 = Interface("IDirect3DDevice7", IUnknown) |
| 141 | IDirect3DExecuteBuffer = Interface("IDirect3DExecuteBuffer", IUnknown) |
| 142 | IDirect3DLight = Interface("IDirect3DLight", IUnknown) |
| 143 | IDirect3DMaterial = Interface("IDirect3DMaterial", IUnknown) |
| 144 | IDirect3DMaterial2 = Interface("IDirect3DMaterial2", IUnknown) |
| 145 | IDirect3DMaterial3 = Interface("IDirect3DMaterial3", IUnknown) |
| 146 | IDirect3DTexture = Interface("IDirect3DTexture", IUnknown) |
| 147 | IDirect3DTexture2 = Interface("IDirect3DTexture2", IUnknown) |
| 148 | IDirect3DViewport = Interface("IDirect3DViewport", IUnknown) |
| 149 | IDirect3DViewport2 = Interface("IDirect3DViewport2", IDirect3DViewport) |
| 150 | IDirect3DViewport3 = Interface("IDirect3DViewport3", IDirect3DViewport2) |
| 151 | IDirect3DVertexBuffer = Interface("IDirect3DVertexBuffer", IUnknown) |
| 152 | IDirect3DVertexBuffer7 = Interface("IDirect3DVertexBuffer7", IUnknown) |
| 153 | |
| 154 | LPUNKNOWN = WrapPointer(IUnknown) |
| 155 | |
| 156 | LPDIRECT3D = WrapPointer(IDirect3D) |
| 157 | LPDIRECT3DDEVICE = WrapPointer(IDirect3DDevice) |
| 158 | LPDIRECT3DEXECUTEBUFFER = WrapPointer(IDirect3DExecuteBuffer) |
| 159 | LPDIRECT3DLIGHT = WrapPointer(IDirect3DLight) |
| 160 | LPDIRECT3DMATERIAL = WrapPointer(IDirect3DMaterial) |
| 161 | LPDIRECT3DTEXTURE = WrapPointer(IDirect3DTexture) |
| 162 | LPDIRECT3DVIEWPORT = WrapPointer(IDirect3DViewport) |
| 163 | |
| 164 | LPDIRECT3D2 = WrapPointer(IDirect3D2) |
| 165 | LPDIRECT3DDEVICE2 = WrapPointer(IDirect3DDevice2) |
| 166 | LPDIRECT3DMATERIAL2 = WrapPointer(IDirect3DMaterial2) |
| 167 | LPDIRECT3DTEXTURE2 = WrapPointer(IDirect3DTexture2) |
| 168 | LPDIRECT3DVIEWPORT2 = WrapPointer(IDirect3DViewport2) |
| 169 | |
| 170 | LPDIRECT3D3 = WrapPointer(IDirect3D3) |
| 171 | LPDIRECT3DDEVICE3 = WrapPointer(IDirect3DDevice3) |
| 172 | LPDIRECT3DMATERIAL3 = WrapPointer(IDirect3DMaterial3) |
| 173 | LPDIRECT3DVIEWPORT3 = WrapPointer(IDirect3DViewport3) |
| 174 | LPDIRECT3DVERTEXBUFFER = WrapPointer(IDirect3DVertexBuffer) |
| 175 | |
| 176 | LPDIRECT3D7 = WrapPointer(IDirect3D7) |
| 177 | LPDIRECT3DDEVICE7 = WrapPointer(IDirect3DDevice7) |
| 178 | LPDIRECT3DVERTEXBUFFER7 = WrapPointer(IDirect3DVertexBuffer7) |
| 179 | |
| 180 | IDirect3D.methods += [ |
| 181 | Method(HRESULT, "Initialize", [REFCLSID]), |
| 182 | Method(HRESULT, "EnumDevices", [LPD3DENUMDEVICESCALLBACK,LPVOID]), |
| 183 | Method(HRESULT, "CreateLight", [OutPointer(LPDIRECT3DLIGHT),LPUNKNOWN]), |
| 184 | Method(HRESULT, "CreateMaterial", [OutPointer(LPDIRECT3DMATERIAL),LPUNKNOWN]), |
| 185 | Method(HRESULT, "CreateViewport", [OutPointer(LPDIRECT3DVIEWPORT),LPUNKNOWN]), |
| 186 | Method(HRESULT, "FindDevice", [LPD3DFINDDEVICESEARCH,LPD3DFINDDEVICERESULT]), |
| 187 | ] |
| 188 | |
| 189 | IDirect3D2.methods += [ |
| 190 | Method(HRESULT, "EnumDevices", [LPD3DENUMDEVICESCALLBACK,LPVOID]), |
| 191 | Method(HRESULT, "CreateLight", [OutPointer(LPDIRECT3DLIGHT),LPUNKNOWN]), |
| 192 | Method(HRESULT, "CreateMaterial", [OutPointer(LPDIRECT3DMATERIAL2),LPUNKNOWN]), |
| 193 | Method(HRESULT, "CreateViewport", [OutPointer(LPDIRECT3DVIEWPORT2),LPUNKNOWN]), |
| 194 | Method(HRESULT, "FindDevice", [LPD3DFINDDEVICESEARCH,LPD3DFINDDEVICERESULT]), |
| 195 | Method(HRESULT, "CreateDevice", [REFCLSID,LPDIRECTDRAWSURFACE,OutPointer(LPDIRECT3DDEVICE2)]), |
| 196 | ] |
| 197 | |
| 198 | IDirect3D3.methods += [ |
| 199 | Method(HRESULT, "EnumDevices", [LPD3DENUMDEVICESCALLBACK,LPVOID]), |
| 200 | Method(HRESULT, "CreateLight", [OutPointer(LPDIRECT3DLIGHT),LPUNKNOWN]), |
| 201 | Method(HRESULT, "CreateMaterial", [OutPointer(LPDIRECT3DMATERIAL3),LPUNKNOWN]), |
| 202 | Method(HRESULT, "CreateViewport", [OutPointer(LPDIRECT3DVIEWPORT3),LPUNKNOWN]), |
| 203 | Method(HRESULT, "FindDevice", [LPD3DFINDDEVICESEARCH,LPD3DFINDDEVICERESULT]), |
| 204 | Method(HRESULT, "CreateDevice", [REFCLSID,LPDIRECTDRAWSURFACE4,OutPointer(LPDIRECT3DDEVICE3),LPUNKNOWN]), |
| 205 | Method(HRESULT, "CreateVertexBuffer", [LPD3DVERTEXBUFFERDESC,OutPointer(LPDIRECT3DVERTEXBUFFER),DWORD,LPUNKNOWN]), |
| 206 | Method(HRESULT, "EnumZBufferFormats", [REFCLSID,LPD3DENUMPIXELFORMATSCALLBACK,LPVOID]), |
| 207 | Method(HRESULT, "EvictManagedTextures", []), |
| 208 | ] |
| 209 | |
| 210 | IDirect3D7.methods += [ |
| 211 | Method(HRESULT, "EnumDevices", [LPD3DENUMDEVICESCALLBACK7,LPVOID]), |
| 212 | Method(HRESULT, "CreateDevice", [REFCLSID,LPDIRECTDRAWSURFACE7,OutPointer(LPDIRECT3DDEVICE7)]), |
| 213 | Method(HRESULT, "CreateVertexBuffer", [LPD3DVERTEXBUFFERDESC,OutPointer(LPDIRECT3DVERTEXBUFFER7),DWORD]), |
| 214 | Method(HRESULT, "EnumZBufferFormats", [REFCLSID,LPD3DENUMPIXELFORMATSCALLBACK,LPVOID]), |
| 215 | Method(HRESULT, "EvictManagedTextures", []), |
| 216 | ] |
| 217 | |
| 218 | IDirect3DDevice.methods += [ |
| 219 | Method(HRESULT, "Initialize", [LPDIRECT3D,LPGUID,LPD3DDEVICEDESC]), |
| 220 | Method(HRESULT, "GetCaps", [LPD3DDEVICEDESC,LPD3DDEVICEDESC]), |
| 221 | Method(HRESULT, "SwapTextureHandles", [LPDIRECT3DTEXTURE,LPDIRECT3DTEXTURE]), |
| 222 | Method(HRESULT, "CreateExecuteBuffer", [LPD3DEXECUTEBUFFERDESC,OutPointer(LPDIRECT3DEXECUTEBUFFER),LPUNKNOWN]), |
| 223 | Method(HRESULT, "GetStats", [LPD3DSTATS]), |
| 224 | Method(HRESULT, "Execute", [LPDIRECT3DEXECUTEBUFFER,LPDIRECT3DVIEWPORT,DWORD]), |
| 225 | Method(HRESULT, "AddViewport", [LPDIRECT3DVIEWPORT]), |
| 226 | Method(HRESULT, "DeleteViewport", [LPDIRECT3DVIEWPORT]), |
| 227 | Method(HRESULT, "NextViewport", [LPDIRECT3DVIEWPORT,OutPointer(LPDIRECT3DVIEWPORT),DWORD]), |
| 228 | Method(HRESULT, "Pick", [LPDIRECT3DEXECUTEBUFFER,LPDIRECT3DVIEWPORT,DWORD,LPD3DRECT]), |
| 229 | Method(HRESULT, "GetPickRecords", [LPDWORD,LPD3DPICKRECORD]), |
| 230 | Method(HRESULT, "EnumTextureFormats", [LPD3DENUMTEXTUREFORMATSCALLBACK,LPVOID]), |
| 231 | Method(HRESULT, "CreateMatrix", [LPD3DMATRIXHANDLE]), |
José Fonseca | 784c010 | 2011-05-25 21:03:40 +0100 | [diff] [blame] | 232 | Method(HRESULT, "SetMatrix", [D3DMATRIXHANDLE,Const(LPD3DMATRIX)]), |
José Fonseca | 91af923 | 2009-04-13 16:15:28 +0100 | [diff] [blame] | 233 | Method(HRESULT, "GetMatrix", [D3DMATRIXHANDLE,LPD3DMATRIX]), |
| 234 | Method(HRESULT, "DeleteMatrix", [D3DMATRIXHANDLE]), |
| 235 | Method(HRESULT, "BeginScene", []), |
| 236 | Method(HRESULT, "EndScene", []), |
| 237 | Method(HRESULT, "GetDirect3D", [OutPointer(LPDIRECT3D)]), |
| 238 | ] |
| 239 | |
| 240 | IDirect3DDevice2.methods += [ |
| 241 | Method(HRESULT, "GetCaps", [LPD3DDEVICEDESC,LPD3DDEVICEDESC]), |
| 242 | Method(HRESULT, "SwapTextureHandles", [LPDIRECT3DTEXTURE2,LPDIRECT3DTEXTURE2]), |
| 243 | Method(HRESULT, "GetStats", [LPD3DSTATS]), |
| 244 | Method(HRESULT, "AddViewport", [LPDIRECT3DVIEWPORT2]), |
| 245 | Method(HRESULT, "DeleteViewport", [LPDIRECT3DVIEWPORT2]), |
| 246 | Method(HRESULT, "NextViewport", [LPDIRECT3DVIEWPORT2,OutPointer(LPDIRECT3DVIEWPORT2),DWORD]), |
| 247 | Method(HRESULT, "EnumTextureFormats", [LPD3DENUMTEXTUREFORMATSCALLBACK,LPVOID]), |
| 248 | Method(HRESULT, "BeginScene", []), |
| 249 | Method(HRESULT, "EndScene", []), |
| 250 | Method(HRESULT, "GetDirect3D", [OutPointer(LPDIRECT3D2)]), |
| 251 | Method(HRESULT, "SetCurrentViewport", [LPDIRECT3DVIEWPORT2]), |
| 252 | Method(HRESULT, "GetCurrentViewport", [OutPointer(LPDIRECT3DVIEWPORT2)]), |
| 253 | Method(HRESULT, "SetRenderTarget", [LPDIRECTDRAWSURFACE,DWORD]), |
| 254 | Method(HRESULT, "GetRenderTarget", [OutPointer(LPDIRECTDRAWSURFACE)]), |
| 255 | Method(HRESULT, "Begin", [D3DPRIMITIVETYPE,D3DVERTEXTYPE,DWORD]), |
| 256 | Method(HRESULT, "BeginIndexed", [D3DPRIMITIVETYPE,D3DVERTEXTYPE,LPVOID,DWORD,DWORD]), |
| 257 | Method(HRESULT, "Vertex", [LPVOID]), |
| 258 | Method(HRESULT, "Index", [WORD]), |
| 259 | Method(HRESULT, "End", [DWORD]), |
| 260 | Method(HRESULT, "GetRenderState", [D3DRENDERSTATETYPE,LPDWORD]), |
| 261 | Method(HRESULT, "SetRenderState", [D3DRENDERSTATETYPE,DWORD]), |
| 262 | Method(HRESULT, "GetLightState", [D3DLIGHTSTATETYPE,LPDWORD]), |
| 263 | Method(HRESULT, "SetLightState", [D3DLIGHTSTATETYPE,DWORD]), |
| 264 | Method(HRESULT, "SetTransform", [D3DTRANSFORMSTATETYPE,LPD3DMATRIX]), |
| 265 | Method(HRESULT, "GetTransform", [D3DTRANSFORMSTATETYPE,LPD3DMATRIX]), |
| 266 | Method(HRESULT, "MultiplyTransform", [D3DTRANSFORMSTATETYPE,LPD3DMATRIX]), |
| 267 | Method(HRESULT, "DrawPrimitive", [D3DPRIMITIVETYPE,D3DVERTEXTYPE,LPVOID,DWORD,DWORD]), |
| 268 | Method(HRESULT, "DrawIndexedPrimitive", [D3DPRIMITIVETYPE,D3DVERTEXTYPE,LPVOID,DWORD,LPWORD,DWORD,DWORD]), |
| 269 | Method(HRESULT, "SetClipStatus", [LPD3DCLIPSTATUS]), |
| 270 | Method(HRESULT, "GetClipStatus", [LPD3DCLIPSTATUS]), |
| 271 | ] |
| 272 | |
| 273 | IDirect3DDevice3.methods += [ |
| 274 | Method(HRESULT, "GetCaps", [LPD3DDEVICEDESC,LPD3DDEVICEDESC]), |
| 275 | Method(HRESULT, "GetStats", [LPD3DSTATS]), |
| 276 | Method(HRESULT, "AddViewport", [LPDIRECT3DVIEWPORT3]), |
| 277 | Method(HRESULT, "DeleteViewport", [LPDIRECT3DVIEWPORT3]), |
| 278 | Method(HRESULT, "NextViewport", [LPDIRECT3DVIEWPORT3,OutPointer(LPDIRECT3DVIEWPORT3),DWORD]), |
| 279 | Method(HRESULT, "EnumTextureFormats", [LPD3DENUMPIXELFORMATSCALLBACK,LPVOID]), |
| 280 | Method(HRESULT, "BeginScene", []), |
| 281 | Method(HRESULT, "EndScene", []), |
| 282 | Method(HRESULT, "GetDirect3D", [OutPointer(LPDIRECT3D3)]), |
| 283 | Method(HRESULT, "SetCurrentViewport", [LPDIRECT3DVIEWPORT3]), |
| 284 | Method(HRESULT, "GetCurrentViewport", [OutPointer(LPDIRECT3DVIEWPORT3)]), |
| 285 | Method(HRESULT, "SetRenderTarget", [LPDIRECTDRAWSURFACE4,DWORD]), |
| 286 | Method(HRESULT, "GetRenderTarget", [OutPointer(LPDIRECTDRAWSURFACE4)]), |
| 287 | Method(HRESULT, "Begin", [D3DPRIMITIVETYPE,DWORD,DWORD]), |
| 288 | Method(HRESULT, "BeginIndexed", [D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD]), |
| 289 | Method(HRESULT, "Vertex", [LPVOID]), |
| 290 | Method(HRESULT, "Index", [WORD]), |
| 291 | Method(HRESULT, "End", [DWORD]), |
| 292 | Method(HRESULT, "GetRenderState", [D3DRENDERSTATETYPE,LPDWORD]), |
| 293 | Method(HRESULT, "SetRenderState", [D3DRENDERSTATETYPE,DWORD]), |
| 294 | Method(HRESULT, "GetLightState", [D3DLIGHTSTATETYPE,LPDWORD]), |
| 295 | Method(HRESULT, "SetLightState", [D3DLIGHTSTATETYPE,DWORD]), |
| 296 | Method(HRESULT, "SetTransform", [D3DTRANSFORMSTATETYPE,LPD3DMATRIX]), |
| 297 | Method(HRESULT, "GetTransform", [D3DTRANSFORMSTATETYPE,LPD3DMATRIX]), |
| 298 | Method(HRESULT, "MultiplyTransform", [D3DTRANSFORMSTATETYPE,LPD3DMATRIX]), |
| 299 | Method(HRESULT, "DrawPrimitive", [D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD]), |
| 300 | Method(HRESULT, "DrawIndexedPrimitive", [D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,LPWORD,DWORD,DWORD]), |
| 301 | Method(HRESULT, "SetClipStatus", [LPD3DCLIPSTATUS]), |
| 302 | Method(HRESULT, "GetClipStatus", [LPD3DCLIPSTATUS]), |
| 303 | Method(HRESULT, "DrawPrimitiveStrided", [D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,DWORD]), |
| 304 | Method(HRESULT, "DrawIndexedPrimitiveStrided", [D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPWORD,DWORD,DWORD]), |
| 305 | Method(HRESULT, "DrawPrimitiveVB", [D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER,DWORD,DWORD,DWORD]), |
| 306 | Method(HRESULT, "DrawIndexedPrimitiveVB", [D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER,LPWORD,DWORD,DWORD]), |
| 307 | Method(HRESULT, "ComputeSphereVisibility", [LPD3DVECTOR,LPD3DVALUE,DWORD,DWORD,LPDWORD]), |
| 308 | Method(HRESULT, "GetTexture", [DWORD,OutPointer(LPDIRECT3DTEXTURE2)]), |
| 309 | Method(HRESULT, "SetTexture", [DWORD,LPDIRECT3DTEXTURE2]), |
| 310 | Method(HRESULT, "GetTextureStageState", [DWORD,D3DTEXTURESTAGESTATETYPE,LPDWORD]), |
| 311 | Method(HRESULT, "SetTextureStageState", [DWORD,D3DTEXTURESTAGESTATETYPE,DWORD]), |
| 312 | Method(HRESULT, "ValidateDevice", [LPDWORD]), |
| 313 | ] |
| 314 | |
| 315 | IDirect3DDevice7.methods += [ |
| 316 | Method(HRESULT, "GetCaps", [LPD3DDEVICEDESC7]), |
| 317 | Method(HRESULT, "EnumTextureFormats", [LPD3DENUMPIXELFORMATSCALLBACK,LPVOID]), |
| 318 | Method(HRESULT, "BeginScene", []), |
| 319 | Method(HRESULT, "EndScene", []), |
| 320 | Method(HRESULT, "GetDirect3D", [OutPointer(LPDIRECT3D7)]), |
| 321 | Method(HRESULT, "SetRenderTarget", [LPDIRECTDRAWSURFACE7,DWORD]), |
| 322 | Method(HRESULT, "GetRenderTarget", [OutPointer(LPDIRECTDRAWSURFACE7)]), |
| 323 | Method(HRESULT, "Clear", [DWORD,LPD3DRECT,DWORD,D3DCOLOR,D3DVALUE,DWORD]), |
| 324 | Method(HRESULT, "SetTransform", [D3DTRANSFORMSTATETYPE,LPD3DMATRIX]), |
| 325 | Method(HRESULT, "GetTransform", [D3DTRANSFORMSTATETYPE,LPD3DMATRIX]), |
| 326 | Method(HRESULT, "SetViewport", [LPD3DVIEWPORT7]), |
| 327 | Method(HRESULT, "MultiplyTransform", [D3DTRANSFORMSTATETYPE,LPD3DMATRIX]), |
| 328 | Method(HRESULT, "GetViewport", [LPD3DVIEWPORT7]), |
| 329 | Method(HRESULT, "SetMaterial", [LPD3DMATERIAL7]), |
| 330 | Method(HRESULT, "GetMaterial", [LPD3DMATERIAL7]), |
| 331 | Method(HRESULT, "SetLight", [DWORD,LPD3DLIGHT7]), |
| 332 | Method(HRESULT, "GetLight", [DWORD,LPD3DLIGHT7]), |
| 333 | Method(HRESULT, "SetRenderState", [D3DRENDERSTATETYPE,DWORD]), |
| 334 | Method(HRESULT, "GetRenderState", [D3DRENDERSTATETYPE,LPDWORD]), |
| 335 | Method(HRESULT, "BeginStateBlock", []), |
| 336 | Method(HRESULT, "EndStateBlock", [LPDWORD]), |
| 337 | Method(HRESULT, "PreLoad", [LPDIRECTDRAWSURFACE7]), |
| 338 | Method(HRESULT, "DrawPrimitive", [D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,DWORD]), |
| 339 | Method(HRESULT, "DrawIndexedPrimitive", [D3DPRIMITIVETYPE,DWORD,LPVOID,DWORD,LPWORD,DWORD,DWORD]), |
| 340 | Method(HRESULT, "SetClipStatus", [LPD3DCLIPSTATUS]), |
| 341 | Method(HRESULT, "GetClipStatus", [LPD3DCLIPSTATUS]), |
| 342 | Method(HRESULT, "DrawPrimitiveStrided", [D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,DWORD]), |
| 343 | Method(HRESULT, "DrawIndexedPrimitiveStrided", [D3DPRIMITIVETYPE,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPWORD,DWORD,DWORD]), |
| 344 | Method(HRESULT, "DrawPrimitiveVB", [D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER7,DWORD,DWORD,DWORD]), |
| 345 | Method(HRESULT, "DrawIndexedPrimitiveVB", [D3DPRIMITIVETYPE,LPDIRECT3DVERTEXBUFFER7,DWORD,DWORD,LPWORD,DWORD,DWORD]), |
| 346 | Method(HRESULT, "ComputeSphereVisibility", [LPD3DVECTOR,LPD3DVALUE,DWORD,DWORD,LPDWORD]), |
| 347 | Method(HRESULT, "GetTexture", [DWORD,OutPointer(LPDIRECTDRAWSURFACE7)]), |
| 348 | Method(HRESULT, "SetTexture", [DWORD,LPDIRECTDRAWSURFACE7]), |
| 349 | Method(HRESULT, "GetTextureStageState", [DWORD,D3DTEXTURESTAGESTATETYPE,LPDWORD]), |
| 350 | Method(HRESULT, "SetTextureStageState", [DWORD,D3DTEXTURESTAGESTATETYPE,DWORD]), |
| 351 | Method(HRESULT, "ValidateDevice", [LPDWORD]), |
| 352 | Method(HRESULT, "ApplyStateBlock", [DWORD]), |
| 353 | Method(HRESULT, "CaptureStateBlock", [DWORD]), |
| 354 | Method(HRESULT, "DeleteStateBlock", [DWORD]), |
| 355 | Method(HRESULT, "CreateStateBlock", [D3DSTATEBLOCKTYPE,LPDWORD]), |
| 356 | Method(HRESULT, "Load", [LPDIRECTDRAWSURFACE7,LPPOINT,LPDIRECTDRAWSURFACE7,LPRECT,DWORD]), |
| 357 | Method(HRESULT, "LightEnable", [DWORD,BOOL]), |
| 358 | Method(HRESULT, "GetLightEnable", [DWORD,OutPointer(BOOL)]), |
| 359 | Method(HRESULT, "SetClipPlane", [DWORD,OutPointer(D3DVALUE)]), |
| 360 | Method(HRESULT, "GetClipPlane", [DWORD,OutPointer(D3DVALUE)]), |
| 361 | Method(HRESULT, "GetInfo", [DWORD,LPVOID,DWORD]), |
| 362 | ] |
| 363 | |
| 364 | IDirect3DExecuteBuffer.methods += [ |
| 365 | Method(HRESULT, "Initialize", [LPDIRECT3DDEVICE,LPD3DEXECUTEBUFFERDESC]), |
| 366 | Method(HRESULT, "Lock", [LPD3DEXECUTEBUFFERDESC]), |
| 367 | Method(HRESULT, "Unlock", []), |
| 368 | Method(HRESULT, "SetExecuteData", [LPD3DEXECUTEDATA]), |
| 369 | Method(HRESULT, "GetExecuteData", [LPD3DEXECUTEDATA]), |
| 370 | Method(HRESULT, "Validate", [LPDWORD,LPD3DVALIDATECALLBACK,LPVOID,DWORD]), |
| 371 | Method(HRESULT, "Optimize", [DWORD]), |
| 372 | ] |
| 373 | |
| 374 | IDirect3DLight.methods += [ |
| 375 | Method(HRESULT, "Initialize", [LPDIRECT3D]), |
| 376 | Method(HRESULT, "SetLight", [LPD3DLIGHT]), |
| 377 | Method(HRESULT, "GetLight", [LPD3DLIGHT]), |
| 378 | ] |
| 379 | |
| 380 | IDirect3DMaterial.methods += [ |
| 381 | Method(HRESULT, "Initialize", [LPDIRECT3D]), |
| 382 | Method(HRESULT, "SetMaterial", [LPD3DMATERIAL]), |
| 383 | Method(HRESULT, "GetMaterial", [LPD3DMATERIAL]), |
| 384 | Method(HRESULT, "GetHandle", [LPDIRECT3DDEVICE,LPD3DMATERIALHANDLE]), |
| 385 | Method(HRESULT, "Reserve", []), |
| 386 | Method(HRESULT, "Unreserve", []), |
| 387 | ] |
| 388 | |
| 389 | IDirect3DMaterial2.methods += [ |
| 390 | Method(HRESULT, "SetMaterial", [LPD3DMATERIAL]), |
| 391 | Method(HRESULT, "GetMaterial", [LPD3DMATERIAL]), |
| 392 | Method(HRESULT, "GetHandle", [LPDIRECT3DDEVICE2,LPD3DMATERIALHANDLE]), |
| 393 | ] |
| 394 | |
| 395 | IDirect3DMaterial3.methods += [ |
| 396 | Method(HRESULT, "SetMaterial", [LPD3DMATERIAL]), |
| 397 | Method(HRESULT, "GetMaterial", [LPD3DMATERIAL]), |
| 398 | Method(HRESULT, "GetHandle", [LPDIRECT3DDEVICE3,LPD3DMATERIALHANDLE]), |
| 399 | ] |
| 400 | |
| 401 | IDirect3DTexture.methods += [ |
| 402 | Method(HRESULT, "Initialize", [LPDIRECT3DDEVICE,LPDIRECTDRAWSURFACE]), |
| 403 | Method(HRESULT, "GetHandle", [LPDIRECT3DDEVICE,LPD3DTEXTUREHANDLE]), |
| 404 | Method(HRESULT, "PaletteChanged", [DWORD,DWORD]), |
| 405 | Method(HRESULT, "Load", [LPDIRECT3DTEXTURE]), |
| 406 | Method(HRESULT, "Unload", []), |
| 407 | ] |
| 408 | |
| 409 | IDirect3DTexture2.methods += [ |
| 410 | Method(HRESULT, "GetHandle", [LPDIRECT3DDEVICE2,LPD3DTEXTUREHANDLE]), |
| 411 | Method(HRESULT, "PaletteChanged", [DWORD,DWORD]), |
| 412 | Method(HRESULT, "Load", [LPDIRECT3DTEXTURE2]), |
| 413 | ] |
| 414 | |
| 415 | IDirect3DViewport.methods += [ |
| 416 | Method(HRESULT, "Initialize", [LPDIRECT3D]), |
| 417 | Method(HRESULT, "GetViewport", [LPD3DVIEWPORT]), |
| 418 | Method(HRESULT, "SetViewport", [LPD3DVIEWPORT]), |
| 419 | Method(HRESULT, "TransformVertices", [DWORD,LPD3DTRANSFORMDATA,DWORD,LPDWORD]), |
| 420 | Method(HRESULT, "LightElements", [DWORD,LPD3DLIGHTDATA]), |
| 421 | Method(HRESULT, "SetBackground", [D3DMATERIALHANDLE]), |
| 422 | Method(HRESULT, "GetBackground", [LPD3DMATERIALHANDLE,LPBOOL]), |
| 423 | Method(HRESULT, "SetBackgroundDepth", [LPDIRECTDRAWSURFACE]), |
| 424 | Method(HRESULT, "GetBackgroundDepth", [OutPointer(LPDIRECTDRAWSURFACE),LPBOOL]), |
| 425 | Method(HRESULT, "Clear", [DWORD,LPD3DRECT,DWORD]), |
| 426 | Method(HRESULT, "AddLight", [LPDIRECT3DLIGHT]), |
| 427 | Method(HRESULT, "DeleteLight", [LPDIRECT3DLIGHT]), |
| 428 | Method(HRESULT, "NextLight", [LPDIRECT3DLIGHT,OutPointer(LPDIRECT3DLIGHT),DWORD]), |
| 429 | ] |
| 430 | |
| 431 | IDirect3DViewport2.methods += [ |
| 432 | Method(HRESULT, "GetViewport2", [LPD3DVIEWPORT2]), |
| 433 | Method(HRESULT, "SetViewport2", [LPD3DVIEWPORT2]), |
| 434 | ] |
| 435 | |
| 436 | IDirect3DViewport3.methods += [ |
| 437 | Method(HRESULT, "SetBackgroundDepth2", [LPDIRECTDRAWSURFACE4]), |
| 438 | Method(HRESULT, "GetBackgroundDepth2", [OutPointer(LPDIRECTDRAWSURFACE4),LPBOOL]), |
| 439 | Method(HRESULT, "Clear2", [DWORD,LPD3DRECT,DWORD,D3DCOLOR,D3DVALUE,DWORD]), |
| 440 | ] |
| 441 | |
| 442 | IDirect3DVertexBuffer.methods += [ |
| 443 | Method(HRESULT, "Lock", [DWORD,OutPointer(LPVOID),LPDWORD]), |
| 444 | Method(HRESULT, "Unlock", []), |
| 445 | Method(HRESULT, "ProcessVertices", [DWORD,DWORD,DWORD,LPDIRECT3DVERTEXBUFFER,DWORD,LPDIRECT3DDEVICE3,DWORD]), |
| 446 | Method(HRESULT, "GetVertexBufferDesc", [LPD3DVERTEXBUFFERDESC]), |
| 447 | Method(HRESULT, "Optimize", [LPDIRECT3DDEVICE3,DWORD]), |
| 448 | ] |
| 449 | |
| 450 | IDirect3DVertexBuffer7.methods += [ |
| 451 | Method(HRESULT, "Lock", [DWORD,OutPointer(LPVOID),LPDWORD]), |
| 452 | Method(HRESULT, "Unlock", []), |
| 453 | Method(HRESULT, "ProcessVertices", [DWORD,DWORD,DWORD,LPDIRECT3DVERTEXBUFFER7,DWORD,LPDIRECT3DDEVICE7,DWORD]), |
| 454 | Method(HRESULT, "GetVertexBufferDesc", [LPD3DVERTEXBUFFERDESC]), |
| 455 | Method(HRESULT, "Optimize", [LPDIRECT3DDEVICE7,DWORD]), |
| 456 | Method(HRESULT, "ProcessVerticesStrided", [DWORD,DWORD,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPDIRECT3DDEVICE7,DWORD]), |
| 457 | ] |
José Fonseca | 8384ccb | 2011-05-25 10:12:02 +0100 | [diff] [blame] | 458 | |
| 459 | interfaces = [ |
| 460 | IDirectDraw, |
| 461 | IDirectDraw2, |
| 462 | IDirectDraw4, |
| 463 | IDirectDraw7, |
| 464 | IDirect3D, |
| 465 | IDirect3D2, |
| 466 | IDirect3D3, |
| 467 | IDirect3D7, |
| 468 | ] |
| 469 | |
| 470 | ddraw.add_interfaces(interfaces) |
| 471 | |
| 472 | |
| 473 | class DDrawTracer(DllTracer): |
| 474 | |
José Fonseca | bb8760b | 2011-05-25 23:21:18 +0100 | [diff] [blame] | 475 | def trace_function_impl_body(self, function): |
| 476 | if function.name in ('AcquireDDThreadLock', 'ReleaseDDThreadLock'): |
| 477 | self.dispatch_function(function) |
| 478 | return |
| 479 | |
| 480 | DllTracer.trace_function_impl_body(self, function) |
| 481 | |
José Fonseca | 8384ccb | 2011-05-25 10:12:02 +0100 | [diff] [blame] | 482 | def wrap_arg(self, function, arg): |
| 483 | if function.name == 'DirectDrawCreateEx' and arg.name == 'lplpDD': |
| 484 | print ' if (*lplpDD) {' |
| 485 | for iface in interfaces: |
| 486 | print ' if (iid == IID_%s) {' % iface.name |
| 487 | print ' *lplpDD = (LPVOID) new Wrap%s((%s *)*lplpDD);' % (iface.name, iface.name) |
| 488 | print ' }' |
| 489 | print ' }' |
José Fonseca | 8384ccb | 2011-05-25 10:12:02 +0100 | [diff] [blame] | 490 | |
José Fonseca | bb8760b | 2011-05-25 23:21:18 +0100 | [diff] [blame] | 491 | DllTracer.wrap_arg(self, function, arg) |
José Fonseca | 8384ccb | 2011-05-25 10:12:02 +0100 | [diff] [blame] | 492 | |
| 493 | |
| 494 | if __name__ == '__main__': |
| 495 | print '#define INITGUID' |
| 496 | print '#include <windows.h>' |
| 497 | print '#include <ddraw.h>' |
| 498 | print '#include <d3d.h>' |
| 499 | print |
| 500 | print ''' |
| 501 | |
| 502 | #ifndef D3DLIGHT_PARALLELPOINT |
| 503 | #define D3DLIGHT_PARALLELPOINT (D3DLIGHTTYPE)4 |
| 504 | #endif |
| 505 | |
| 506 | #ifndef D3DLIGHT_GLSPOT |
| 507 | #define D3DLIGHT_GLSPOT (D3DLIGHTTYPE)5 |
| 508 | #endif |
| 509 | |
| 510 | ''' |
| 511 | print '#include "trace_writer.hpp"' |
| 512 | print '#include "os.hpp"' |
| 513 | print |
| 514 | tracer = DDrawTracer('ddraw.dll') |
| 515 | tracer.trace_api(ddraw) |