├── .gitignore ├── LICENSE ├── README ├── build ├── helper32.exe ├── helper64.exe ├── libqtscreen32.dll └── libqtscreen64.dll ├── directx_api ├── d3d.h ├── d3d8.h ├── d3d8caps.h ├── d3d8types.h ├── d3d9.h ├── d3d9caps.h ├── d3d9types.h ├── d3dcaps.h ├── d3dtypes.h ├── d3dx9.h ├── ddraw.h └── dxcustomtypes.h ├── helper ├── dummy_window.cpp ├── dummy_window.h ├── dx8offsets.cpp ├── dx9offsets.cpp ├── dxgi_offsets.cpp ├── dxoffsets.h ├── helper.pro ├── inject.cpp ├── inject.h └── main.cpp ├── injected_dll ├── dx10screen.cpp ├── dx11screen.cpp ├── dx8screen.cpp ├── dx9screen.cpp ├── dxgi_screen.cpp ├── dxscreen.cpp ├── dxscreen.h ├── hook.cpp ├── hook.h ├── injected_app.cpp ├── injected_app.h ├── injected_dll.pro ├── main.cpp └── opengl.cpp ├── libqtscreen ├── client.cpp ├── client.h ├── libqtscreen.pri ├── proto.h ├── saveload.h ├── screenshot_maker.cpp └── screenshot_maker.h ├── qtscreen.pro └── screener ├── main.cpp ├── screener.cpp ├── screener.h └── screener.pro /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.qbs.user 20 | *.qbs.user.* 21 | *.moc 22 | moc_*.cpp 23 | qrc_*.cpp 24 | ui_*.h 25 | Makefile* 26 | *-build-* 27 | 28 | # QtCreator 29 | 30 | *.autosave 31 | 32 | #QtCtreator Qml 33 | *.qmlproject.user 34 | *.qmlproject.user.* 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Filipp Ozinov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | What is LibQtScreen? 2 | 3 | LibQtScreen is a Qt 5 library for taking screenshots of fullscreen DirectX 4 | and OpenGL applications. It supports DirectX from 8 to 11, OpenGL, win32 5 | and win64 applications. It can be compiled with MSVC and MinGW gcc. 6 | 7 | How does it works? 8 | 9 | LibQtScreen injects dll into fullscreen applications. Injected dll intercepts 10 | DirectX and OpenGL draw functions, copy rendered frame and returns it back. 11 | 12 | How can I use it? 13 | 14 | * copy libqtscreen to your project 15 | * add include(libqtscreen/libqtscreen.pri) to your .pro file 16 | * use NQtScreen::TScreenShotMaker to make screenshot (see screener example) 17 | * you also need helper32.exe, helper64.exe, libqtscreen32.dll and libqtscreen64.dll. 18 | You can build it yourself (injected_dll) or take pre-built dlls (build directory). 19 | Put them near your applications executable. 20 | 21 | Why do I need helper32.exe, helper64.exe, libqtscreen32.dll and libqtscreen64.dll? 22 | 23 | Dll is required to inject code into directx and opengl applications. You need one 24 | for 32bit and one for 64bit process. Helper64.exe is required to be able to inject 25 | 64bit dll into 64bit process from your 32bit compiled program, and helper32.exe is 26 | required to inject 32bit dll into 32bit process from your 64bit compiled program. 27 | -------------------------------------------------------------------------------- /build/helper32.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bakwc/LibQtScreen/9bf1e200465797807b86a6d20c43f3fc8cc9e59f/build/helper32.exe -------------------------------------------------------------------------------- /build/helper64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bakwc/LibQtScreen/9bf1e200465797807b86a6d20c43f3fc8cc9e59f/build/helper64.exe -------------------------------------------------------------------------------- /build/libqtscreen32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bakwc/LibQtScreen/9bf1e200465797807b86a6d20c43f3fc8cc9e59f/build/libqtscreen32.dll -------------------------------------------------------------------------------- /build/libqtscreen64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bakwc/LibQtScreen/9bf1e200465797807b86a6d20c43f3fc8cc9e59f/build/libqtscreen64.dll -------------------------------------------------------------------------------- /directx_api/d3d8caps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Jason Edmeades 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 | */ 18 | 19 | #ifndef __WINE_D3D8CAPS_H 20 | #define __WINE_D3D8CAPS_H 21 | 22 | /* 23 | * Definitions 24 | */ 25 | 26 | #define D3DCAPS_READ_SCANLINE 0x20000 27 | 28 | #define D3DCURSORCAPS_COLOR 1 29 | #define D3DCURSORCAPS_LOWRES 2 30 | 31 | #define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x0000010 32 | #define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x0000020 33 | #define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x0000040 34 | #define D3DDEVCAPS_TLVERTEXVIDEOMEMORY 0x0000080 35 | #define D3DDEVCAPS_TEXTURESYSTEMMEMORY 0x0000100 36 | #define D3DDEVCAPS_TEXTUREVIDEOMEMORY 0x0000200 37 | #define D3DDEVCAPS_DRAWPRIMTLVERTEX 0x0000400 38 | #define D3DDEVCAPS_CANRENDERAFTERFLIP 0x0000800 39 | #define D3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x0001000 40 | #define D3DDEVCAPS_DRAWPRIMITIVES2 0x0002000 41 | #define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x0004000 42 | #define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x0008000 43 | #define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x0010000 44 | #define D3DDEVCAPS_CANBLTSYSTONONLOCAL 0x0020000 45 | #define D3DDEVCAPS_HWRASTERIZATION 0x0080000 46 | #define D3DDEVCAPS_PUREDEVICE 0x0100000 47 | #define D3DDEVCAPS_QUINTICRTPATCHES 0x0200000 48 | #define D3DDEVCAPS_RTPATCHES 0x0400000 49 | #define D3DDEVCAPS_RTPATCHHANDLEZERO 0x0800000 50 | #define D3DDEVCAPS_NPATCHES 0x1000000 51 | 52 | #define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x00FFFF 53 | #define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x080000 54 | #define D3DFVFCAPS_PSIZE 0x100000 55 | 56 | #define D3DLINECAPS_TEXTURE 0x01 57 | #define D3DLINECAPS_ZTEST 0x02 58 | #define D3DLINECAPS_BLEND 0x04 59 | #define D3DLINECAPS_ALPHACMP 0x08 60 | #define D3DLINECAPS_FOG 0x10 61 | 62 | #define D3DPBLENDCAPS_ZERO 0x0001 63 | #define D3DPBLENDCAPS_ONE 0x0002 64 | #define D3DPBLENDCAPS_SRCCOLOR 0x0004 65 | #define D3DPBLENDCAPS_INVSRCCOLOR 0x0008 66 | #define D3DPBLENDCAPS_SRCALPHA 0x0010 67 | #define D3DPBLENDCAPS_INVSRCALPHA 0x0020 68 | #define D3DPBLENDCAPS_DESTALPHA 0x0040 69 | #define D3DPBLENDCAPS_INVDESTALPHA 0x0080 70 | #define D3DPBLENDCAPS_DESTCOLOR 0x0100 71 | #define D3DPBLENDCAPS_INVDESTCOLOR 0x0200 72 | #define D3DPBLENDCAPS_SRCALPHASAT 0x0400 73 | #define D3DPBLENDCAPS_BOTHSRCALPHA 0x0800 74 | #define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x1000 75 | 76 | #define D3DPCMPCAPS_NEVER 0x01 77 | #define D3DPCMPCAPS_LESS 0x02 78 | #define D3DPCMPCAPS_EQUAL 0x04 79 | #define D3DPCMPCAPS_LESSEQUAL 0x08 80 | #define D3DPCMPCAPS_GREATER 0x10 81 | #define D3DPCMPCAPS_NOTEQUAL 0x20 82 | #define D3DPCMPCAPS_GREATEREQUAL 0x40 83 | #define D3DPCMPCAPS_ALWAYS 0x80 84 | 85 | #define D3DPMISCCAPS_MASKZ 0x0002 86 | #define D3DPMISCCAPS_LINEPATTERNREP 0x0004 87 | #define D3DPMISCCAPS_CULLNONE 0x0010 88 | #define D3DPMISCCAPS_CULLCW 0x0020 89 | #define D3DPMISCCAPS_CULLCCW 0x0040 90 | #define D3DPMISCCAPS_COLORWRITEENABLE 0x0080 91 | #define D3DPMISCCAPS_CLIPPLANESCALEDPOINTS 0x0100 92 | #define D3DPMISCCAPS_CLIPTLVERTS 0x0200 93 | #define D3DPMISCCAPS_TSSARGTEMP 0x0400 94 | #define D3DPMISCCAPS_BLENDOP 0x0800 95 | 96 | #define D3DPRASTERCAPS_DITHER 0x00000001 97 | #define D3DPRASTERCAPS_PAT 0x00000008 98 | #define D3DPRASTERCAPS_ZTEST 0x00000010 99 | #define D3DPRASTERCAPS_FOGVERTEX 0x00000080 100 | #define D3DPRASTERCAPS_FOGTABLE 0x00000100 101 | #define D3DPRASTERCAPS_ANTIALIASEDGES 0x00001000 102 | #define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000 103 | #define D3DPRASTERCAPS_ZBIAS 0x00004000 104 | #define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000 105 | #define D3DPRASTERCAPS_FOGRANGE 0x00010000 106 | #define D3DPRASTERCAPS_ANISOTROPY 0x00020000 107 | #define D3DPRASTERCAPS_WBUFFER 0x00040000 108 | #define D3DPRASTERCAPS_WFOG 0x00100000 109 | #define D3DPRASTERCAPS_ZFOG 0x00200000 110 | #define D3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000 111 | #define D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE 0x00800000 112 | 113 | #define D3DPRESENT_INTERVAL_DEFAULT 0x00000000 114 | #define D3DPRESENT_INTERVAL_ONE 0x00000001 115 | #define D3DPRESENT_INTERVAL_TWO 0x00000002 116 | #define D3DPRESENT_INTERVAL_THREE 0x00000004 117 | #define D3DPRESENT_INTERVAL_FOUR 0x00000008 118 | #define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000 119 | 120 | #define D3DPSHADECAPS_COLORGOURAUDRGB 0x00008 121 | #define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00200 122 | #define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x04000 123 | #define D3DPSHADECAPS_FOGGOURAUD 0x80000 124 | 125 | #define D3DPTADDRESSCAPS_WRAP 0x01 126 | #define D3DPTADDRESSCAPS_MIRROR 0x02 127 | #define D3DPTADDRESSCAPS_CLAMP 0x04 128 | #define D3DPTADDRESSCAPS_BORDER 0x08 129 | #define D3DPTADDRESSCAPS_INDEPENDENTUV 0x10 130 | #define D3DPTADDRESSCAPS_MIRRORONCE 0x20 131 | 132 | #define D3DPTEXTURECAPS_PERSPECTIVE 0x00001 133 | #define D3DPTEXTURECAPS_POW2 0x00002 134 | #define D3DPTEXTURECAPS_ALPHA 0x00004 135 | #define D3DPTEXTURECAPS_SQUAREONLY 0x00020 136 | #define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00040 137 | #define D3DPTEXTURECAPS_ALPHAPALETTE 0x00080 138 | #define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00100 139 | #define D3DPTEXTURECAPS_PROJECTED 0x00400 140 | #define D3DPTEXTURECAPS_CUBEMAP 0x00800 141 | #define D3DPTEXTURECAPS_VOLUMEMAP 0x02000 142 | #define D3DPTEXTURECAPS_MIPMAP 0x04000 143 | #define D3DPTEXTURECAPS_MIPVOLUMEMAP 0x08000 144 | #define D3DPTEXTURECAPS_MIPCUBEMAP 0x10000 145 | #define D3DPTEXTURECAPS_CUBEMAP_POW2 0x20000 146 | #define D3DPTEXTURECAPS_VOLUMEMAP_POW2 0x40000 147 | 148 | #define D3DPTFILTERCAPS_MINFPOINT 0x00000100 149 | #define D3DPTFILTERCAPS_MINFLINEAR 0x00000200 150 | #define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400 151 | #define D3DPTFILTERCAPS_MIPFPOINT 0x00010000 152 | #define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000 153 | #define D3DPTFILTERCAPS_MAGFPOINT 0x01000000 154 | #define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000 155 | #define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000 156 | #define D3DPTFILTERCAPS_MAGFAFLATCUBIC 0x08000000 157 | #define D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC 0x10000000 158 | 159 | #define D3DSTENCILCAPS_KEEP 0x01 160 | #define D3DSTENCILCAPS_ZERO 0x02 161 | #define D3DSTENCILCAPS_REPLACE 0x04 162 | #define D3DSTENCILCAPS_INCRSAT 0x08 163 | #define D3DSTENCILCAPS_DECRSAT 0x10 164 | #define D3DSTENCILCAPS_INVERT 0x20 165 | #define D3DSTENCILCAPS_INCR 0x40 166 | #define D3DSTENCILCAPS_DECR 0x80 167 | 168 | #define D3DTEXOPCAPS_DISABLE 0x0000001 169 | #define D3DTEXOPCAPS_SELECTARG1 0x0000002 170 | #define D3DTEXOPCAPS_SELECTARG2 0x0000004 171 | #define D3DTEXOPCAPS_MODULATE 0x0000008 172 | #define D3DTEXOPCAPS_MODULATE2X 0x0000010 173 | #define D3DTEXOPCAPS_MODULATE4X 0x0000020 174 | #define D3DTEXOPCAPS_ADD 0x0000040 175 | #define D3DTEXOPCAPS_ADDSIGNED 0x0000080 176 | #define D3DTEXOPCAPS_ADDSIGNED2X 0x0000100 177 | #define D3DTEXOPCAPS_SUBTRACT 0x0000200 178 | #define D3DTEXOPCAPS_ADDSMOOTH 0x0000400 179 | #define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x0000800 180 | #define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x0001000 181 | #define D3DTEXOPCAPS_BLENDFACTORALPHA 0x0002000 182 | #define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x0004000 183 | #define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x0008000 184 | #define D3DTEXOPCAPS_PREMODULATE 0x0010000 185 | #define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x0020000 186 | #define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x0040000 187 | #define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x0080000 188 | #define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x0100000 189 | #define D3DTEXOPCAPS_BUMPENVMAP 0x0200000 190 | #define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x0400000 191 | #define D3DTEXOPCAPS_DOTPRODUCT3 0x0800000 192 | #define D3DTEXOPCAPS_MULTIPLYADD 0x1000000 193 | #define D3DTEXOPCAPS_LERP 0x2000000 194 | 195 | #define D3DVTXPCAPS_TEXGEN 0x01 196 | #define D3DVTXPCAPS_MATERIALSOURCE7 0x02 197 | #define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x08 198 | #define D3DVTXPCAPS_POSITIONALLIGHTS 0x10 199 | #define D3DVTXPCAPS_LOCALVIEWER 0x20 200 | #define D3DVTXPCAPS_TWEENING 0x40 201 | 202 | #define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020 203 | #define D3DCAPS3_RESERVED 0x8000001f 204 | 205 | #define D3DCAPS2_CANCALIBRATEGAMMA 0x0100000 206 | #define D3DCAPS2_CANRENDERWINDOWED 0x0080000 207 | #define D3DCAPS2_CANMANAGERESOURCE 0x10000000 208 | #define D3DCAPS2_DYNAMICTEXTURES 0x20000000 209 | #define D3DCAPS2_FULLSCREENGAMMA 0x0020000 210 | #define D3DCAPS2_NO2DDURING3DSCENE 0x0000002 211 | #define D3DCAPS2_RESERVED 0x2000000 212 | 213 | /* 214 | * The d3dcaps8 structure 215 | */ 216 | typedef struct _D3DCAPS8 { 217 | D3DDEVTYPE DeviceType; 218 | UINT AdapterOrdinal; 219 | 220 | DWORD Caps; 221 | DWORD Caps2; 222 | DWORD Caps3; 223 | DWORD PresentationIntervals; 224 | 225 | DWORD CursorCaps; 226 | 227 | DWORD DevCaps; 228 | 229 | DWORD PrimitiveMiscCaps; 230 | DWORD RasterCaps; 231 | DWORD ZCmpCaps; 232 | DWORD SrcBlendCaps; 233 | DWORD DestBlendCaps; 234 | DWORD AlphaCmpCaps; 235 | DWORD ShadeCaps; 236 | DWORD TextureCaps; 237 | DWORD TextureFilterCaps; 238 | DWORD CubeTextureFilterCaps; 239 | DWORD VolumeTextureFilterCaps; 240 | DWORD TextureAddressCaps; 241 | DWORD VolumeTextureAddressCaps; 242 | 243 | DWORD LineCaps; 244 | 245 | DWORD MaxTextureWidth, MaxTextureHeight; 246 | DWORD MaxVolumeExtent; 247 | 248 | DWORD MaxTextureRepeat; 249 | DWORD MaxTextureAspectRatio; 250 | DWORD MaxAnisotropy; 251 | float MaxVertexW; 252 | 253 | float GuardBandLeft; 254 | float GuardBandTop; 255 | float GuardBandRight; 256 | float GuardBandBottom; 257 | 258 | float ExtentsAdjust; 259 | DWORD StencilCaps; 260 | 261 | DWORD FVFCaps; 262 | DWORD TextureOpCaps; 263 | DWORD MaxTextureBlendStages; 264 | DWORD MaxSimultaneousTextures; 265 | 266 | DWORD VertexProcessingCaps; 267 | DWORD MaxActiveLights; 268 | DWORD MaxUserClipPlanes; 269 | DWORD MaxVertexBlendMatrices; 270 | DWORD MaxVertexBlendMatrixIndex; 271 | 272 | float MaxPointSize; 273 | 274 | DWORD MaxPrimitiveCount; 275 | DWORD MaxVertexIndex; 276 | DWORD MaxStreams; 277 | DWORD MaxStreamStride; 278 | 279 | DWORD VertexShaderVersion; 280 | DWORD MaxVertexShaderConst; 281 | 282 | DWORD PixelShaderVersion; 283 | float MaxPixelShaderValue; 284 | } D3DCAPS8; 285 | 286 | #endif /* __WINE_D3D8CAPS_H */ 287 | -------------------------------------------------------------------------------- /directx_api/d3d8types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002 Jason Edmeades 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 | */ 18 | 19 | #ifndef __WINE_D3D8TYPES_H 20 | #define __WINE_D3D8TYPES_H 21 | 22 | #include 23 | 24 | /***************************************************************************** 25 | * Direct 3D v8 #defines 26 | */ 27 | 28 | #define D3DCLEAR_TARGET 1 29 | #define D3DCLEAR_ZBUFFER 2 30 | #define D3DCLEAR_STENCIL 4 31 | 32 | #define D3DCLIPPLANE0 (1 << 0) 33 | #define D3DCLIPPLANE1 (1 << 1) 34 | #define D3DCLIPPLANE2 (1 << 2) 35 | #define D3DCLIPPLANE3 (1 << 3) 36 | #define D3DCLIPPLANE4 (1 << 4) 37 | #define D3DCLIPPLANE5 (1 << 5) 38 | 39 | #define D3DCOLOR_ARGB(a,r,g,b) ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) 40 | #define D3DCOLOR_COLORVALUE(r,g,b,a) D3DCOLOR_RGBA((DWORD)((r)*255.f),(DWORD)((g)*255.f),(DWORD)((b)*255.f),(DWORD)((a)*255.f)) 41 | #define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b) 42 | #define D3DCOLOR_XRGB(r,g,b) D3DCOLOR_ARGB(0xff,r,g,b) 43 | 44 | #define D3DCS_LEFT 0x001 45 | #define D3DCS_RIGHT 0x002 46 | #define D3DCS_TOP 0x004 47 | #define D3DCS_BOTTOM 0x008 48 | #define D3DCS_FRONT 0x010 49 | #define D3DCS_BACK 0x020 50 | #define D3DCS_PLANE0 0x040 51 | #define D3DCS_PLANE1 0x080 52 | #define D3DCS_PLANE2 0x100 53 | #define D3DCS_PLANE3 0x200 54 | #define D3DCS_PLANE4 0x400 55 | #define D3DCS_PLANE5 0x800 56 | #define D3DCS_ALL 0xFFF 57 | 58 | #define D3DFVF_TEXTUREFORMAT1 3 59 | #define D3DFVF_TEXTUREFORMAT2 0 60 | #define D3DFVF_TEXTUREFORMAT3 1 61 | #define D3DFVF_TEXTUREFORMAT4 2 62 | #define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16)) 63 | #define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2) 64 | #define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16)) 65 | #define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16)) 66 | 67 | #define D3DLOCK_READONLY 0x0010 68 | #define D3DLOCK_NOSYSLOCK 0x0800 69 | #define D3DLOCK_NOOVERWRITE 0x1000 70 | #define D3DLOCK_DISCARD 0x2000 71 | #define D3DLOCK_NO_DIRTY_UPDATE 0x8000 72 | 73 | #define D3DMAXUSERCLIPPLANES 32 74 | 75 | #define D3DRENDERSTATE_WRAPBIAS 0x80 76 | 77 | #define D3DTSS_TCI_PASSTHRU 0x00000 78 | #define D3DTSS_TCI_CAMERASPACENORMAL 0x10000 79 | #define D3DTSS_TCI_CAMERASPACEPOSITION 0x20000 80 | #define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x30000 81 | 82 | 83 | #define D3DTS_WORLD D3DTS_WORLDMATRIX(0) 84 | #define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1) 85 | #define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2) 86 | #define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3) 87 | #define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256) 88 | 89 | #define D3DUSAGE_RENDERTARGET 0x01 90 | #define D3DUSAGE_DEPTHSTENCIL 0x02 91 | #define D3DUSAGE_WRITEONLY 0x08 92 | #define D3DUSAGE_SOFTWAREPROCESSING 0x10 93 | #define D3DUSAGE_DONOTCLIP 0x20 94 | #define D3DUSAGE_POINTS 0x40 95 | #define D3DUSAGE_RTPATCHES 0x80 96 | #define D3DUSAGE_NPATCHES 0x100 97 | #define D3DUSAGE_DYNAMIC 0x200 98 | 99 | #define D3DWRAP_U 1 100 | #define D3DWRAP_V 2 101 | #define D3DWRAP_W 4 102 | #define D3DWRAPCOORD_0 1 103 | #define D3DWRAPCOORD_1 2 104 | #define D3DWRAPCOORD_2 4 105 | #define D3DWRAPCOORD_3 8 106 | 107 | #define MAX_DEVICE_IDENTIFIER_STRING 512 108 | 109 | #define D3DFVF_RESERVED0 0x0001 110 | #define D3DFVF_POSITION_MASK 0x000E 111 | #define D3DFVF_XYZ 0x0002 112 | #define D3DFVF_XYZRHW 0x0004 113 | #define D3DFVF_XYZB1 0x0006 114 | #define D3DFVF_XYZB2 0x0008 115 | #define D3DFVF_XYZB3 0x000a 116 | #define D3DFVF_XYZB4 0x000c 117 | #define D3DFVF_XYZB5 0x000e 118 | #define D3DFVF_NORMAL 0x0010 119 | #define D3DFVF_PSIZE 0x0020 120 | #define D3DFVF_DIFFUSE 0x0040 121 | #define D3DFVF_SPECULAR 0x0080 122 | #define D3DFVF_TEXCOUNT_MASK 0x0f00 123 | #define D3DFVF_TEXCOUNT_SHIFT 8 124 | #define D3DFVF_TEX0 0x0000 125 | #define D3DFVF_TEX1 0x0100 126 | #define D3DFVF_TEX2 0x0200 127 | #define D3DFVF_TEX3 0x0300 128 | #define D3DFVF_TEX4 0x0400 129 | #define D3DFVF_TEX5 0x0500 130 | #define D3DFVF_TEX6 0x0600 131 | #define D3DFVF_TEX7 0x0700 132 | #define D3DFVF_TEX8 0x0800 133 | #define D3DFVF_LASTBETA_UBYTE4 0x1000 134 | #define D3DFVF_RESERVED2 0xE000 135 | 136 | #define D3DTA_SELECTMASK 0x0000000f 137 | #define D3DTA_DIFFUSE 0x00000000 138 | #define D3DTA_CURRENT 0x00000001 139 | #define D3DTA_TEXTURE 0x00000002 140 | #define D3DTA_TFACTOR 0x00000003 141 | #define D3DTA_SPECULAR 0x00000004 142 | #define D3DTA_COMPLEMENT 0x00000010 143 | #define D3DTA_ALPHAREPLICATE 0x00000020 144 | #define D3DTA_TEMP 0x00000005 145 | 146 | #define D3DCOLORWRITEENABLE_RED (__MSABI_LONG(1)<<0) 147 | #define D3DCOLORWRITEENABLE_GREEN (__MSABI_LONG(1)<<1) 148 | #define D3DCOLORWRITEENABLE_BLUE (__MSABI_LONG(1)<<2) 149 | #define D3DCOLORWRITEENABLE_ALPHA (__MSABI_LONG(1)<<3) 150 | 151 | 152 | #ifndef MAKEFOURCC 153 | #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ 154 | ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ 155 | ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) 156 | #endif 157 | 158 | /**************************** 159 | * Vertex Shaders Declaration 160 | */ 161 | 162 | typedef enum _D3DVSD_TOKENTYPE { 163 | D3DVSD_TOKEN_NOP = 0, 164 | D3DVSD_TOKEN_STREAM = 1, 165 | D3DVSD_TOKEN_STREAMDATA = 2, 166 | D3DVSD_TOKEN_TESSELLATOR = 3, 167 | D3DVSD_TOKEN_CONSTMEM = 4, 168 | D3DVSD_TOKEN_EXT = 5, 169 | /* RESERVED = 6 */ 170 | D3DVSD_TOKEN_END = 7, 171 | D3DVSD_FORCE_DWORD = 0x7FFFFFFF 172 | } D3DVSD_TOKENTYPE; 173 | 174 | /** input registers for vertex shaders functions */ 175 | /* 176 | #define D3DVSDE_POSITION 0 177 | #define D3DVSDE_BLENDWEIGHT 1 178 | #define D3DVSDE_BLENDINDICES 2 179 | #define D3DVSDE_NORMAL 3 180 | #define D3DVSDE_PSIZE 4 181 | #define D3DVSDE_DIFFUSE 5 182 | #define D3DVSDE_SPECULAR 6 183 | #define D3DVSDE_TEXCOORD0 7 184 | #define D3DVSDE_TEXCOORD1 8 185 | #define D3DVSDE_TEXCOORD2 9 186 | #define D3DVSDE_TEXCOORD3 10 187 | #define D3DVSDE_TEXCOORD4 11 188 | #define D3DVSDE_TEXCOORD5 12 189 | #define D3DVSDE_TEXCOORD6 13 190 | #define D3DVSDE_TEXCOORD7 14 191 | #define D3DVSDE_POSITION2 15 192 | #define D3DVSDE_NORMAL2 16 193 | */ 194 | /** Address of the vertex register. 0 - 16 */ 195 | typedef enum _D3DVSDE_REGISTER { 196 | D3DVSDE_POSITION = 0, 197 | D3DVSDE_BLENDWEIGHT = 1, 198 | D3DVSDE_BLENDINDICES = 2, 199 | D3DVSDE_NORMAL = 3, 200 | D3DVSDE_PSIZE = 4, 201 | D3DVSDE_DIFFUSE = 5, 202 | D3DVSDE_SPECULAR = 6, 203 | D3DVSDE_TEXCOORD0 = 7, 204 | D3DVSDE_TEXCOORD1 = 8, 205 | D3DVSDE_TEXCOORD2 = 9, 206 | D3DVSDE_TEXCOORD3 = 10, 207 | D3DVSDE_TEXCOORD4 = 11, 208 | D3DVSDE_TEXCOORD5 = 12, 209 | D3DVSDE_TEXCOORD6 = 13, 210 | D3DVSDE_TEXCOORD7 = 14, 211 | D3DVSDE_POSITION2 = 15, 212 | D3DVSDE_NORMAL2 = 16 213 | } D3DVSDE_REGISTER; 214 | 215 | /** bit-field declaration for VertexRegister Type */ 216 | /* 217 | #define D3DVSDT_FLOAT1 0x00 218 | #define D3DVSDT_FLOAT2 0x01 219 | #define D3DVSDT_FLOAT3 0x02 220 | #define D3DVSDT_FLOAT4 0x03 221 | #define D3DVSDT_D3DCOLOR 0x04 222 | #define D3DVSDT_UBYTE4 0x05 223 | #define D3DVSDT_SHORT2 0x06 224 | #define D3DVSDT_SHORT4 0x07 225 | */ 226 | typedef enum _D3DVSDT_TYPE { 227 | D3DVSDT_FLOAT1 = 0x00, 228 | D3DVSDT_FLOAT2 = 0x01, 229 | D3DVSDT_FLOAT3 = 0x02, 230 | D3DVSDT_FLOAT4 = 0x03, 231 | D3DVSDT_D3DCOLOR = 0x04, 232 | D3DVSDT_UBYTE4 = 0x05, 233 | D3DVSDT_SHORT2 = 0x06, 234 | D3DVSDT_SHORT4 = 0x07 235 | } D3DVSDT_TYPE; 236 | 237 | 238 | #define D3DVSD_CONSTADDRESSSHIFT 0 239 | #define D3DVSD_EXTINFOSHIFT 0 240 | #define D3DVSD_STREAMNUMBERSHIFT 0 241 | #define D3DVSD_VERTEXREGSHIFT 0 242 | #define D3DVSD_CONSTRSSHIFT 16 243 | #define D3DVSD_DATATYPESHIFT 16 244 | #define D3DVSD_SKIPCOUNTSHIFT 16 245 | #define D3DVSD_VERTEXREGINSHIFT 20 246 | #define D3DVSD_EXTCOUNTSHIFT 24 247 | #define D3DVSD_CONSTCOUNTSHIFT 25 248 | #define D3DVSD_DATALOADTYPESHIFT 28 249 | #define D3DVSD_STREAMTESSSHIFT 28 250 | #define D3DVSD_TOKENTYPESHIFT 29 251 | 252 | #define D3DVSD_CONSTADDRESSMASK (0x7F << D3DVSD_CONSTADDRESSSHIFT) 253 | #define D3DVSD_EXTINFOMASK (0xFFFFFF << D3DVSD_EXTINFOSHIFT) 254 | #define D3DVSD_STREAMNUMBERMASK (0xF << D3DVSD_STREAMNUMBERSHIFT) 255 | #define D3DVSD_VERTEXREGMASK (0x1F << D3DVSD_VERTEXREGSHIFT) 256 | #define D3DVSD_CONSTRSMASK (0x1FFF << D3DVSD_CONSTRSSHIFT) 257 | #define D3DVSD_DATATYPEMASK (0xF << D3DVSD_DATATYPESHIFT) 258 | #define D3DVSD_SKIPCOUNTMASK (0xF << D3DVSD_SKIPCOUNTSHIFT) 259 | #define D3DVSD_EXTCOUNTMASK (0x1F << D3DVSD_EXTCOUNTSHIFT) 260 | #define D3DVSD_VERTEXREGINMASK (0xF << D3DVSD_VERTEXREGINSHIFT) 261 | #define D3DVSD_CONSTCOUNTMASK (0xF << D3DVSD_CONSTCOUNTSHIFT) 262 | #define D3DVSD_DATALOADTYPEMASK (0x1 << D3DVSD_DATALOADTYPESHIFT) 263 | #define D3DVSD_STREAMTESSMASK (0x1 << D3DVSD_STREAMTESSSHIFT) 264 | #define D3DVSD_TOKENTYPEMASK (0x7 << D3DVSD_TOKENTYPESHIFT) 265 | 266 | 267 | #define D3DVSD_MAKETOKENTYPE(TokenType) \ 268 | ((TokenType << D3DVSD_TOKENTYPESHIFT) & D3DVSD_TOKENTYPEMASK) 269 | 270 | #define D3DVSD_CONST(ConstantAddress, Count) \ 271 | (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_CONSTMEM) | ((Count) << D3DVSD_CONSTCOUNTSHIFT) | (ConstantAddress)) 272 | 273 | #define D3DVSD_END() 0xFFFFFFFF 274 | 275 | #define D3DVSD_NOP() 0x00000000 276 | 277 | #define D3DVSD_REG(VertexRegister, Type) \ 278 | (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | ((Type) << D3DVSD_DATATYPESHIFT) | (VertexRegister)) 279 | 280 | #define D3DVSD_SKIP(Count) \ 281 | (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | 0x10000000 | ((Count) << D3DVSD_SKIPCOUNTSHIFT)) 282 | 283 | #define D3DVSD_STREAM(StreamNumber) \ 284 | (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (StreamNumber)) 285 | 286 | #define D3DVSD_STREAM_TESS() \ 287 | (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (D3DVSD_STREAMTESSMASK)) 288 | 289 | #define D3DVSD_TESSNORMAL(RegisterIn, RegisterOut) \ 290 | (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | ((RegisterIn) << D3DVSD_VERTEXREGINSHIFT) | ((0x02) << D3DVSD_DATATYPESHIFT) | (RegisterOut)) 291 | 292 | #define D3DVSD_TESSUV(Register) \ 293 | (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | 0x10000000 | ((0x01) << D3DVSD_DATATYPESHIFT) | (Register)) 294 | 295 | 296 | /******************************** 297 | * Pixel/Vertex Shaders Functions 298 | */ 299 | 300 | /** Maximum number of supported texture coordinates sets operation */ 301 | #define D3DDP_MAXTEXCOORD 8 302 | 303 | /** opcode token mask */ 304 | #define D3DSI_OPCODE_MASK 0x0000FFFF 305 | 306 | /** opcodes types for PS and VS */ 307 | typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE { 308 | D3DSIO_NOP = 0, 309 | D3DSIO_MOV = 1, 310 | D3DSIO_ADD = 2, 311 | D3DSIO_SUB = 3, 312 | D3DSIO_MAD = 4, 313 | D3DSIO_MUL = 5, 314 | D3DSIO_RCP = 6, 315 | D3DSIO_RSQ = 7, 316 | D3DSIO_DP3 = 8, 317 | D3DSIO_DP4 = 9, 318 | D3DSIO_MIN = 10, 319 | D3DSIO_MAX = 11, 320 | D3DSIO_SLT = 12, 321 | D3DSIO_SGE = 13, 322 | D3DSIO_EXP = 14, 323 | D3DSIO_LOG = 15, 324 | D3DSIO_LIT = 16, 325 | D3DSIO_DST = 17, 326 | D3DSIO_LRP = 18, 327 | D3DSIO_FRC = 19, 328 | D3DSIO_M4x4 = 20, 329 | D3DSIO_M4x3 = 21, 330 | D3DSIO_M3x4 = 22, 331 | D3DSIO_M3x3 = 23, 332 | D3DSIO_M3x2 = 24, 333 | 334 | D3DSIO_TEXCOORD = 64, 335 | D3DSIO_TEXKILL = 65, 336 | D3DSIO_TEX = 66, 337 | D3DSIO_TEXBEM = 67, 338 | D3DSIO_TEXBEML = 68, 339 | D3DSIO_TEXREG2AR = 69, 340 | D3DSIO_TEXREG2GB = 70, 341 | D3DSIO_TEXM3x2PAD = 71, 342 | D3DSIO_TEXM3x2TEX = 72, 343 | D3DSIO_TEXM3x3PAD = 73, 344 | D3DSIO_TEXM3x3TEX = 74, 345 | D3DSIO_TEXM3x3DIFF = 75, 346 | D3DSIO_TEXM3x3SPEC = 76, 347 | D3DSIO_TEXM3x3VSPEC = 77, 348 | D3DSIO_EXPP = 78, 349 | D3DSIO_LOGP = 79, 350 | D3DSIO_CND = 80, 351 | D3DSIO_DEF = 81, 352 | D3DSIO_TEXREG2RGB = 82, 353 | D3DSIO_TEXDP3TEX = 83, 354 | D3DSIO_TEXM3x2DEPTH = 84, 355 | D3DSIO_TEXDP3 = 85, 356 | D3DSIO_TEXM3x3 = 86, 357 | D3DSIO_TEXDEPTH = 87, 358 | D3DSIO_CMP = 88, 359 | D3DSIO_BEM = 89, 360 | 361 | D3DSIO_PHASE = 0xFFFD, 362 | D3DSIO_COMMENT = 0xFFFE, 363 | D3DSIO_END = 0XFFFF, 364 | 365 | D3DSIO_FORCE_DWORD = 0X7FFFFFFF /** for 32-bit alignment */ 366 | } D3DSHADER_INSTRUCTION_OPCODE_TYPE; 367 | 368 | /** for parallelism */ 369 | #define D3DSI_COISSUE 0x40000000 370 | 371 | /** destination parameter modifiers (.xyzw) */ 372 | #define D3DSP_WRITEMASK_0 0x00010000 /* .x r */ 373 | #define D3DSP_WRITEMASK_1 0x00020000 /* .y g */ 374 | #define D3DSP_WRITEMASK_2 0x00040000 /* .z b */ 375 | #define D3DSP_WRITEMASK_3 0x00080000 /* .w a */ 376 | #define D3DSP_WRITEMASK_ALL 0x000F0000 /* all */ 377 | 378 | #define D3DSP_DSTMOD_SHIFT 20 379 | #define D3DSP_DSTMOD_MASK (0xF << D3DSP_DSTMOD_SHIFT) 380 | 381 | typedef enum _D3DSHADER_PARAM_DSTMOD_TYPE { 382 | D3DSPDM_NONE = 0 << D3DSP_DSTMOD_SHIFT, 383 | D3DSPDM_SATURATE = 1 << D3DSP_DSTMOD_SHIFT, 384 | D3DSPDM_FORCE_DWORD = 0X7FFFFFFF 385 | } D3DSHADER_PARAM_DSTMOD_TYPE; 386 | 387 | /** destination param */ 388 | #define D3DSP_DSTSHIFT_SHIFT 24 389 | #define D3DSP_DSTSHIFT_MASK (0xF << D3DSP_DSTSHIFT_SHIFT) 390 | 391 | /** destination/source reg type */ 392 | #define D3DSP_REGTYPE_SHIFT 28 393 | #define D3DSP_REGTYPE_MASK (0x7 << D3DSP_REGTYPE_SHIFT) 394 | 395 | typedef enum _D3DSHADER_PARAM_REGISTER_TYPE { 396 | D3DSPR_TEMP = 0 << D3DSP_REGTYPE_SHIFT, 397 | D3DSPR_INPUT = 1 << D3DSP_REGTYPE_SHIFT, 398 | D3DSPR_CONST = 2 << D3DSP_REGTYPE_SHIFT, 399 | D3DSPR_ADDR = 3 << D3DSP_REGTYPE_SHIFT, 400 | D3DSPR_TEXTURE = 3 << D3DSP_REGTYPE_SHIFT, 401 | D3DSPR_RASTOUT = 4 << D3DSP_REGTYPE_SHIFT, 402 | D3DSPR_ATTROUT = 5 << D3DSP_REGTYPE_SHIFT, 403 | D3DSPR_TEXCRDOUT = 6 << D3DSP_REGTYPE_SHIFT, 404 | D3DSPR_FORCE_DWORD = 0x7FFFFFFF 405 | } D3DSHADER_PARAM_REGISTER_TYPE; 406 | 407 | typedef enum _D3DVS_RASTOUT_OFFSETS { 408 | D3DSRO_POSITION = 0, 409 | D3DSRO_FOG = 1, 410 | D3DSRO_POINT_SIZE = 2, 411 | D3DSRO_FORCE_DWORD = 0x7FFFFFFF 412 | } D3DVS_RASTOUT_OFFSETS; 413 | 414 | #define D3DVS_ADDRESSMODE_SHIFT 13 415 | #define D3DVS_ADDRESSMODE_MASK (0x1 << D3DVS_ADDRESSMODE_SHIFT) 416 | 417 | typedef enum _D3DVS_ADDRESSMODE_TYPE { 418 | D3DVS_ADDRMODE_ABSOLUTE = 0 << D3DVS_ADDRESSMODE_SHIFT, 419 | D3DVS_ADDRMODE_RELATIVE = 1 << D3DVS_ADDRESSMODE_SHIFT, 420 | D3DVS_ADDRMODE_FORCE_DWORD = 0x7FFFFFFF 421 | } D3DVS_ADDRESSMODE_TYPE; 422 | 423 | #define D3DVS_SWIZZLE_SHIFT 16 424 | #define D3DVS_SWIZZLE_MASK (0xFF << D3DVS_SWIZZLE_SHIFT) 425 | 426 | #define D3DSP_SWIZZLE_SHIFT 16 427 | #define D3DSP_SWIZZLE_MASK (0xFF << D3DSP_SWIZZLE_SHIFT) 428 | 429 | #define D3DVS_X_X (0 << D3DVS_SWIZZLE_SHIFT) 430 | #define D3DVS_X_Y (1 << D3DVS_SWIZZLE_SHIFT) 431 | #define D3DVS_X_Z (2 << D3DVS_SWIZZLE_SHIFT) 432 | #define D3DVS_X_W (3 << D3DVS_SWIZZLE_SHIFT) 433 | 434 | #define D3DVS_Y_X (0 << (D3DVS_SWIZZLE_SHIFT + 2)) 435 | #define D3DVS_Y_Y (1 << (D3DVS_SWIZZLE_SHIFT + 2)) 436 | #define D3DVS_Y_Z (2 << (D3DVS_SWIZZLE_SHIFT + 2)) 437 | #define D3DVS_Y_W (3 << (D3DVS_SWIZZLE_SHIFT + 2)) 438 | 439 | #define D3DVS_Z_X (0 << (D3DVS_SWIZZLE_SHIFT + 4)) 440 | #define D3DVS_Z_Y (1 << (D3DVS_SWIZZLE_SHIFT + 4)) 441 | #define D3DVS_Z_Z (2 << (D3DVS_SWIZZLE_SHIFT + 4)) 442 | #define D3DVS_Z_W (3 << (D3DVS_SWIZZLE_SHIFT + 4)) 443 | 444 | #define D3DVS_W_X (0 << (D3DVS_SWIZZLE_SHIFT + 6)) 445 | #define D3DVS_W_Y (1 << (D3DVS_SWIZZLE_SHIFT + 6)) 446 | #define D3DVS_W_Z (2 << (D3DVS_SWIZZLE_SHIFT + 6)) 447 | #define D3DVS_W_W (3 << (D3DVS_SWIZZLE_SHIFT + 6)) 448 | 449 | #define D3DVS_NOSWIZZLE (D3DVS_X_X | D3DVS_Y_Y | D3DVS_Z_Z | D3DVS_W_W) 450 | 451 | #define D3DSP_NOSWIZZLE \ 452 | ((0 << (D3DSP_SWIZZLE_SHIFT + 0)) | (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | (2 << (D3DSP_SWIZZLE_SHIFT + 4)) | (3 << (D3DSP_SWIZZLE_SHIFT + 6))) 453 | 454 | #define D3DSP_SRCMOD_SHIFT 24 455 | #define D3DSP_SRCMOD_MASK (0xF << D3DSP_SRCMOD_SHIFT) 456 | 457 | typedef enum _D3DSHADER_PARAM_SRCMOD_TYPE { 458 | D3DSPSM_NONE = 0 << D3DSP_SRCMOD_SHIFT, 459 | D3DSPSM_NEG = 1 << D3DSP_SRCMOD_SHIFT, 460 | D3DSPSM_BIAS = 2 << D3DSP_SRCMOD_SHIFT, 461 | D3DSPSM_BIASNEG = 3 << D3DSP_SRCMOD_SHIFT, 462 | D3DSPSM_SIGN = 4 << D3DSP_SRCMOD_SHIFT, 463 | D3DSPSM_SIGNNEG = 5 << D3DSP_SRCMOD_SHIFT, 464 | D3DSPSM_COMP = 6 << D3DSP_SRCMOD_SHIFT, 465 | D3DSPSM_X2 = 7 << D3DSP_SRCMOD_SHIFT, 466 | D3DSPSM_X2NEG = 8 << D3DSP_SRCMOD_SHIFT, 467 | D3DSPSM_DZ = 9 << D3DSP_SRCMOD_SHIFT, 468 | D3DSPSM_DW = 10 << D3DSP_SRCMOD_SHIFT, 469 | D3DSPSM_FORCE_DWORD = 0x7FFFFFFF 470 | } D3DSHADER_PARAM_SRCMOD_TYPE; 471 | 472 | #define D3DPS_VERSION(major, minor) (0xFFFF0000 | ((major) << 8) | (minor)) 473 | #define D3DVS_VERSION(major, minor) (0xFFFE0000 | ((major) << 8) | (minor)) 474 | #define D3DSHADER_VERSION_MAJOR(version) (((version) >> 8) & 0xFF) 475 | #define D3DSHADER_VERSION_MINOR(version) (((version) >> 0) & 0xFF) 476 | 477 | #define D3DSI_COMMENTSIZE_SHIFT 16 478 | #define D3DSI_COMMENTSIZE_MASK (0x7FFF << D3DSI_COMMENTSIZE_SHIFT) 479 | 480 | #define D3DSHADER_COMMENT(commentSize) \ 481 | ((((commentSize) << D3DSI_COMMENTSIZE_SHIFT) & D3DSI_COMMENTSIZE_MASK) | D3DSIO_COMMENT) 482 | 483 | #define D3DPS_END() 0x0000FFFF 484 | #define D3DVS_END() 0x0000FFFF 485 | 486 | 487 | /***************************************************************************** 488 | * Direct 3D v8 enumerated types 489 | */ 490 | typedef enum _D3DBACKBUFFER_TYPE { 491 | D3DBACKBUFFER_TYPE_MONO = 0, 492 | D3DBACKBUFFER_TYPE_LEFT = 1, 493 | D3DBACKBUFFER_TYPE_RIGHT = 2, 494 | 495 | D3DBACKBUFFER_TYPE_FORCE_DWORD = 0x7fffffff 496 | } D3DBACKBUFFER_TYPE; 497 | 498 | typedef enum _D3DBASISTYPE{ 499 | D3DBASIS_BEZIER = 0, 500 | D3DBASIS_BSPLINE = 1, 501 | D3DBASIS_INTERPOLATE = 2, 502 | 503 | D3DBASIS_FORCE_DWORD = 0x7fffffff 504 | } D3DBASISTYPE; 505 | 506 | typedef enum _D3DBLEND { 507 | D3DBLEND_ZERO = 1, 508 | D3DBLEND_ONE = 2, 509 | D3DBLEND_SRCCOLOR = 3, 510 | D3DBLEND_INVSRCCOLOR = 4, 511 | D3DBLEND_SRCALPHA = 5, 512 | D3DBLEND_INVSRCALPHA = 6, 513 | D3DBLEND_DESTALPHA = 7, 514 | D3DBLEND_INVDESTALPHA = 8, 515 | D3DBLEND_DESTCOLOR = 9, 516 | D3DBLEND_INVDESTCOLOR = 10, 517 | D3DBLEND_SRCALPHASAT = 11, 518 | D3DBLEND_BOTHSRCALPHA = 12, 519 | D3DBLEND_BOTHINVSRCALPHA = 13, 520 | 521 | D3DBLEND_FORCE_DWORD = 0x7fffffff 522 | } D3DBLEND; 523 | 524 | typedef enum _D3DBLENDOP { 525 | D3DBLENDOP_ADD = 1, 526 | D3DBLENDOP_SUBTRACT = 2, 527 | D3DBLENDOP_REVSUBTRACT = 3, 528 | D3DBLENDOP_MIN = 4, 529 | D3DBLENDOP_MAX = 5, 530 | 531 | D3DBLENDOP_FORCE_DWORD = 0x7fffffff 532 | } D3DBLENDOP; 533 | 534 | typedef enum _D3DCMPFUNC { 535 | D3DCMP_NEVER = 1, 536 | D3DCMP_LESS = 2, 537 | D3DCMP_EQUAL = 3, 538 | D3DCMP_LESSEQUAL = 4, 539 | D3DCMP_GREATER = 5, 540 | D3DCMP_NOTEQUAL = 6, 541 | D3DCMP_GREATEREQUAL = 7, 542 | D3DCMP_ALWAYS = 8, 543 | 544 | D3DCMP_FORCE_DWORD = 0x7fffffff 545 | } D3DCMPFUNC; 546 | 547 | typedef enum _D3DCUBEMAP_FACES { 548 | D3DCUBEMAP_FACE_POSITIVE_X = 0, 549 | D3DCUBEMAP_FACE_NEGATIVE_X = 1, 550 | D3DCUBEMAP_FACE_POSITIVE_Y = 2, 551 | D3DCUBEMAP_FACE_NEGATIVE_Y = 3, 552 | D3DCUBEMAP_FACE_POSITIVE_Z = 4, 553 | D3DCUBEMAP_FACE_NEGATIVE_Z = 5, 554 | 555 | D3DCUBEMAP_FACE_FORCE_DWORD = 0xffffffff 556 | } D3DCUBEMAP_FACES; 557 | 558 | typedef enum _D3DCULL { 559 | D3DCULL_NONE = 1, 560 | D3DCULL_CW = 2, 561 | D3DCULL_CCW = 3, 562 | 563 | D3DCULL_FORCE_DWORD = 0x7fffffff 564 | } D3DCULL; 565 | 566 | typedef enum _D3DDEBUGMONITORTOKENS { 567 | D3DDMT_ENABLE = 0, 568 | D3DDMT_DISABLE = 1, 569 | 570 | D3DDMT_FORCE_DWORD = 0x7fffffff 571 | } D3DDEBUGMONITORTOKENS; 572 | 573 | typedef enum _D3DDEVTYPE { 574 | D3DDEVTYPE_HAL = 1, 575 | D3DDEVTYPE_REF = 2, 576 | D3DDEVTYPE_SW = 3, 577 | 578 | D3DDEVTYPE_FORCE_DWORD = 0xffffffff 579 | } D3DDEVTYPE; 580 | 581 | typedef enum _D3DFILLMODE { 582 | D3DFILL_POINT = 1, 583 | D3DFILL_WIREFRAME = 2, 584 | D3DFILL_SOLID = 3, 585 | 586 | D3DFILL_FORCE_DWORD = 0x7fffffff 587 | } D3DFILLMODE; 588 | 589 | typedef enum _D3DFOGMODE { 590 | D3DFOG_NONE = 0, 591 | D3DFOG_EXP = 1, 592 | D3DFOG_EXP2 = 2, 593 | D3DFOG_LINEAR = 3, 594 | 595 | D3DFOG_FORCE_DWORD = 0x7fffffff 596 | } D3DFOGMODE; 597 | 598 | typedef enum _D3DFORMAT { 599 | D3DFMT_UNKNOWN = 0, 600 | 601 | D3DFMT_R8G8B8 = 20, 602 | D3DFMT_A8R8G8B8 = 21, 603 | D3DFMT_X8R8G8B8 = 22, 604 | D3DFMT_R5G6B5 = 23, 605 | D3DFMT_X1R5G5B5 = 24, 606 | D3DFMT_A1R5G5B5 = 25, 607 | D3DFMT_A4R4G4B4 = 26, 608 | D3DFMT_R3G3B2 = 27, 609 | D3DFMT_A8 = 28, 610 | D3DFMT_A8R3G3B2 = 29, 611 | D3DFMT_X4R4G4B4 = 30, 612 | D3DFMT_A2B10G10R10 = 31, 613 | D3DFMT_G16R16 = 34, 614 | 615 | D3DFMT_A8P8 = 40, 616 | D3DFMT_P8 = 41, 617 | 618 | D3DFMT_L8 = 50, 619 | D3DFMT_A8L8 = 51, 620 | D3DFMT_A4L4 = 52, 621 | 622 | D3DFMT_V8U8 = 60, 623 | D3DFMT_L6V5U5 = 61, 624 | D3DFMT_X8L8V8U8 = 62, 625 | D3DFMT_Q8W8V8U8 = 63, 626 | D3DFMT_V16U16 = 64, 627 | D3DFMT_W11V11U10 = 65, 628 | D3DFMT_A2W10V10U10 = 67, 629 | 630 | D3DFMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'), 631 | D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'), 632 | D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'), 633 | D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'), 634 | D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'), 635 | D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'), 636 | D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'), 637 | 638 | D3DFMT_D16_LOCKABLE = 70, 639 | D3DFMT_D32 = 71, 640 | D3DFMT_D15S1 = 73, 641 | D3DFMT_D24S8 = 75, 642 | D3DFMT_D16 = 80, 643 | D3DFMT_D24X8 = 77, 644 | D3DFMT_D24X4S4 = 79, 645 | 646 | D3DFMT_VERTEXDATA = 100, 647 | D3DFMT_INDEX16 = 101, 648 | D3DFMT_INDEX32 = 102, 649 | 650 | D3DFMT_FORCE_DWORD = 0xFFFFFFFF 651 | } D3DFORMAT; 652 | 653 | typedef enum _D3DLIGHTTYPE { 654 | D3DLIGHT_POINT = 1, 655 | D3DLIGHT_SPOT = 2, 656 | D3DLIGHT_DIRECTIONAL = 3, 657 | 658 | D3DLIGHT_FORCE_DWORD = 0x7fffffff 659 | } D3DLIGHTTYPE; 660 | 661 | typedef enum _D3DMATERIALCOLORSOURCE { 662 | D3DMCS_MATERIAL = 0, 663 | D3DMCS_COLOR1 = 1, 664 | D3DMCS_COLOR2 = 2, 665 | 666 | D3DMCS_FORCE_DWORD = 0x7fffffff 667 | } D3DMATERIALCOLORSOURCE; 668 | 669 | typedef enum _D3DMULTISAMPLE_TYPE { 670 | D3DMULTISAMPLE_NONE = 0, 671 | D3DMULTISAMPLE_2_SAMPLES = 2, 672 | D3DMULTISAMPLE_3_SAMPLES = 3, 673 | D3DMULTISAMPLE_4_SAMPLES = 4, 674 | D3DMULTISAMPLE_5_SAMPLES = 5, 675 | D3DMULTISAMPLE_6_SAMPLES = 6, 676 | D3DMULTISAMPLE_7_SAMPLES = 7, 677 | D3DMULTISAMPLE_8_SAMPLES = 8, 678 | D3DMULTISAMPLE_9_SAMPLES = 9, 679 | D3DMULTISAMPLE_10_SAMPLES = 10, 680 | D3DMULTISAMPLE_11_SAMPLES = 11, 681 | D3DMULTISAMPLE_12_SAMPLES = 12, 682 | D3DMULTISAMPLE_13_SAMPLES = 13, 683 | D3DMULTISAMPLE_14_SAMPLES = 14, 684 | D3DMULTISAMPLE_15_SAMPLES = 15, 685 | D3DMULTISAMPLE_16_SAMPLES = 16, 686 | 687 | D3DMULTISAMPLE_FORCE_DWORD = 0x7fffffff 688 | } D3DMULTISAMPLE_TYPE; 689 | 690 | typedef enum _D3DORDERTYPE { 691 | D3DORDER_LINEAR = 1, 692 | D3DORDER_QUADRATIC = 2, 693 | D3DORDER_CUBIC = 3, 694 | D3DORDER_QUINTIC = 5, 695 | 696 | D3DORDER_FORCE_DWORD = 0x7fffffff 697 | } D3DORDERTYPE; 698 | 699 | typedef enum _D3DPATCHEDGESTYLE { 700 | D3DPATCHEDGE_DISCRETE = 0, 701 | D3DPATCHEDGE_CONTINUOUS = 1, 702 | 703 | D3DPATCHEDGE_FORCE_DWORD = 0x7fffffff, 704 | } D3DPATCHEDGESTYLE; 705 | 706 | typedef enum _D3DPOOL { 707 | D3DPOOL_DEFAULT = 0, 708 | D3DPOOL_MANAGED = 1, 709 | D3DPOOL_SYSTEMMEM = 2, 710 | D3DPOOL_SCRATCH = 3, 711 | 712 | D3DPOOL_FORCE_DWORD = 0x7fffffff 713 | } D3DPOOL; 714 | 715 | typedef enum _D3DPRIMITIVETYPE { 716 | D3DPT_POINTLIST = 1, 717 | D3DPT_LINELIST = 2, 718 | D3DPT_LINESTRIP = 3, 719 | D3DPT_TRIANGLELIST = 4, 720 | D3DPT_TRIANGLESTRIP = 5, 721 | D3DPT_TRIANGLEFAN = 6, 722 | 723 | D3DPT_FORCE_DWORD = 0x7fffffff 724 | } D3DPRIMITIVETYPE; 725 | 726 | typedef enum _D3DRENDERSTATETYPE { 727 | D3DRS_ZENABLE = 7, 728 | D3DRS_FILLMODE = 8, 729 | D3DRS_SHADEMODE = 9, 730 | D3DRS_LINEPATTERN = 10, 731 | D3DRS_ZWRITEENABLE = 14, 732 | D3DRS_ALPHATESTENABLE = 15, 733 | D3DRS_LASTPIXEL = 16, 734 | D3DRS_SRCBLEND = 19, 735 | D3DRS_DESTBLEND = 20, 736 | D3DRS_CULLMODE = 22, 737 | D3DRS_ZFUNC = 23, 738 | D3DRS_ALPHAREF = 24, 739 | D3DRS_ALPHAFUNC = 25, 740 | D3DRS_DITHERENABLE = 26, 741 | D3DRS_ALPHABLENDENABLE = 27, 742 | D3DRS_FOGENABLE = 28, 743 | D3DRS_SPECULARENABLE = 29, 744 | D3DRS_ZVISIBLE = 30, 745 | D3DRS_FOGCOLOR = 34, 746 | D3DRS_FOGTABLEMODE = 35, 747 | D3DRS_FOGSTART = 36, 748 | D3DRS_FOGEND = 37, 749 | D3DRS_FOGDENSITY = 38, 750 | D3DRS_EDGEANTIALIAS = 40, 751 | D3DRS_ZBIAS = 47, 752 | D3DRS_RANGEFOGENABLE = 48, 753 | D3DRS_STENCILENABLE = 52, 754 | D3DRS_STENCILFAIL = 53, 755 | D3DRS_STENCILZFAIL = 54, 756 | D3DRS_STENCILPASS = 55, 757 | D3DRS_STENCILFUNC = 56, 758 | D3DRS_STENCILREF = 57, 759 | D3DRS_STENCILMASK = 58, 760 | D3DRS_STENCILWRITEMASK = 59, 761 | D3DRS_TEXTUREFACTOR = 60, 762 | D3DRS_WRAP0 = 128, 763 | D3DRS_WRAP1 = 129, 764 | D3DRS_WRAP2 = 130, 765 | D3DRS_WRAP3 = 131, 766 | D3DRS_WRAP4 = 132, 767 | D3DRS_WRAP5 = 133, 768 | D3DRS_WRAP6 = 134, 769 | D3DRS_WRAP7 = 135, 770 | D3DRS_CLIPPING = 136, 771 | D3DRS_LIGHTING = 137, 772 | D3DRS_AMBIENT = 139, 773 | D3DRS_FOGVERTEXMODE = 140, 774 | D3DRS_COLORVERTEX = 141, 775 | D3DRS_LOCALVIEWER = 142, 776 | D3DRS_NORMALIZENORMALS = 143, 777 | D3DRS_DIFFUSEMATERIALSOURCE = 145, 778 | D3DRS_SPECULARMATERIALSOURCE = 146, 779 | D3DRS_AMBIENTMATERIALSOURCE = 147, 780 | D3DRS_EMISSIVEMATERIALSOURCE = 148, 781 | D3DRS_VERTEXBLEND = 151, 782 | D3DRS_CLIPPLANEENABLE = 152, 783 | D3DRS_SOFTWAREVERTEXPROCESSING = 153, 784 | D3DRS_POINTSIZE = 154, 785 | D3DRS_POINTSIZE_MIN = 155, 786 | D3DRS_POINTSPRITEENABLE = 156, 787 | D3DRS_POINTSCALEENABLE = 157, 788 | D3DRS_POINTSCALE_A = 158, 789 | D3DRS_POINTSCALE_B = 159, 790 | D3DRS_POINTSCALE_C = 160, 791 | D3DRS_MULTISAMPLEANTIALIAS = 161, 792 | D3DRS_MULTISAMPLEMASK = 162, 793 | D3DRS_PATCHEDGESTYLE = 163, 794 | D3DRS_PATCHSEGMENTS = 164, 795 | D3DRS_DEBUGMONITORTOKEN = 165, 796 | D3DRS_POINTSIZE_MAX = 166, 797 | D3DRS_INDEXEDVERTEXBLENDENABLE = 167, 798 | D3DRS_COLORWRITEENABLE = 168, 799 | D3DRS_TWEENFACTOR = 170, 800 | D3DRS_BLENDOP = 171, 801 | D3DRS_POSITIONORDER = 172, 802 | D3DRS_NORMALORDER = 173, 803 | 804 | D3DRS_FORCE_DWORD = 0x7fffffff 805 | } D3DRENDERSTATETYPE; 806 | 807 | typedef enum _D3DRESOURCETYPE { 808 | D3DRTYPE_SURFACE = 1, 809 | D3DRTYPE_VOLUME = 2, 810 | D3DRTYPE_TEXTURE = 3, 811 | D3DRTYPE_VOLUMETEXTURE = 4, 812 | D3DRTYPE_CUBETEXTURE = 5, 813 | D3DRTYPE_VERTEXBUFFER = 6, 814 | D3DRTYPE_INDEXBUFFER = 7, 815 | 816 | D3DRTYPE_FORCE_DWORD = 0x7fffffff 817 | } D3DRESOURCETYPE; 818 | 819 | typedef enum _D3DSHADEMODE { 820 | D3DSHADE_FLAT = 1, 821 | D3DSHADE_GOURAUD = 2, 822 | D3DSHADE_PHONG = 3, 823 | 824 | D3DSHADE_FORCE_DWORD = 0x7fffffff 825 | } D3DSHADEMODE; 826 | 827 | typedef enum _D3DSTATEBLOCKTYPE { 828 | D3DSBT_ALL = 1, 829 | D3DSBT_PIXELSTATE = 2, 830 | D3DSBT_VERTEXSTATE = 3, 831 | 832 | D3DSBT_FORCE_DWORD = 0xffffffff 833 | } D3DSTATEBLOCKTYPE; 834 | 835 | typedef enum _D3DSTENCILOP { 836 | D3DSTENCILOP_KEEP = 1, 837 | D3DSTENCILOP_ZERO = 2, 838 | D3DSTENCILOP_REPLACE = 3, 839 | D3DSTENCILOP_INCRSAT = 4, 840 | D3DSTENCILOP_DECRSAT = 5, 841 | D3DSTENCILOP_INVERT = 6, 842 | D3DSTENCILOP_INCR = 7, 843 | D3DSTENCILOP_DECR = 8, 844 | 845 | D3DSTENCILOP_FORCE_DWORD = 0x7fffffff 846 | } D3DSTENCILOP; 847 | 848 | typedef enum _D3DSWAPEFFECT { 849 | D3DSWAPEFFECT_DISCARD = 1, 850 | D3DSWAPEFFECT_FLIP = 2, 851 | D3DSWAPEFFECT_COPY = 3, 852 | D3DSWAPEFFECT_COPY_VSYNC = 4, 853 | 854 | D3DSWAPEFFECT_FORCE_DWORD = 0xFFFFFFFF 855 | } D3DSWAPEFFECT; 856 | 857 | typedef enum _D3DTEXTUREADDRESS { 858 | D3DTADDRESS_WRAP = 1, 859 | D3DTADDRESS_MIRROR = 2, 860 | D3DTADDRESS_CLAMP = 3, 861 | D3DTADDRESS_BORDER = 4, 862 | D3DTADDRESS_MIRRORONCE = 5, 863 | 864 | D3DTADDRESS_FORCE_DWORD = 0x7fffffff 865 | } D3DTEXTUREADDRESS; 866 | 867 | typedef enum _D3DTEXTUREFILTERTYPE { 868 | D3DTEXF_NONE = 0, 869 | D3DTEXF_POINT = 1, 870 | D3DTEXF_LINEAR = 2, 871 | D3DTEXF_ANISOTROPIC = 3, 872 | D3DTEXF_FLATCUBIC = 4, 873 | D3DTEXF_GAUSSIANCUBIC = 5, 874 | 875 | D3DTEXF_FORCE_DWORD = 0x7fffffff 876 | } D3DTEXTUREFILTERTYPE; 877 | 878 | typedef enum _D3DTEXTUREOP { 879 | D3DTOP_DISABLE = 1, 880 | D3DTOP_SELECTARG1 = 2, 881 | D3DTOP_SELECTARG2 = 3, 882 | D3DTOP_MODULATE = 4, 883 | D3DTOP_MODULATE2X = 5, 884 | D3DTOP_MODULATE4X = 6, 885 | D3DTOP_ADD = 7, 886 | D3DTOP_ADDSIGNED = 8, 887 | D3DTOP_ADDSIGNED2X = 9, 888 | D3DTOP_SUBTRACT = 10, 889 | D3DTOP_ADDSMOOTH = 11, 890 | D3DTOP_BLENDDIFFUSEALPHA = 12, 891 | D3DTOP_BLENDTEXTUREALPHA = 13, 892 | D3DTOP_BLENDFACTORALPHA = 14, 893 | D3DTOP_BLENDTEXTUREALPHAPM = 15, 894 | D3DTOP_BLENDCURRENTALPHA = 16, 895 | D3DTOP_PREMODULATE = 17, 896 | D3DTOP_MODULATEALPHA_ADDCOLOR = 18, 897 | D3DTOP_MODULATECOLOR_ADDALPHA = 19, 898 | D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20, 899 | D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21, 900 | D3DTOP_BUMPENVMAP = 22, 901 | D3DTOP_BUMPENVMAPLUMINANCE = 23, 902 | D3DTOP_DOTPRODUCT3 = 24, 903 | D3DTOP_MULTIPLYADD = 25, 904 | D3DTOP_LERP = 26, 905 | 906 | D3DTOP_FORCE_DWORD = 0x7fffffff, 907 | } D3DTEXTUREOP; 908 | 909 | typedef enum _D3DTEXTURESTAGESTATETYPE { 910 | D3DTSS_COLOROP = 1, 911 | D3DTSS_COLORARG1 = 2, 912 | D3DTSS_COLORARG2 = 3, 913 | D3DTSS_ALPHAOP = 4, 914 | D3DTSS_ALPHAARG1 = 5, 915 | D3DTSS_ALPHAARG2 = 6, 916 | D3DTSS_BUMPENVMAT00 = 7, 917 | D3DTSS_BUMPENVMAT01 = 8, 918 | D3DTSS_BUMPENVMAT10 = 9, 919 | D3DTSS_BUMPENVMAT11 = 10, 920 | D3DTSS_TEXCOORDINDEX = 11, 921 | D3DTSS_ADDRESSU = 13, 922 | D3DTSS_ADDRESSV = 14, 923 | D3DTSS_BORDERCOLOR = 15, 924 | D3DTSS_MAGFILTER = 16, 925 | D3DTSS_MINFILTER = 17, 926 | D3DTSS_MIPFILTER = 18, 927 | D3DTSS_MIPMAPLODBIAS = 19, 928 | D3DTSS_MAXMIPLEVEL = 20, 929 | D3DTSS_MAXANISOTROPY = 21, 930 | D3DTSS_BUMPENVLSCALE = 22, 931 | D3DTSS_BUMPENVLOFFSET = 23, 932 | D3DTSS_TEXTURETRANSFORMFLAGS = 24, 933 | D3DTSS_ADDRESSW = 25, 934 | D3DTSS_COLORARG0 = 26, 935 | D3DTSS_ALPHAARG0 = 27, 936 | D3DTSS_RESULTARG = 28, 937 | 938 | D3DTSS_FORCE_DWORD = 0x7fffffff 939 | } D3DTEXTURESTAGESTATETYPE; 940 | 941 | typedef enum _D3DTEXTURETRANSFORMFLAGS { 942 | D3DTTFF_DISABLE = 0, 943 | D3DTTFF_COUNT1 = 1, 944 | D3DTTFF_COUNT2 = 2, 945 | D3DTTFF_COUNT3 = 3, 946 | D3DTTFF_COUNT4 = 4, 947 | D3DTTFF_PROJECTED = 256, 948 | 949 | D3DTTFF_FORCE_DWORD = 0x7fffffff 950 | } D3DTEXTURETRANSFORMFLAGS; 951 | 952 | typedef enum _D3DTRANSFORMSTATETYPE { 953 | D3DTS_VIEW = 2, 954 | D3DTS_PROJECTION = 3, 955 | D3DTS_TEXTURE0 = 16, 956 | D3DTS_TEXTURE1 = 17, 957 | D3DTS_TEXTURE2 = 18, 958 | D3DTS_TEXTURE3 = 19, 959 | D3DTS_TEXTURE4 = 20, 960 | D3DTS_TEXTURE5 = 21, 961 | D3DTS_TEXTURE6 = 22, 962 | D3DTS_TEXTURE7 = 23, 963 | 964 | D3DTS_FORCE_DWORD = 0x7fffffff 965 | } D3DTRANSFORMSTATETYPE; 966 | 967 | typedef enum _D3DVERTEXBLENDFLAGS { 968 | D3DVBF_DISABLE = 0, 969 | D3DVBF_1WEIGHTS = 1, 970 | D3DVBF_2WEIGHTS = 2, 971 | D3DVBF_3WEIGHTS = 3, 972 | D3DVBF_TWEENING = 255, 973 | D3DVBF_0WEIGHTS = 256 974 | } D3DVERTEXBLENDFLAGS; 975 | 976 | typedef enum _D3DZBUFFERTYPE { 977 | D3DZB_FALSE = 0, 978 | D3DZB_TRUE = 1, 979 | D3DZB_USEW = 2, 980 | 981 | D3DZB_FORCE_DWORD = 0x7fffffff 982 | } D3DZBUFFERTYPE; 983 | 984 | 985 | /***************************************************************************** 986 | * Direct 3D v8 typedefs 987 | */ 988 | typedef DWORD D3DCOLOR; 989 | 990 | /***************************************************************************** 991 | * Direct 3D v8 structures 992 | */ 993 | typedef struct _D3DADAPTER_IDENTIFIER8 { 994 | char Driver[MAX_DEVICE_IDENTIFIER_STRING]; 995 | char Description[MAX_DEVICE_IDENTIFIER_STRING]; 996 | 997 | LARGE_INTEGER DriverVersion; 998 | DWORD VendorId; 999 | DWORD DeviceId; 1000 | DWORD SubSysId; 1001 | DWORD Revision; 1002 | 1003 | GUID DeviceIdentifier; 1004 | 1005 | DWORD WHQLLevel; 1006 | } D3DADAPTER_IDENTIFIER8; 1007 | 1008 | typedef struct _D3DBOX { 1009 | UINT Left; 1010 | UINT Top; 1011 | UINT Right; 1012 | UINT Bottom; 1013 | UINT Front; 1014 | UINT Back; 1015 | } D3DBOX; 1016 | 1017 | typedef struct _D3DCLIPSTATUS8 { 1018 | DWORD ClipUnion; 1019 | DWORD ClipIntersection; 1020 | } D3DCLIPSTATUS8; 1021 | 1022 | typedef struct _D3DCOLORVALUE { 1023 | float r; 1024 | float g; 1025 | float b; 1026 | float a; 1027 | } D3DCOLORVALUE; 1028 | 1029 | typedef struct _D3DDEVICE_CREATION_PARAMETERS { 1030 | UINT AdapterOrdinal; 1031 | D3DDEVTYPE DeviceType; 1032 | HWND hFocusWindow; 1033 | DWORD BehaviorFlags; 1034 | } D3DDEVICE_CREATION_PARAMETERS; 1035 | 1036 | typedef struct _D3DDISPLAYMODE { 1037 | UINT Width; 1038 | UINT Height; 1039 | UINT RefreshRate; 1040 | D3DFORMAT Format; 1041 | } D3DDISPLAYMODE; 1042 | 1043 | typedef struct _D3DGAMMARAMP { 1044 | WORD red [256]; 1045 | WORD green[256]; 1046 | WORD blue [256]; 1047 | } D3DGAMMARAMP; 1048 | 1049 | typedef struct _D3DINDEXBUFFER_DESC { 1050 | D3DFORMAT Format; 1051 | D3DRESOURCETYPE Type; 1052 | DWORD Usage; 1053 | D3DPOOL Pool; 1054 | UINT Size; 1055 | } D3DINDEXBUFFER_DESC; 1056 | 1057 | #ifndef D3DVECTOR_DEFINED 1058 | typedef struct _D3DVECTOR { 1059 | float x; 1060 | float y; 1061 | float z; 1062 | } D3DVECTOR; 1063 | #define D3DVECTOR_DEFINED 1064 | #endif 1065 | 1066 | typedef struct _D3DLIGHT8 { 1067 | D3DLIGHTTYPE Type; 1068 | D3DCOLORVALUE Diffuse; 1069 | D3DCOLORVALUE Specular; 1070 | D3DCOLORVALUE Ambient; 1071 | D3DVECTOR Position; 1072 | D3DVECTOR Direction; 1073 | float Range; 1074 | float Falloff; 1075 | float Attenuation0; 1076 | float Attenuation1; 1077 | float Attenuation2; 1078 | float Theta; 1079 | float Phi; 1080 | } D3DLIGHT8; 1081 | 1082 | typedef struct _D3DLINEPATTERN { 1083 | WORD wRepeatFactor; 1084 | WORD wLinePattern; 1085 | } D3DLINEPATTERN; 1086 | 1087 | typedef struct _D3DLOCKED_BOX { 1088 | INT RowPitch; 1089 | INT SlicePitch; 1090 | void* pBits; 1091 | } D3DLOCKED_BOX; 1092 | 1093 | typedef struct _D3DLOCKED_RECT { 1094 | INT Pitch; 1095 | void* pBits; 1096 | } D3DLOCKED_RECT; 1097 | 1098 | typedef struct _D3DMATERIAL8 { 1099 | D3DCOLORVALUE Diffuse; 1100 | D3DCOLORVALUE Ambient; 1101 | D3DCOLORVALUE Specular; 1102 | D3DCOLORVALUE Emissive; 1103 | float Power; 1104 | } D3DMATERIAL8; 1105 | 1106 | typedef struct _D3DMATRIX { 1107 | union { 1108 | struct { 1109 | float _11, _12, _13, _14; 1110 | float _21, _22, _23, _24; 1111 | float _31, _32, _33, _34; 1112 | float _41, _42, _43, _44; 1113 | } DUMMYSTRUCTNAME; 1114 | float m[4][4]; 1115 | } DUMMYUNIONNAME; 1116 | } D3DMATRIX; 1117 | 1118 | typedef struct _D3DPRESENT_PARAMETERS_ { 1119 | UINT BackBufferWidth; 1120 | UINT BackBufferHeight; 1121 | D3DFORMAT BackBufferFormat; 1122 | UINT BackBufferCount; 1123 | 1124 | D3DMULTISAMPLE_TYPE MultiSampleType; 1125 | 1126 | D3DSWAPEFFECT SwapEffect; 1127 | HWND hDeviceWindow; 1128 | WINBOOL Windowed; 1129 | WINBOOL EnableAutoDepthStencil; 1130 | D3DFORMAT AutoDepthStencilFormat; 1131 | DWORD Flags; 1132 | 1133 | UINT FullScreen_RefreshRateInHz; 1134 | UINT FullScreen_PresentationInterval; 1135 | 1136 | } D3DPRESENT_PARAMETERS; 1137 | 1138 | #define D3DPRESENTFLAG_LOCKABLE_BACKBUFFER 0x00000001 1139 | 1140 | typedef struct _D3DRANGE { 1141 | UINT Offset; 1142 | UINT Size; 1143 | } D3DRANGE; 1144 | 1145 | typedef struct _D3DRASTER_STATUS { 1146 | WINBOOL InVBlank; 1147 | UINT ScanLine; 1148 | } D3DRASTER_STATUS; 1149 | 1150 | typedef struct _D3DRECT { 1151 | LONG x1; 1152 | LONG y1; 1153 | LONG x2; 1154 | LONG y2; 1155 | } D3DRECT; 1156 | 1157 | typedef struct _D3DRECTPATCH_INFO { 1158 | UINT StartVertexOffsetWidth; 1159 | UINT StartVertexOffsetHeight; 1160 | UINT Width; 1161 | UINT Height; 1162 | UINT Stride; 1163 | D3DBASISTYPE Basis; 1164 | D3DORDERTYPE Order; 1165 | } D3DRECTPATCH_INFO; 1166 | 1167 | typedef struct _D3DSURFACE_DESC { 1168 | D3DFORMAT Format; 1169 | D3DRESOURCETYPE Type; 1170 | DWORD Usage; 1171 | D3DPOOL Pool; 1172 | UINT Size; 1173 | D3DMULTISAMPLE_TYPE MultiSampleType; 1174 | UINT Width; 1175 | UINT Height; 1176 | } D3DSURFACE_DESC; 1177 | 1178 | typedef struct _D3DTRIPATCH_INFO { 1179 | UINT StartVertexOffset; 1180 | UINT NumVertices; 1181 | D3DBASISTYPE Basis; 1182 | D3DORDERTYPE Order; 1183 | } D3DTRIPATCH_INFO; 1184 | 1185 | typedef struct _D3DVERTEXBUFFER_DESC { 1186 | D3DFORMAT Format; 1187 | D3DRESOURCETYPE Type; 1188 | DWORD Usage; 1189 | D3DPOOL Pool; 1190 | UINT Size; 1191 | DWORD FVF; 1192 | } D3DVERTEXBUFFER_DESC; 1193 | 1194 | typedef struct _D3DVIEWPORT8 { 1195 | DWORD X; 1196 | DWORD Y; 1197 | DWORD Width; 1198 | DWORD Height; 1199 | float MinZ; 1200 | float MaxZ; 1201 | } D3DVIEWPORT8; 1202 | 1203 | typedef struct _D3DVOLUME_DESC { 1204 | D3DFORMAT Format; 1205 | D3DRESOURCETYPE Type; 1206 | DWORD Usage; 1207 | D3DPOOL Pool; 1208 | UINT Size; 1209 | UINT Width; 1210 | UINT Height; 1211 | UINT Depth; 1212 | } D3DVOLUME_DESC; 1213 | 1214 | #endif /* __WINE_D3D8TYPES_H */ 1215 | -------------------------------------------------------------------------------- /directx_api/d3d9caps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2003 Jason Edmeades 3 | * Raphael Junqueira 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 St, Fifth Floor, Boston, MA 02110-1301, USA 18 | */ 19 | 20 | #ifndef __WINE_D3D9CAPS_H 21 | #define __WINE_D3D9CAPS_H 22 | 23 | /* 24 | * Definitions 25 | */ 26 | #define D3DCAPS_READ_SCANLINE 0x20000 27 | 28 | #define D3DCURSORCAPS_COLOR 1 29 | #define D3DCURSORCAPS_LOWRES 2 30 | 31 | 32 | #define D3DDEVCAPS2_STREAMOFFSET __MSABI_LONG(0x00000001) 33 | #define D3DDEVCAPS2_DMAPNPATCH __MSABI_LONG(0x00000002) 34 | #define D3DDEVCAPS2_ADAPTIVETESSRTPATCH __MSABI_LONG(0x00000004) 35 | #define D3DDEVCAPS2_ADAPTIVETESSNPATCH __MSABI_LONG(0x00000008) 36 | #define D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES __MSABI_LONG(0x00000010) 37 | #define D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH __MSABI_LONG(0x00000020) 38 | #define D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET __MSABI_LONG(0x00000040) 39 | 40 | #define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x0000010 41 | #define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x0000020 42 | #define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x0000040 43 | #define D3DDEVCAPS_TLVERTEXVIDEOMEMORY 0x0000080 44 | #define D3DDEVCAPS_TEXTURESYSTEMMEMORY 0x0000100 45 | #define D3DDEVCAPS_TEXTUREVIDEOMEMORY 0x0000200 46 | #define D3DDEVCAPS_DRAWPRIMTLVERTEX 0x0000400 47 | #define D3DDEVCAPS_CANRENDERAFTERFLIP 0x0000800 48 | #define D3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x0001000 49 | #define D3DDEVCAPS_DRAWPRIMITIVES2 0x0002000 50 | #define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x0004000 51 | #define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x0008000 52 | #define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x0010000 53 | #define D3DDEVCAPS_CANBLTSYSTONONLOCAL 0x0020000 54 | #define D3DDEVCAPS_HWRASTERIZATION 0x0080000 55 | #define D3DDEVCAPS_PUREDEVICE 0x0100000 56 | #define D3DDEVCAPS_QUINTICRTPATCHES 0x0200000 57 | #define D3DDEVCAPS_RTPATCHES 0x0400000 58 | #define D3DDEVCAPS_RTPATCHHANDLEZERO 0x0800000 59 | #define D3DDEVCAPS_NPATCHES 0x1000000 60 | 61 | #define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x00FFFF 62 | #define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x080000 63 | #define D3DFVFCAPS_PSIZE 0x100000 64 | 65 | #define D3DLINECAPS_TEXTURE 0x01 66 | #define D3DLINECAPS_ZTEST 0x02 67 | #define D3DLINECAPS_BLEND 0x04 68 | #define D3DLINECAPS_ALPHACMP 0x08 69 | #define D3DLINECAPS_FOG 0x10 70 | #define D3DLINECAPS_ANTIALIAS 0x20 71 | 72 | #define D3DPBLENDCAPS_ZERO 0x00000001 73 | #define D3DPBLENDCAPS_ONE 0x00000002 74 | #define D3DPBLENDCAPS_SRCCOLOR 0x00000004 75 | #define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008 76 | #define D3DPBLENDCAPS_SRCALPHA 0x00000010 77 | #define D3DPBLENDCAPS_INVSRCALPHA 0x00000020 78 | #define D3DPBLENDCAPS_DESTALPHA 0x00000040 79 | #define D3DPBLENDCAPS_INVDESTALPHA 0x00000080 80 | #define D3DPBLENDCAPS_DESTCOLOR 0x00000100 81 | #define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200 82 | #define D3DPBLENDCAPS_SRCALPHASAT 0x00000400 83 | #define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800 84 | #define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000 85 | #define D3DPBLENDCAPS_BLENDFACTOR 0x00002000 86 | 87 | #define D3DPCMPCAPS_NEVER 0x01 88 | #define D3DPCMPCAPS_LESS 0x02 89 | #define D3DPCMPCAPS_EQUAL 0x04 90 | #define D3DPCMPCAPS_LESSEQUAL 0x08 91 | #define D3DPCMPCAPS_GREATER 0x10 92 | #define D3DPCMPCAPS_NOTEQUAL 0x20 93 | #define D3DPCMPCAPS_GREATEREQUAL 0x40 94 | #define D3DPCMPCAPS_ALWAYS 0x80 95 | 96 | #define D3DPMISCCAPS_MASKZ __MSABI_LONG(0x00000002) 97 | #define D3DPMISCCAPS_LINEPATTERNREP __MSABI_LONG(0x00000004) 98 | #define D3DPMISCCAPS_CULLNONE __MSABI_LONG(0x00000010) 99 | #define D3DPMISCCAPS_CULLCW __MSABI_LONG(0x00000020) 100 | #define D3DPMISCCAPS_CULLCCW __MSABI_LONG(0x00000040) 101 | #define D3DPMISCCAPS_COLORWRITEENABLE __MSABI_LONG(0x00000080) 102 | #define D3DPMISCCAPS_CLIPPLANESCALEDPOINTS __MSABI_LONG(0x00000100) 103 | #define D3DPMISCCAPS_CLIPTLVERTS __MSABI_LONG(0x00000200) 104 | #define D3DPMISCCAPS_TSSARGTEMP __MSABI_LONG(0x00000400) 105 | #define D3DPMISCCAPS_BLENDOP __MSABI_LONG(0x00000800) 106 | #define D3DPMISCCAPS_NULLREFERENCE __MSABI_LONG(0x00001000) 107 | #define D3DPMISCCAPS_INDEPENDENTWRITEMASKS __MSABI_LONG(0x00004000) 108 | #define D3DPMISCCAPS_PERSTAGECONSTANT __MSABI_LONG(0x00008000) 109 | #define D3DPMISCCAPS_FOGANDSPECULARALPHA __MSABI_LONG(0x00010000) 110 | #define D3DPMISCCAPS_SEPARATEALPHABLEND __MSABI_LONG(0x00020000) 111 | #define D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS __MSABI_LONG(0x00040000) 112 | #define D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING __MSABI_LONG(0x00080000) 113 | #define D3DPMISCCAPS_FOGVERTEXCLAMPED __MSABI_LONG(0x00100000) 114 | 115 | 116 | #define D3DPRASTERCAPS_DITHER __MSABI_LONG(0x00000001) 117 | #define D3DPRASTERCAPS_PAT __MSABI_LONG(0x00000008) 118 | #define D3DPRASTERCAPS_ZTEST __MSABI_LONG(0x00000010) 119 | #define D3DPRASTERCAPS_FOGVERTEX __MSABI_LONG(0x00000080) 120 | #define D3DPRASTERCAPS_FOGTABLE __MSABI_LONG(0x00000100) 121 | #define D3DPRASTERCAPS_ANTIALIASEDGES __MSABI_LONG(0x00001000) 122 | #define D3DPRASTERCAPS_MIPMAPLODBIAS __MSABI_LONG(0x00002000) 123 | #define D3DPRASTERCAPS_ZBIAS __MSABI_LONG(0x00004000) 124 | #define D3DPRASTERCAPS_ZBUFFERLESSHSR __MSABI_LONG(0x00008000) 125 | #define D3DPRASTERCAPS_FOGRANGE __MSABI_LONG(0x00010000) 126 | #define D3DPRASTERCAPS_ANISOTROPY __MSABI_LONG(0x00020000) 127 | #define D3DPRASTERCAPS_WBUFFER __MSABI_LONG(0x00040000) 128 | #define D3DPRASTERCAPS_WFOG __MSABI_LONG(0x00100000) 129 | #define D3DPRASTERCAPS_ZFOG __MSABI_LONG(0x00200000) 130 | #define D3DPRASTERCAPS_COLORPERSPECTIVE __MSABI_LONG(0x00400000) 131 | #define D3DPRASTERCAPS_SCISSORTEST __MSABI_LONG(0x01000000) 132 | #define D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS __MSABI_LONG(0x02000000) 133 | #define D3DPRASTERCAPS_DEPTHBIAS __MSABI_LONG(0x04000000) 134 | #define D3DPRASTERCAPS_MULTISAMPLE_TOGGLE __MSABI_LONG(0x08000000) 135 | 136 | #define D3DPRESENT_INTERVAL_DEFAULT 0x00000000 137 | #define D3DPRESENT_INTERVAL_ONE 0x00000001 138 | #define D3DPRESENT_INTERVAL_TWO 0x00000002 139 | #define D3DPRESENT_INTERVAL_THREE 0x00000004 140 | #define D3DPRESENT_INTERVAL_FOUR 0x00000008 141 | #define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000 142 | 143 | #define D3DPSHADECAPS_COLORGOURAUDRGB 0x00008 144 | #define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00200 145 | #define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x04000 146 | #define D3DPSHADECAPS_FOGGOURAUD 0x80000 147 | 148 | #define D3DPTADDRESSCAPS_WRAP 0x01 149 | #define D3DPTADDRESSCAPS_MIRROR 0x02 150 | #define D3DPTADDRESSCAPS_CLAMP 0x04 151 | #define D3DPTADDRESSCAPS_BORDER 0x08 152 | #define D3DPTADDRESSCAPS_INDEPENDENTUV 0x10 153 | #define D3DPTADDRESSCAPS_MIRRORONCE 0x20 154 | 155 | #define D3DPTEXTURECAPS_PERSPECTIVE __MSABI_LONG(0x00000001) 156 | #define D3DPTEXTURECAPS_POW2 __MSABI_LONG(0x00000002) 157 | #define D3DPTEXTURECAPS_ALPHA __MSABI_LONG(0x00000004) 158 | #define D3DPTEXTURECAPS_SQUAREONLY __MSABI_LONG(0x00000020) 159 | #define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE __MSABI_LONG(0x00000040) 160 | #define D3DPTEXTURECAPS_ALPHAPALETTE __MSABI_LONG(0x00000080) 161 | #define D3DPTEXTURECAPS_NONPOW2CONDITIONAL __MSABI_LONG(0x00000100) 162 | #define D3DPTEXTURECAPS_PROJECTED __MSABI_LONG(0x00000400) 163 | #define D3DPTEXTURECAPS_CUBEMAP __MSABI_LONG(0x00000800) 164 | #define D3DPTEXTURECAPS_VOLUMEMAP __MSABI_LONG(0x00002000) 165 | #define D3DPTEXTURECAPS_MIPMAP __MSABI_LONG(0x00004000) 166 | #define D3DPTEXTURECAPS_MIPVOLUMEMAP __MSABI_LONG(0x00008000) 167 | #define D3DPTEXTURECAPS_MIPCUBEMAP __MSABI_LONG(0x00010000) 168 | #define D3DPTEXTURECAPS_CUBEMAP_POW2 __MSABI_LONG(0x00020000) 169 | #define D3DPTEXTURECAPS_VOLUMEMAP_POW2 __MSABI_LONG(0x00040000) 170 | #define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV __MSABI_LONG(0x00200000) 171 | 172 | #define D3DPTFILTERCAPS_MINFPOINT 0x00000100 173 | #define D3DPTFILTERCAPS_MINFLINEAR 0x00000200 174 | #define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400 175 | #define D3DPTFILTERCAPS_MINFPYRAMIDALQUAD 0x00000800 176 | #define D3DPTFILTERCAPS_MINFGAUSSIANQUAD 0x00001000 177 | #define D3DPTFILTERCAPS_MIPFPOINT 0x00010000 178 | #define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000 179 | #define D3DPTFILTERCAPS_MAGFPOINT 0x01000000 180 | #define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000 181 | #define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000 182 | #define D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD 0x08000000 183 | #define D3DPTFILTERCAPS_MAGFGAUSSIANQUAD 0x10000000 184 | 185 | #define D3DSTENCILCAPS_KEEP 0x01 186 | #define D3DSTENCILCAPS_ZERO 0x02 187 | #define D3DSTENCILCAPS_REPLACE 0x04 188 | #define D3DSTENCILCAPS_INCRSAT 0x08 189 | #define D3DSTENCILCAPS_DECRSAT 0x10 190 | #define D3DSTENCILCAPS_INVERT 0x20 191 | #define D3DSTENCILCAPS_INCR 0x40 192 | #define D3DSTENCILCAPS_DECR 0x80 193 | #define D3DSTENCILCAPS_TWOSIDED 0x100 194 | 195 | #define D3DTEXOPCAPS_DISABLE 0x0000001 196 | #define D3DTEXOPCAPS_SELECTARG1 0x0000002 197 | #define D3DTEXOPCAPS_SELECTARG2 0x0000004 198 | #define D3DTEXOPCAPS_MODULATE 0x0000008 199 | #define D3DTEXOPCAPS_MODULATE2X 0x0000010 200 | #define D3DTEXOPCAPS_MODULATE4X 0x0000020 201 | #define D3DTEXOPCAPS_ADD 0x0000040 202 | #define D3DTEXOPCAPS_ADDSIGNED 0x0000080 203 | #define D3DTEXOPCAPS_ADDSIGNED2X 0x0000100 204 | #define D3DTEXOPCAPS_SUBTRACT 0x0000200 205 | #define D3DTEXOPCAPS_ADDSMOOTH 0x0000400 206 | #define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x0000800 207 | #define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x0001000 208 | #define D3DTEXOPCAPS_BLENDFACTORALPHA 0x0002000 209 | #define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x0004000 210 | #define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x0008000 211 | #define D3DTEXOPCAPS_PREMODULATE 0x0010000 212 | #define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x0020000 213 | #define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x0040000 214 | #define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x0080000 215 | #define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x0100000 216 | #define D3DTEXOPCAPS_BUMPENVMAP 0x0200000 217 | #define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x0400000 218 | #define D3DTEXOPCAPS_DOTPRODUCT3 0x0800000 219 | #define D3DTEXOPCAPS_MULTIPLYADD 0x1000000 220 | #define D3DTEXOPCAPS_LERP 0x2000000 221 | 222 | #define D3DVTXPCAPS_TEXGEN __MSABI_LONG(0x00000001) 223 | #define D3DVTXPCAPS_MATERIALSOURCE7 __MSABI_LONG(0x00000002) 224 | #define D3DVTXPCAPS_DIRECTIONALLIGHTS __MSABI_LONG(0x00000008) 225 | #define D3DVTXPCAPS_POSITIONALLIGHTS __MSABI_LONG(0x00000010) 226 | #define D3DVTXPCAPS_LOCALVIEWER __MSABI_LONG(0x00000020) 227 | #define D3DVTXPCAPS_TWEENING __MSABI_LONG(0x00000040) 228 | #define D3DVTXPCAPS_TEXGEN_SPHEREMAP __MSABI_LONG(0x00000100) 229 | #define D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER __MSABI_LONG(0x00000200) 230 | 231 | #define D3DDTCAPS_UBYTE4 __MSABI_LONG(0x00000001) 232 | #define D3DDTCAPS_UBYTE4N __MSABI_LONG(0x00000002) 233 | #define D3DDTCAPS_SHORT2N __MSABI_LONG(0x00000004) 234 | #define D3DDTCAPS_SHORT4N __MSABI_LONG(0x00000008) 235 | #define D3DDTCAPS_USHORT2N __MSABI_LONG(0x00000010) 236 | #define D3DDTCAPS_USHORT4N __MSABI_LONG(0x00000020) 237 | #define D3DDTCAPS_UDEC3 __MSABI_LONG(0x00000040) 238 | #define D3DDTCAPS_DEC3N __MSABI_LONG(0x00000080) 239 | #define D3DDTCAPS_FLOAT16_2 __MSABI_LONG(0x00000100) 240 | #define D3DDTCAPS_FLOAT16_4 __MSABI_LONG(0x00000200) 241 | 242 | #define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD __MSABI_LONG(0x00000020) 243 | #define D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION __MSABI_LONG(0x00000080) 244 | #define D3DCAPS3_COPY_TO_VIDMEM __MSABI_LONG(0x00000100) 245 | #define D3DCAPS3_COPY_TO_SYSTEMMEM __MSABI_LONG(0x00000200) 246 | #define D3DCAPS3_RESERVED __MSABI_LONG(0x8000001F) 247 | 248 | #define D3DCAPS2_NO2DDURING3DSCENE __MSABI_LONG(0x00000002) 249 | #define D3DCAPS2_FULLSCREENGAMMA __MSABI_LONG(0x00020000) 250 | #define D3DCAPS2_CANRENDERWINDOWED __MSABI_LONG(0x00080000) 251 | #define D3DCAPS2_CANCALIBRATEGAMMA __MSABI_LONG(0x00100000) 252 | #define D3DCAPS2_RESERVED __MSABI_LONG(0x02000000) 253 | #define D3DCAPS2_CANMANAGERESOURCE __MSABI_LONG(0x10000000) 254 | #define D3DCAPS2_DYNAMICTEXTURES __MSABI_LONG(0x20000000) 255 | #define D3DCAPS2_CANAUTOGENMIPMAP __MSABI_LONG(0x40000000) 256 | 257 | 258 | #define D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH 24 259 | #define D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH 0 260 | #define D3DVS20_MAX_NUMTEMPS 32 261 | #define D3DVS20_MIN_NUMTEMPS 12 262 | #define D3DVS20_MAX_STATICFLOWCONTROLDEPTH 4 263 | #define D3DVS20_MIN_STATICFLOWCONTROLDEPTH 1 264 | 265 | #define D3DVS20CAPS_PREDICATION (1 << 0) 266 | 267 | #define D3DPS20CAPS_ARBITRARYSWIZZLE (1 << 0) 268 | #define D3DPS20CAPS_GRADIENTINSTRUCTIONS (1 << 1) 269 | #define D3DPS20CAPS_PREDICATION (1 << 2) 270 | #define D3DPS20CAPS_NODEPENDENTREADLIMIT (1 << 3) 271 | #define D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT (1 << 4) 272 | 273 | #define D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH 24 274 | #define D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH 0 275 | #define D3DPS20_MAX_NUMTEMPS 32 276 | #define D3DPS20_MIN_NUMTEMPS 12 277 | #define D3DPS20_MAX_STATICFLOWCONTROLDEPTH 4 278 | #define D3DPS20_MIN_STATICFLOWCONTROLDEPTH 0 279 | #define D3DPS20_MAX_NUMINSTRUCTIONSLOTS 512 280 | #define D3DPS20_MIN_NUMINSTRUCTIONSLOTS 96 281 | 282 | #define D3DMIN30SHADERINSTRUCTIONS 512 283 | #define D3DMAX30SHADERINSTRUCTIONS 32768 284 | 285 | 286 | typedef struct _D3DVSHADERCAPS2_0 { 287 | DWORD Caps; 288 | INT DynamicFlowControlDepth; 289 | INT NumTemps; 290 | INT StaticFlowControlDepth; 291 | } D3DVSHADERCAPS2_0; 292 | 293 | typedef struct _D3DPSHADERCAPS2_0 { 294 | DWORD Caps; 295 | INT DynamicFlowControlDepth; 296 | INT NumTemps; 297 | INT StaticFlowControlDepth; 298 | INT NumInstructionSlots; 299 | } D3DPSHADERCAPS2_0; 300 | 301 | /* 302 | * The d3dcaps9 structure 303 | */ 304 | typedef struct _D3DCAPS9 { 305 | D3DDEVTYPE DeviceType; 306 | UINT AdapterOrdinal; 307 | 308 | DWORD Caps; 309 | DWORD Caps2; 310 | DWORD Caps3; 311 | DWORD PresentationIntervals; 312 | 313 | DWORD CursorCaps; 314 | 315 | DWORD DevCaps; 316 | 317 | DWORD PrimitiveMiscCaps; 318 | DWORD RasterCaps; 319 | DWORD ZCmpCaps; 320 | DWORD SrcBlendCaps; 321 | DWORD DestBlendCaps; 322 | DWORD AlphaCmpCaps; 323 | DWORD ShadeCaps; 324 | DWORD TextureCaps; 325 | DWORD TextureFilterCaps; 326 | DWORD CubeTextureFilterCaps; 327 | DWORD VolumeTextureFilterCaps; 328 | DWORD TextureAddressCaps; 329 | DWORD VolumeTextureAddressCaps; 330 | 331 | DWORD LineCaps; 332 | 333 | DWORD MaxTextureWidth, MaxTextureHeight; 334 | DWORD MaxVolumeExtent; 335 | 336 | DWORD MaxTextureRepeat; 337 | DWORD MaxTextureAspectRatio; 338 | DWORD MaxAnisotropy; 339 | float MaxVertexW; 340 | 341 | float GuardBandLeft; 342 | float GuardBandTop; 343 | float GuardBandRight; 344 | float GuardBandBottom; 345 | 346 | float ExtentsAdjust; 347 | DWORD StencilCaps; 348 | 349 | DWORD FVFCaps; 350 | DWORD TextureOpCaps; 351 | DWORD MaxTextureBlendStages; 352 | DWORD MaxSimultaneousTextures; 353 | 354 | DWORD VertexProcessingCaps; 355 | DWORD MaxActiveLights; 356 | DWORD MaxUserClipPlanes; 357 | DWORD MaxVertexBlendMatrices; 358 | DWORD MaxVertexBlendMatrixIndex; 359 | 360 | float MaxPointSize; 361 | 362 | DWORD MaxPrimitiveCount; 363 | DWORD MaxVertexIndex; 364 | DWORD MaxStreams; 365 | DWORD MaxStreamStride; 366 | 367 | DWORD VertexShaderVersion; 368 | DWORD MaxVertexShaderConst; 369 | 370 | DWORD PixelShaderVersion; 371 | float PixelShader1xMaxValue; 372 | 373 | /* DX 9 */ 374 | DWORD DevCaps2; 375 | 376 | float MaxNpatchTessellationLevel; 377 | DWORD Reserved5; 378 | 379 | UINT MasterAdapterOrdinal; 380 | UINT AdapterOrdinalInGroup; 381 | UINT NumberOfAdaptersInGroup; 382 | DWORD DeclTypes; 383 | DWORD NumSimultaneousRTs; 384 | DWORD StretchRectFilterCaps; 385 | D3DVSHADERCAPS2_0 VS20Caps; 386 | D3DPSHADERCAPS2_0 PS20Caps; 387 | DWORD VertexTextureFilterCaps; 388 | DWORD MaxVShaderInstructionsExecuted; 389 | DWORD MaxPShaderInstructionsExecuted; 390 | DWORD MaxVertexShader30InstructionSlots; 391 | DWORD MaxPixelShader30InstructionSlots; 392 | 393 | } D3DCAPS9; 394 | 395 | #endif 396 | -------------------------------------------------------------------------------- /directx_api/d3dcaps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2000 Peter Hunnisett 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 | */ 18 | 19 | #ifndef __WINE_D3DCAPS_H 20 | #define __WINE_D3DCAPS_H 21 | 22 | #include 23 | 24 | typedef struct _D3DTRANSFORMCAPS { 25 | DWORD dwSize; 26 | DWORD dwCaps; 27 | } D3DTRANSFORMCAPS, *LPD3DTRANSFORMCAPS; 28 | 29 | #define D3DTRANSFORMCAPS_CLIP __MSABI_LONG(0x00000001) 30 | 31 | typedef struct _D3DLIGHTINGCAPS { 32 | DWORD dwSize; 33 | DWORD dwCaps; 34 | DWORD dwLightingModel; 35 | DWORD dwNumLights; 36 | } D3DLIGHTINGCAPS, *LPD3DLIGHTINGCAPS; 37 | 38 | #define D3DLIGHTINGMODEL_RGB 0x00000001 39 | #define D3DLIGHTINGMODEL_MONO 0x00000002 40 | 41 | #define D3DLIGHTCAPS_POINT 0x00000001 42 | #define D3DLIGHTCAPS_SPOT 0x00000002 43 | #define D3DLIGHTCAPS_DIRECTIONAL 0x00000004 44 | #define D3DLIGHTCAPS_PARALLELPOINT 0x00000008 45 | #define D3DLIGHTCAPS_GLSPOT 0x00000010 46 | 47 | typedef struct _D3dPrimCaps { 48 | DWORD dwSize; 49 | DWORD dwMiscCaps; 50 | DWORD dwRasterCaps; 51 | DWORD dwZCmpCaps; 52 | DWORD dwSrcBlendCaps; 53 | DWORD dwDestBlendCaps; 54 | DWORD dwAlphaCmpCaps; 55 | DWORD dwShadeCaps; 56 | DWORD dwTextureCaps; 57 | DWORD dwTextureFilterCaps; 58 | DWORD dwTextureBlendCaps; 59 | DWORD dwTextureAddressCaps; 60 | DWORD dwStippleWidth; 61 | DWORD dwStippleHeight; 62 | } D3DPRIMCAPS, *LPD3DPRIMCAPS; 63 | 64 | #define D3DPMISCCAPS_MASKPLANES 0x00000001 65 | #define D3DPMISCCAPS_MASKZ 0x00000002 66 | #define D3DPMISCCAPS_LINEPATTERNREP 0x00000004 67 | #define D3DPMISCCAPS_CONFORMANT 0x00000008 68 | #define D3DPMISCCAPS_CULLNONE 0x00000010 69 | #define D3DPMISCCAPS_CULLCW 0x00000020 70 | #define D3DPMISCCAPS_CULLCCW 0x00000040 71 | 72 | #define D3DPRASTERCAPS_DITHER 0x00000001 73 | #define D3DPRASTERCAPS_ROP2 0x00000002 74 | #define D3DPRASTERCAPS_XOR 0x00000004 75 | #define D3DPRASTERCAPS_PAT 0x00000008 76 | #define D3DPRASTERCAPS_ZTEST 0x00000010 77 | #define D3DPRASTERCAPS_SUBPIXEL 0x00000020 78 | #define D3DPRASTERCAPS_SUBPIXELX 0x00000040 79 | #define D3DPRASTERCAPS_FOGVERTEX 0x00000080 80 | #define D3DPRASTERCAPS_FOGTABLE 0x00000100 81 | #define D3DPRASTERCAPS_STIPPLE 0x00000200 82 | #define D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT 0x00000400 83 | #define D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT 0x00000800 84 | #define D3DPRASTERCAPS_ANTIALIASEDGES 0x00001000 85 | #define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000 86 | #define D3DPRASTERCAPS_ZBIAS 0x00004000 87 | #define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000 88 | #define D3DPRASTERCAPS_FOGRANGE 0x00010000 89 | #define D3DPRASTERCAPS_ANISOTROPY 0x00020000 90 | #define D3DPRASTERCAPS_WBUFFER 0x00040000 91 | #define D3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT 0x00080000 92 | #define D3DPRASTERCAPS_WFOG 0x00100000 93 | #define D3DPRASTERCAPS_ZFOG 0x00200000 94 | 95 | #define D3DPCMPCAPS_NEVER 0x00000001 96 | #define D3DPCMPCAPS_LESS 0x00000002 97 | #define D3DPCMPCAPS_EQUAL 0x00000004 98 | #define D3DPCMPCAPS_LESSEQUAL 0x00000008 99 | #define D3DPCMPCAPS_GREATER 0x00000010 100 | #define D3DPCMPCAPS_NOTEQUAL 0x00000020 101 | #define D3DPCMPCAPS_GREATEREQUAL 0x00000040 102 | #define D3DPCMPCAPS_ALWAYS 0x00000080 103 | 104 | #define D3DPBLENDCAPS_ZERO 0x00000001 105 | #define D3DPBLENDCAPS_ONE 0x00000002 106 | #define D3DPBLENDCAPS_SRCCOLOR 0x00000004 107 | #define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008 108 | #define D3DPBLENDCAPS_SRCALPHA 0x00000010 109 | #define D3DPBLENDCAPS_INVSRCALPHA 0x00000020 110 | #define D3DPBLENDCAPS_DESTALPHA 0x00000040 111 | #define D3DPBLENDCAPS_INVDESTALPHA 0x00000080 112 | #define D3DPBLENDCAPS_DESTCOLOR 0x00000100 113 | #define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200 114 | #define D3DPBLENDCAPS_SRCALPHASAT 0x00000400 115 | #define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800 116 | #define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000 117 | 118 | #define D3DPSHADECAPS_COLORFLATMONO 0x00000001 119 | #define D3DPSHADECAPS_COLORFLATRGB 0x00000002 120 | #define D3DPSHADECAPS_COLORGOURAUDMONO 0x00000004 121 | #define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008 122 | #define D3DPSHADECAPS_COLORPHONGMONO 0x00000010 123 | #define D3DPSHADECAPS_COLORPHONGRGB 0x00000020 124 | 125 | #define D3DPSHADECAPS_SPECULARFLATMONO 0x00000040 126 | #define D3DPSHADECAPS_SPECULARFLATRGB 0x00000080 127 | #define D3DPSHADECAPS_SPECULARGOURAUDMONO 0x00000100 128 | #define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200 129 | #define D3DPSHADECAPS_SPECULARPHONGMONO 0x00000400 130 | #define D3DPSHADECAPS_SPECULARPHONGRGB 0x00000800 131 | 132 | #define D3DPSHADECAPS_ALPHAFLATBLEND 0x00001000 133 | #define D3DPSHADECAPS_ALPHAFLATSTIPPLED 0x00002000 134 | #define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000 135 | #define D3DPSHADECAPS_ALPHAGOURAUDSTIPPLED 0x00008000 136 | #define D3DPSHADECAPS_ALPHAPHONGBLEND 0x00010000 137 | #define D3DPSHADECAPS_ALPHAPHONGSTIPPLED 0x00020000 138 | 139 | #define D3DPSHADECAPS_FOGFLAT 0x00040000 140 | #define D3DPSHADECAPS_FOGGOURAUD 0x00080000 141 | #define D3DPSHADECAPS_FOGPHONG 0x00100000 142 | 143 | #define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001 144 | #define D3DPTEXTURECAPS_POW2 0x00000002 145 | #define D3DPTEXTURECAPS_ALPHA 0x00000004 146 | #define D3DPTEXTURECAPS_TRANSPARENCY 0x00000008 147 | #define D3DPTEXTURECAPS_BORDER 0x00000010 148 | #define D3DPTEXTURECAPS_SQUAREONLY 0x00000020 149 | #define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040 150 | #define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080 151 | #define D3DPTEXTURECAPS_NONPOW2CONDITIONAL __MSABI_LONG(0x00000100) 152 | /* yes actually 0x00000200 is unused - or at least unreleased */ 153 | #define D3DPTEXTURECAPS_PROJECTED 0x00000400 154 | #define D3DPTEXTURECAPS_CUBEMAP 0x00000800 155 | #define D3DPTEXTURECAPS_COLORKEYBLEND 0x00001000 156 | 157 | #define D3DPTFILTERCAPS_NEAREST 0x00000001 158 | #define D3DPTFILTERCAPS_LINEAR 0x00000002 159 | #define D3DPTFILTERCAPS_MIPNEAREST 0x00000004 160 | #define D3DPTFILTERCAPS_MIPLINEAR 0x00000008 161 | #define D3DPTFILTERCAPS_LINEARMIPNEAREST 0x00000010 162 | #define D3DPTFILTERCAPS_LINEARMIPLINEAR 0x00000020 163 | /* yes - missing numbers */ 164 | #define D3DPTFILTERCAPS_MINFPOINT 0x00000100 165 | #define D3DPTFILTERCAPS_MINFLINEAR 0x00000200 166 | #define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400 167 | /* yes - missing numbers */ 168 | #define D3DPTFILTERCAPS_MIPFPOINT 0x00010000 169 | #define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000 170 | /* yes - missing numbers */ 171 | #define D3DPTFILTERCAPS_MAGFPOINT 0x01000000 172 | #define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000 173 | #define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000 174 | #define D3DPTFILTERCAPS_MAGFAFLATCUBIC 0x08000000 175 | #define D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC 0x10000000 176 | 177 | #define D3DPTBLENDCAPS_DECAL 0x00000001 178 | #define D3DPTBLENDCAPS_MODULATE 0x00000002 179 | #define D3DPTBLENDCAPS_DECALALPHA 0x00000004 180 | #define D3DPTBLENDCAPS_MODULATEALPHA 0x00000008 181 | #define D3DPTBLENDCAPS_DECALMASK 0x00000010 182 | #define D3DPTBLENDCAPS_MODULATEMASK 0x00000020 183 | #define D3DPTBLENDCAPS_COPY 0x00000040 184 | #define D3DPTBLENDCAPS_ADD 0x00000080 185 | 186 | #define D3DPTADDRESSCAPS_WRAP 0x00000001 187 | #define D3DPTADDRESSCAPS_MIRROR 0x00000002 188 | #define D3DPTADDRESSCAPS_CLAMP 0x00000004 189 | #define D3DPTADDRESSCAPS_BORDER 0x00000008 190 | #define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010 191 | 192 | 193 | typedef struct _D3DDeviceDesc { 194 | DWORD dwSize; 195 | DWORD dwFlags; 196 | D3DCOLORMODEL dcmColorModel; 197 | DWORD dwDevCaps; 198 | D3DTRANSFORMCAPS dtcTransformCaps; 199 | WINBOOL bClipping; 200 | D3DLIGHTINGCAPS dlcLightingCaps; 201 | D3DPRIMCAPS dpcLineCaps; 202 | D3DPRIMCAPS dpcTriCaps; 203 | DWORD dwDeviceRenderBitDepth; 204 | DWORD dwDeviceZBufferBitDepth; 205 | DWORD dwMaxBufferSize; 206 | DWORD dwMaxVertexCount; 207 | 208 | DWORD dwMinTextureWidth,dwMinTextureHeight; 209 | DWORD dwMaxTextureWidth,dwMaxTextureHeight; 210 | DWORD dwMinStippleWidth,dwMaxStippleWidth; 211 | DWORD dwMinStippleHeight,dwMaxStippleHeight; 212 | 213 | DWORD dwMaxTextureRepeat; 214 | DWORD dwMaxTextureAspectRatio; 215 | DWORD dwMaxAnisotropy; 216 | 217 | D3DVALUE dvGuardBandLeft; 218 | D3DVALUE dvGuardBandTop; 219 | D3DVALUE dvGuardBandRight; 220 | D3DVALUE dvGuardBandBottom; 221 | 222 | D3DVALUE dvExtentsAdjust; 223 | DWORD dwStencilCaps; 224 | 225 | DWORD dwFVFCaps; 226 | DWORD dwTextureOpCaps; 227 | WORD wMaxTextureBlendStages; 228 | WORD wMaxSimultaneousTextures; 229 | } D3DDEVICEDESC,*LPD3DDEVICEDESC; 230 | #define D3DDEVICEDESCSIZE (sizeof(D3DDEVICEDESC)) 231 | 232 | typedef struct _D3DDeviceDesc7 { 233 | DWORD dwDevCaps; 234 | D3DPRIMCAPS dpcLineCaps; 235 | D3DPRIMCAPS dpcTriCaps; 236 | DWORD dwDeviceRenderBitDepth; 237 | DWORD dwDeviceZBufferBitDepth; 238 | 239 | DWORD dwMinTextureWidth, dwMinTextureHeight; 240 | DWORD dwMaxTextureWidth, dwMaxTextureHeight; 241 | 242 | DWORD dwMaxTextureRepeat; 243 | DWORD dwMaxTextureAspectRatio; 244 | DWORD dwMaxAnisotropy; 245 | 246 | D3DVALUE dvGuardBandLeft; 247 | D3DVALUE dvGuardBandTop; 248 | D3DVALUE dvGuardBandRight; 249 | D3DVALUE dvGuardBandBottom; 250 | 251 | D3DVALUE dvExtentsAdjust; 252 | DWORD dwStencilCaps; 253 | DWORD dwFVFCaps; 254 | DWORD dwTextureOpCaps; 255 | WORD wMaxTextureBlendStages; 256 | WORD wMaxSimultaneousTextures; 257 | 258 | DWORD dwMaxActiveLights; 259 | D3DVALUE dvMaxVertexW; 260 | GUID deviceGUID; 261 | 262 | WORD wMaxUserClipPlanes; 263 | WORD wMaxVertexBlendMatrices; 264 | 265 | DWORD dwVertexProcessingCaps; 266 | 267 | DWORD dwReserved1; 268 | DWORD dwReserved2; 269 | DWORD dwReserved3; 270 | DWORD dwReserved4; 271 | } D3DDEVICEDESC7, *LPD3DDEVICEDESC7; 272 | #define D3DDEVICEDESC7SIZE (sizeof(D3DDEVICEDESC7)) 273 | 274 | #define D3DDD_COLORMODEL 0x00000001 275 | #define D3DDD_DEVCAPS 0x00000002 276 | #define D3DDD_TRANSFORMCAPS 0x00000004 277 | #define D3DDD_LIGHTINGCAPS 0x00000008 278 | #define D3DDD_BCLIPPING 0x00000010 279 | #define D3DDD_LINECAPS 0x00000020 280 | #define D3DDD_TRICAPS 0x00000040 281 | #define D3DDD_DEVICERENDERBITDEPTH 0x00000080 282 | #define D3DDD_DEVICEZBUFFERBITDEPTH 0x00000100 283 | #define D3DDD_MAXBUFFERSIZE 0x00000200 284 | #define D3DDD_MAXVERTEXCOUNT 0x00000400 285 | 286 | #define D3DDEVCAPS_FLOATTLVERTEX 0x00000001 287 | #define D3DDEVCAPS_SORTINCREASINGZ 0x00000002 288 | #define D3DDEVCAPS_SORTDECREASINGZ 0X00000004 289 | #define D3DDEVCAPS_SORTEXACT 0x00000008 290 | #define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010 291 | #define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020 292 | #define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040 293 | #define D3DDEVCAPS_TLVERTEXVIDEOMEMORY 0x00000080 294 | #define D3DDEVCAPS_TEXTURESYSTEMMEMORY 0x00000100 295 | #define D3DDEVCAPS_TEXTUREVIDEOMEMORY 0x00000200 296 | #define D3DDEVCAPS_DRAWPRIMTLVERTEX 0x00000400 297 | #define D3DDEVCAPS_CANRENDERAFTERFLIP 0x00000800 298 | #define D3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x00001000 299 | #define D3DDEVCAPS_DRAWPRIMITIVES2 0x00002000 300 | #define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000 301 | #define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000 302 | #define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x00010000 303 | #define D3DDEVCAPS_CANBLTSYSTONONLOCAL 0x00020000 304 | #define D3DDEVCAPS_HWRASTERIZATION 0x00080000 305 | 306 | #define D3DSTENCILCAPS_KEEP 0x00000001 307 | #define D3DSTENCILCAPS_ZERO 0x00000002 308 | #define D3DSTENCILCAPS_REPLACE 0x00000004 309 | #define D3DSTENCILCAPS_INCRSAT 0x00000008 310 | #define D3DSTENCILCAPS_DECRSAT 0x00000010 311 | #define D3DSTENCILCAPS_INVERT 0x00000020 312 | #define D3DSTENCILCAPS_INCR 0x00000040 313 | #define D3DSTENCILCAPS_DECR 0x00000080 314 | 315 | #define D3DTEXOPCAPS_DISABLE 0x00000001 316 | #define D3DTEXOPCAPS_SELECTARG1 0x00000002 317 | #define D3DTEXOPCAPS_SELECTARG2 0x00000004 318 | #define D3DTEXOPCAPS_MODULATE 0x00000008 319 | #define D3DTEXOPCAPS_MODULATE2X 0x00000010 320 | #define D3DTEXOPCAPS_MODULATE4X 0x00000020 321 | #define D3DTEXOPCAPS_ADD 0x00000040 322 | #define D3DTEXOPCAPS_ADDSIGNED 0x00000080 323 | #define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100 324 | #define D3DTEXOPCAPS_SUBTRACT 0x00000200 325 | #define D3DTEXOPCAPS_ADDSMOOTH 0x00000400 326 | #define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800 327 | #define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000 328 | #define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000 329 | #define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000 330 | #define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000 331 | #define D3DTEXOPCAPS_PREMODULATE 0x00010000 332 | #define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000 333 | #define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000 334 | #define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000 335 | #define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000 336 | #define D3DTEXOPCAPS_BUMPENVMAP 0x00200000 337 | #define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000 338 | #define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000 339 | 340 | #define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000FFFF 341 | #define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000 342 | 343 | #define D3DVTXPCAPS_TEXGEN 0x00000001 344 | #define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002 345 | #define D3DVTXPCAPS_VERTEXFOG 0x00000004 346 | #define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008 347 | #define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010 348 | #define D3DVTXPCAPS_LOCALVIEWER 0x00000020 349 | 350 | typedef HRESULT (CALLBACK *LPD3DENUMDEVICESCALLBACK)(GUID *guid, char *description, char *name, 351 | D3DDEVICEDESC *hal_desc, D3DDEVICEDESC *hel_desc, void *ctx); 352 | typedef HRESULT (CALLBACK *LPD3DENUMDEVICESCALLBACK7)(char *description, char *name, D3DDEVICEDESC7 *desc, void *ctx); 353 | 354 | #define D3DFDS_COLORMODEL 0x00000001 355 | #define D3DFDS_GUID 0x00000002 356 | #define D3DFDS_HARDWARE 0x00000004 357 | #define D3DFDS_TRIANGLES 0x00000008 358 | #define D3DFDS_LINES 0x00000010 359 | #define D3DFDS_MISCCAPS 0x00000020 360 | #define D3DFDS_RASTERCAPS 0x00000040 361 | #define D3DFDS_ZCMPCAPS 0x00000080 362 | #define D3DFDS_ALPHACMPCAPS 0x00000100 363 | #define D3DFDS_SRCBLENDCAPS 0x00000200 364 | #define D3DFDS_DSTBLENDCAPS 0x00000400 365 | #define D3DFDS_SHADECAPS 0x00000800 366 | #define D3DFDS_TEXTURECAPS 0x00001000 367 | #define D3DFDS_TEXTUREFILTERCAPS 0x00002000 368 | #define D3DFDS_TEXTUREBLENDCAPS 0x00004000 369 | #define D3DFDS_TEXTUREADDRESSCAPS 0x00008000 370 | 371 | typedef struct _D3DFINDDEVICESEARCH { 372 | DWORD dwSize; 373 | DWORD dwFlags; 374 | WINBOOL bHardware; 375 | D3DCOLORMODEL dcmColorModel; 376 | GUID guid; 377 | DWORD dwCaps; 378 | D3DPRIMCAPS dpcPrimCaps; 379 | } D3DFINDDEVICESEARCH,*LPD3DFINDDEVICESEARCH; 380 | 381 | typedef struct _D3DFINDDEVICERESULT { 382 | DWORD dwSize; 383 | GUID guid; 384 | D3DDEVICEDESC ddHwDesc; 385 | D3DDEVICEDESC ddSwDesc; 386 | } D3DFINDDEVICERESULT,*LPD3DFINDDEVICERESULT; 387 | 388 | typedef struct _D3DExecuteBufferDesc { 389 | DWORD dwSize; 390 | DWORD dwFlags; 391 | DWORD dwCaps; 392 | DWORD dwBufferSize; 393 | void *lpData; 394 | } D3DEXECUTEBUFFERDESC, *LPD3DEXECUTEBUFFERDESC; 395 | 396 | #define D3DDEB_BUFSIZE 0x00000001 397 | #define D3DDEB_CAPS 0x00000002 398 | #define D3DDEB_LPDATA 0x00000004 399 | 400 | #define D3DDEBCAPS_SYSTEMMEMORY 0x00000001 401 | #define D3DDEBCAPS_VIDEOMEMORY 0x00000002 402 | #define D3DDEBCAPS_MEM (D3DDEBCAPS_SYSTEMMEMORY|D3DDEBCAPS_VIDEOMEMORY) /* = 0x3 */ 403 | 404 | typedef struct _D3DDEVINFO_TEXTUREMANAGER { 405 | WINBOOL bThrashing; 406 | DWORD dwApproxBytesDownloaded; 407 | DWORD dwNumEvicts; 408 | DWORD dwNumVidCreates; 409 | DWORD dwNumTexturesUsed; 410 | DWORD dwNumUsedTexInVid; 411 | DWORD dwWorkingSet; 412 | DWORD dwWorkingSetBytes; 413 | DWORD dwTotalManaged; 414 | DWORD dwTotalBytes; 415 | DWORD dwLastPri; 416 | } D3DDEVINFO_TEXTUREMANAGER, *LPD3DDEVINFO_TEXTUREMANAGER; 417 | 418 | typedef struct _D3DDEVINFO_TEXTURING { 419 | DWORD dwNumLoads; 420 | DWORD dwApproxBytesLoaded; 421 | DWORD dwNumPreLoads; 422 | DWORD dwNumSet; 423 | DWORD dwNumCreates; 424 | DWORD dwNumDestroys; 425 | DWORD dwNumSetPriorities; 426 | DWORD dwNumSetLODs; 427 | DWORD dwNumLocks; 428 | DWORD dwNumGetDCs; 429 | } D3DDEVINFO_TEXTURING, *LPD3DDEVINFO_TEXTURING; 430 | 431 | 432 | 433 | #endif 434 | -------------------------------------------------------------------------------- /directx_api/d3dtypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2000 Peter Hunnisett 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 | */ 18 | 19 | /* FIXME: Need to add C++ code for certain structs for headers - this is going to be a problem 20 | if WINE continues to only use C code - I suppose that we could always inline in 21 | the header file to get around that little problem... */ 22 | /* FIXME: We need to implement versioning on everything directx 5 and up if these headers 23 | are going to be generically useful for directx stuff */ 24 | 25 | #ifndef __WINE_D3DTYPES_H 26 | #define __WINE_D3DTYPES_H 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #define D3DVALP(val, prec) ((float)(val)) 33 | #define D3DVAL(val) ((float)(val)) 34 | #define D3DDivide(a, b) (float)((double) (a) / (double) (b)) 35 | #define D3DMultiply(a, b) ((a) * (b)) 36 | 37 | typedef LONG D3DFIXED; 38 | 39 | 40 | #ifndef RGB_MAKE 41 | #define CI_GETALPHA(ci) ((ci) >> 24) 42 | #define CI_GETINDEX(ci) (((ci) >> 8) & 0xffff) 43 | #define CI_GETFRACTION(ci) ((ci) & 0xff) 44 | #define CI_ROUNDINDEX(ci) CI_GETINDEX((ci) + 0x80) 45 | #define CI_MASKALPHA(ci) ((ci) & 0xffffff) 46 | #define CI_MAKE(a, i, f) (((a) << 24) | ((i) << 8) | (f)) 47 | 48 | #define RGBA_GETALPHA(rgb) ((rgb) >> 24) 49 | #define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff) 50 | #define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff) 51 | #define RGBA_GETBLUE(rgb) ((rgb) & 0xff) 52 | #define RGBA_MAKE(r, g, b, a) ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))) 53 | 54 | #define D3DRGB(r, g, b) \ 55 | (0xff000000 | ( ((LONG)((r) * 255)) << 16) | (((LONG)((g) * 255)) << 8) | (LONG)((b) * 255)) 56 | #define D3DRGBA(r, g, b, a) \ 57 | ( (((LONG)((a) * 255)) << 24) | (((LONG)((r) * 255)) << 16) \ 58 | | (((LONG)((g) * 255)) << 8) | (LONG)((b) * 255) \ 59 | ) 60 | 61 | #define RGB_GETRED(rgb) (((rgb) >> 16) & 0xff) 62 | #define RGB_GETGREEN(rgb) (((rgb) >> 8) & 0xff) 63 | #define RGB_GETBLUE(rgb) ((rgb) & 0xff) 64 | #define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff)) 65 | #define RGB_MAKE(r, g, b) ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b))) 66 | #define RGBA_TORGB(rgba) ((D3DCOLOR) ((rgba) & 0xffffff)) 67 | #define RGB_TORGBA(rgb) ((D3DCOLOR) ((rgb) | 0xff000000)) 68 | 69 | #endif 70 | 71 | #define D3DENUMRET_CANCEL DDENUMRET_CANCEL 72 | #define D3DENUMRET_OK DDENUMRET_OK 73 | 74 | typedef HRESULT (CALLBACK *LPD3DVALIDATECALLBACK)(void *ctx, DWORD offset); 75 | typedef HRESULT (CALLBACK *LPD3DENUMTEXTUREFORMATSCALLBACK)(DDSURFACEDESC *surface_desc, void *ctx); 76 | typedef HRESULT (CALLBACK *LPD3DENUMPIXELFORMATSCALLBACK)(DDPIXELFORMAT *format, void *ctx); 77 | 78 | #ifndef DX_SHARED_DEFINES 79 | 80 | typedef float D3DVALUE,*LPD3DVALUE; 81 | 82 | #ifndef D3DCOLOR_DEFINED 83 | typedef DWORD D3DCOLOR, *LPD3DCOLOR; 84 | #define D3DCOLOR_DEFINED 85 | #endif 86 | 87 | #ifndef D3DVECTOR_DEFINED 88 | typedef struct _D3DVECTOR { 89 | union { 90 | D3DVALUE x; 91 | D3DVALUE dvX; 92 | } DUMMYUNIONNAME1; 93 | union { 94 | D3DVALUE y; 95 | D3DVALUE dvY; 96 | } DUMMYUNIONNAME2; 97 | union { 98 | D3DVALUE z; 99 | D3DVALUE dvZ; 100 | } DUMMYUNIONNAME3; 101 | #if defined(__cplusplus) && defined(D3D_OVERLOADS) 102 | /* the definitions for these methods are in d3dvec.inl */ 103 | public: 104 | /*** constructors ***/ 105 | _D3DVECTOR() {} 106 | _D3DVECTOR(D3DVALUE f); 107 | _D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z); 108 | _D3DVECTOR(const D3DVALUE f[3]); 109 | 110 | /*** assignment operators ***/ 111 | _D3DVECTOR& operator += (const _D3DVECTOR& v); 112 | _D3DVECTOR& operator -= (const _D3DVECTOR& v); 113 | _D3DVECTOR& operator *= (const _D3DVECTOR& v); 114 | _D3DVECTOR& operator /= (const _D3DVECTOR& v); 115 | _D3DVECTOR& operator *= (D3DVALUE s); 116 | _D3DVECTOR& operator /= (D3DVALUE s); 117 | 118 | /*** unary operators ***/ 119 | friend _D3DVECTOR operator + (const _D3DVECTOR& v); 120 | friend _D3DVECTOR operator - (const _D3DVECTOR& v); 121 | 122 | /*** binary operators ***/ 123 | friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2); 124 | friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2); 125 | 126 | friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s); 127 | friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v); 128 | friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s); 129 | 130 | friend D3DVALUE SquareMagnitude(const _D3DVECTOR& v); 131 | friend D3DVALUE Magnitude(const _D3DVECTOR& v); 132 | 133 | friend _D3DVECTOR Normalize(const _D3DVECTOR& v); 134 | 135 | friend D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2); 136 | friend _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2); 137 | #endif 138 | } D3DVECTOR,*LPD3DVECTOR; 139 | #define D3DVECTOR_DEFINED 140 | #endif 141 | 142 | #define DX_SHARED_DEFINES 143 | #endif /* DX_SHARED_DEFINES */ 144 | 145 | typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE; 146 | typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE; 147 | typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE; 148 | 149 | typedef struct _D3DCOLORVALUE { 150 | union { 151 | D3DVALUE r; 152 | D3DVALUE dvR; 153 | } DUMMYUNIONNAME1; 154 | union { 155 | D3DVALUE g; 156 | D3DVALUE dvG; 157 | } DUMMYUNIONNAME2; 158 | union { 159 | D3DVALUE b; 160 | D3DVALUE dvB; 161 | } DUMMYUNIONNAME3; 162 | union { 163 | D3DVALUE a; 164 | D3DVALUE dvA; 165 | } DUMMYUNIONNAME4; 166 | } D3DCOLORVALUE,*LPD3DCOLORVALUE; 167 | 168 | typedef struct _D3DRECT { 169 | union { 170 | LONG x1; 171 | LONG lX1; 172 | } DUMMYUNIONNAME1; 173 | union { 174 | LONG y1; 175 | LONG lY1; 176 | } DUMMYUNIONNAME2; 177 | union { 178 | LONG x2; 179 | LONG lX2; 180 | } DUMMYUNIONNAME3; 181 | union { 182 | LONG y2; 183 | LONG lY2; 184 | } DUMMYUNIONNAME4; 185 | } D3DRECT, *LPD3DRECT; 186 | 187 | typedef struct _D3DHVERTEX { 188 | DWORD dwFlags; 189 | union { 190 | D3DVALUE hx; 191 | D3DVALUE dvHX; 192 | } DUMMYUNIONNAME1; 193 | union { 194 | D3DVALUE hy; 195 | D3DVALUE dvHY; 196 | } DUMMYUNIONNAME2; 197 | union { 198 | D3DVALUE hz; 199 | D3DVALUE dvHZ; 200 | } DUMMYUNIONNAME3; 201 | } D3DHVERTEX, *LPD3DHVERTEX; 202 | 203 | /* 204 | * Transformed/lit vertices 205 | */ 206 | typedef struct _D3DTLVERTEX { 207 | union { 208 | D3DVALUE sx; 209 | D3DVALUE dvSX; 210 | } DUMMYUNIONNAME1; 211 | union { 212 | D3DVALUE sy; 213 | D3DVALUE dvSY; 214 | } DUMMYUNIONNAME2; 215 | union { 216 | D3DVALUE sz; 217 | D3DVALUE dvSZ; 218 | } DUMMYUNIONNAME3; 219 | union { 220 | D3DVALUE rhw; 221 | D3DVALUE dvRHW; 222 | } DUMMYUNIONNAME4; 223 | union { 224 | D3DCOLOR color; 225 | D3DCOLOR dcColor; 226 | } DUMMYUNIONNAME5; 227 | union { 228 | D3DCOLOR specular; 229 | D3DCOLOR dcSpecular; 230 | } DUMMYUNIONNAME6; 231 | union { 232 | D3DVALUE tu; 233 | D3DVALUE dvTU; 234 | } DUMMYUNIONNAME7; 235 | union { 236 | D3DVALUE tv; 237 | D3DVALUE dvTV; 238 | } DUMMYUNIONNAME8; 239 | #if defined(__cplusplus) && defined(D3D_OVERLOADS) 240 | public: 241 | _D3DTLVERTEX() {} 242 | _D3DTLVERTEX(const D3DVECTOR& v, float _rhw, D3DCOLOR _color, D3DCOLOR _specular, float _tu, float _tv) { 243 | sx = v.x; sy = v.y; sz = v.z; rhw = _rhw; 244 | color = _color; specular = _specular; 245 | tu = _tu; tv = _tv; 246 | } 247 | #endif 248 | } D3DTLVERTEX, *LPD3DTLVERTEX; 249 | 250 | typedef struct _D3DLVERTEX { 251 | union { 252 | D3DVALUE x; 253 | D3DVALUE dvX; 254 | } DUMMYUNIONNAME1; 255 | union { 256 | D3DVALUE y; 257 | D3DVALUE dvY; 258 | } DUMMYUNIONNAME2; 259 | union { 260 | D3DVALUE z; 261 | D3DVALUE dvZ; 262 | } DUMMYUNIONNAME3; 263 | DWORD dwReserved; 264 | union { 265 | D3DCOLOR color; 266 | D3DCOLOR dcColor; 267 | } DUMMYUNIONNAME4; 268 | union { 269 | D3DCOLOR specular; 270 | D3DCOLOR dcSpecular; 271 | } DUMMYUNIONNAME5; 272 | union { 273 | D3DVALUE tu; 274 | D3DVALUE dvTU; 275 | } DUMMYUNIONNAME6; 276 | union { 277 | D3DVALUE tv; 278 | D3DVALUE dvTV; 279 | } DUMMYUNIONNAME7; 280 | } D3DLVERTEX, *LPD3DLVERTEX; 281 | 282 | typedef struct _D3DVERTEX { 283 | union { 284 | D3DVALUE x; 285 | D3DVALUE dvX; 286 | } DUMMYUNIONNAME1; 287 | union { 288 | D3DVALUE y; 289 | D3DVALUE dvY; 290 | } DUMMYUNIONNAME2; 291 | union { 292 | D3DVALUE z; 293 | D3DVALUE dvZ; 294 | } DUMMYUNIONNAME3; 295 | union { 296 | D3DVALUE nx; 297 | D3DVALUE dvNX; 298 | } DUMMYUNIONNAME4; 299 | union { 300 | D3DVALUE ny; 301 | D3DVALUE dvNY; 302 | } DUMMYUNIONNAME5; 303 | union { 304 | D3DVALUE nz; 305 | D3DVALUE dvNZ; 306 | } DUMMYUNIONNAME6; 307 | union { 308 | D3DVALUE tu; 309 | D3DVALUE dvTU; 310 | } DUMMYUNIONNAME7; 311 | union { 312 | D3DVALUE tv; 313 | D3DVALUE dvTV; 314 | } DUMMYUNIONNAME8; 315 | #if defined(__cplusplus) && defined(D3D_OVERLOADS) 316 | public: 317 | _D3DVERTEX() {} 318 | _D3DVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, float _tu, float _tv) { 319 | x = v.x; y = v.y; z = v.z; 320 | nx = n.x; ny = n.y; nz = n.z; 321 | tu = _tu; tv = _tv; 322 | } 323 | #endif 324 | } D3DVERTEX, *LPD3DVERTEX; 325 | 326 | typedef struct _D3DMATRIX { 327 | D3DVALUE _11, _12, _13, _14; 328 | D3DVALUE _21, _22, _23, _24; 329 | D3DVALUE _31, _32, _33, _34; 330 | D3DVALUE _41, _42, _43, _44; 331 | #if defined(__cplusplus) && defined(D3D_OVERLOADS) 332 | _D3DMATRIX() { } 333 | 334 | /* This is different from MS, but avoids anonymous structs. */ 335 | D3DVALUE &operator () (int r, int c) 336 | { return (&_11)[r*4 + c]; } 337 | const D3DVALUE &operator() (int r, int c) const 338 | { return (&_11)[r*4 + c]; } 339 | #endif 340 | } D3DMATRIX, *LPD3DMATRIX; 341 | 342 | #if defined(__cplusplus) && defined(D3D_OVERLOADS) 343 | #include 344 | #endif 345 | 346 | typedef struct _D3DVIEWPORT { 347 | DWORD dwSize; 348 | DWORD dwX; 349 | DWORD dwY; 350 | DWORD dwWidth; 351 | DWORD dwHeight; 352 | D3DVALUE dvScaleX; 353 | D3DVALUE dvScaleY; 354 | D3DVALUE dvMaxX; 355 | D3DVALUE dvMaxY; 356 | D3DVALUE dvMinZ; 357 | D3DVALUE dvMaxZ; 358 | } D3DVIEWPORT, *LPD3DVIEWPORT; 359 | 360 | typedef struct _D3DVIEWPORT2 { 361 | DWORD dwSize; 362 | DWORD dwX; 363 | DWORD dwY; 364 | DWORD dwWidth; 365 | DWORD dwHeight; 366 | D3DVALUE dvClipX; 367 | D3DVALUE dvClipY; 368 | D3DVALUE dvClipWidth; 369 | D3DVALUE dvClipHeight; 370 | D3DVALUE dvMinZ; 371 | D3DVALUE dvMaxZ; 372 | } D3DVIEWPORT2, *LPD3DVIEWPORT2; 373 | 374 | typedef struct _D3DVIEWPORT7 { 375 | DWORD dwX; 376 | DWORD dwY; 377 | DWORD dwWidth; 378 | DWORD dwHeight; 379 | D3DVALUE dvMinZ; 380 | D3DVALUE dvMaxZ; 381 | } D3DVIEWPORT7, *LPD3DVIEWPORT7; 382 | 383 | #define D3DMAXUSERCLIPPLANES 32 384 | 385 | #define D3DCLIPPLANE0 (1 << 0) 386 | #define D3DCLIPPLANE1 (1 << 1) 387 | #define D3DCLIPPLANE2 (1 << 2) 388 | #define D3DCLIPPLANE3 (1 << 3) 389 | #define D3DCLIPPLANE4 (1 << 4) 390 | #define D3DCLIPPLANE5 (1 << 5) 391 | 392 | #define D3DCLIP_LEFT 0x00000001 393 | #define D3DCLIP_RIGHT 0x00000002 394 | #define D3DCLIP_TOP 0x00000004 395 | #define D3DCLIP_BOTTOM 0x00000008 396 | #define D3DCLIP_FRONT 0x00000010 397 | #define D3DCLIP_BACK 0x00000020 398 | #define D3DCLIP_GEN0 0x00000040 399 | #define D3DCLIP_GEN1 0x00000080 400 | #define D3DCLIP_GEN2 0x00000100 401 | #define D3DCLIP_GEN3 0x00000200 402 | #define D3DCLIP_GEN4 0x00000400 403 | #define D3DCLIP_GEN5 0x00000800 404 | 405 | #define D3DSTATUS_CLIPUNIONLEFT D3DCLIP_LEFT 406 | #define D3DSTATUS_CLIPUNIONRIGHT D3DCLIP_RIGHT 407 | #define D3DSTATUS_CLIPUNIONTOP D3DCLIP_TOP 408 | #define D3DSTATUS_CLIPUNIONBOTTOM D3DCLIP_BOTTOM 409 | #define D3DSTATUS_CLIPUNIONFRONT D3DCLIP_FRONT 410 | #define D3DSTATUS_CLIPUNIONBACK D3DCLIP_BACK 411 | #define D3DSTATUS_CLIPUNIONGEN0 D3DCLIP_GEN0 412 | #define D3DSTATUS_CLIPUNIONGEN1 D3DCLIP_GEN1 413 | #define D3DSTATUS_CLIPUNIONGEN2 D3DCLIP_GEN2 414 | #define D3DSTATUS_CLIPUNIONGEN3 D3DCLIP_GEN3 415 | #define D3DSTATUS_CLIPUNIONGEN4 D3DCLIP_GEN4 416 | #define D3DSTATUS_CLIPUNIONGEN5 D3DCLIP_GEN5 417 | 418 | #define D3DSTATUS_CLIPINTERSECTIONLEFT 0x00001000 419 | #define D3DSTATUS_CLIPINTERSECTIONRIGHT 0x00002000 420 | #define D3DSTATUS_CLIPINTERSECTIONTOP 0x00004000 421 | #define D3DSTATUS_CLIPINTERSECTIONBOTTOM 0x00008000 422 | #define D3DSTATUS_CLIPINTERSECTIONFRONT 0x00010000 423 | #define D3DSTATUS_CLIPINTERSECTIONBACK 0x00020000 424 | #define D3DSTATUS_CLIPINTERSECTIONGEN0 0x00040000 425 | #define D3DSTATUS_CLIPINTERSECTIONGEN1 0x00080000 426 | #define D3DSTATUS_CLIPINTERSECTIONGEN2 0x00100000 427 | #define D3DSTATUS_CLIPINTERSECTIONGEN3 0x00200000 428 | #define D3DSTATUS_CLIPINTERSECTIONGEN4 0x00400000 429 | #define D3DSTATUS_CLIPINTERSECTIONGEN5 0x00800000 430 | #define D3DSTATUS_ZNOTVISIBLE 0x01000000 431 | 432 | #define D3DSTATUS_CLIPUNIONALL ( \ 433 | D3DSTATUS_CLIPUNIONLEFT | \ 434 | D3DSTATUS_CLIPUNIONRIGHT | \ 435 | D3DSTATUS_CLIPUNIONTOP | \ 436 | D3DSTATUS_CLIPUNIONBOTTOM | \ 437 | D3DSTATUS_CLIPUNIONFRONT | \ 438 | D3DSTATUS_CLIPUNIONBACK | \ 439 | D3DSTATUS_CLIPUNIONGEN0 | \ 440 | D3DSTATUS_CLIPUNIONGEN1 | \ 441 | D3DSTATUS_CLIPUNIONGEN2 | \ 442 | D3DSTATUS_CLIPUNIONGEN3 | \ 443 | D3DSTATUS_CLIPUNIONGEN4 | \ 444 | D3DSTATUS_CLIPUNIONGEN5 \ 445 | ) 446 | 447 | #define D3DSTATUS_CLIPINTERSECTIONALL ( \ 448 | D3DSTATUS_CLIPINTERSECTIONLEFT | \ 449 | D3DSTATUS_CLIPINTERSECTIONRIGHT | \ 450 | D3DSTATUS_CLIPINTERSECTIONTOP | \ 451 | D3DSTATUS_CLIPINTERSECTIONBOTTOM | \ 452 | D3DSTATUS_CLIPINTERSECTIONFRONT | \ 453 | D3DSTATUS_CLIPINTERSECTIONBACK | \ 454 | D3DSTATUS_CLIPINTERSECTIONGEN0 | \ 455 | D3DSTATUS_CLIPINTERSECTIONGEN1 | \ 456 | D3DSTATUS_CLIPINTERSECTIONGEN2 | \ 457 | D3DSTATUS_CLIPINTERSECTIONGEN3 | \ 458 | D3DSTATUS_CLIPINTERSECTIONGEN4 | \ 459 | D3DSTATUS_CLIPINTERSECTIONGEN5 \ 460 | ) 461 | 462 | #define D3DSTATUS_DEFAULT ( \ 463 | D3DSTATUS_CLIPINTERSECTIONALL | \ 464 | D3DSTATUS_ZNOTVISIBLE) 465 | 466 | #define D3DTRANSFORM_CLIPPED 0x00000001 467 | #define D3DTRANSFORM_UNCLIPPED 0x00000002 468 | 469 | typedef struct _D3DTRANSFORMDATA { 470 | DWORD dwSize; 471 | void *lpIn; 472 | DWORD dwInSize; 473 | void *lpOut; 474 | DWORD dwOutSize; 475 | D3DHVERTEX *lpHOut; 476 | DWORD dwClip; 477 | DWORD dwClipIntersection; 478 | DWORD dwClipUnion; 479 | D3DRECT drExtent; 480 | } D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA; 481 | 482 | typedef struct _D3DLIGHTINGELEMENT { 483 | D3DVECTOR dvPosition; 484 | D3DVECTOR dvNormal; 485 | } D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT; 486 | 487 | typedef struct _D3DMATERIAL { 488 | DWORD dwSize; 489 | union { 490 | D3DCOLORVALUE diffuse; 491 | D3DCOLORVALUE dcvDiffuse; 492 | } DUMMYUNIONNAME; 493 | union { 494 | D3DCOLORVALUE ambient; 495 | D3DCOLORVALUE dcvAmbient; 496 | } DUMMYUNIONNAME1; 497 | union { 498 | D3DCOLORVALUE specular; 499 | D3DCOLORVALUE dcvSpecular; 500 | } DUMMYUNIONNAME2; 501 | union { 502 | D3DCOLORVALUE emissive; 503 | D3DCOLORVALUE dcvEmissive; 504 | } DUMMYUNIONNAME3; 505 | union { 506 | D3DVALUE power; 507 | D3DVALUE dvPower; 508 | } DUMMYUNIONNAME4; 509 | D3DTEXTUREHANDLE hTexture; 510 | DWORD dwRampSize; 511 | } D3DMATERIAL, *LPD3DMATERIAL; 512 | 513 | typedef struct _D3DMATERIAL7 { 514 | union { 515 | D3DCOLORVALUE diffuse; 516 | D3DCOLORVALUE dcvDiffuse; 517 | } DUMMYUNIONNAME; 518 | union { 519 | D3DCOLORVALUE ambient; 520 | D3DCOLORVALUE dcvAmbient; 521 | } DUMMYUNIONNAME1; 522 | union { 523 | D3DCOLORVALUE specular; 524 | D3DCOLORVALUE dcvSpecular; 525 | } DUMMYUNIONNAME2; 526 | union { 527 | D3DCOLORVALUE emissive; 528 | D3DCOLORVALUE dcvEmissive; 529 | } DUMMYUNIONNAME3; 530 | union { 531 | D3DVALUE power; 532 | D3DVALUE dvPower; 533 | } DUMMYUNIONNAME4; 534 | } D3DMATERIAL7, *LPD3DMATERIAL7; 535 | 536 | typedef enum { 537 | D3DLIGHT_POINT = 1, 538 | D3DLIGHT_SPOT = 2, 539 | D3DLIGHT_DIRECTIONAL = 3, 540 | D3DLIGHT_PARALLELPOINT = 4, 541 | D3DLIGHT_GLSPOT = 5, 542 | D3DLIGHT_FORCE_DWORD = 0x7fffffff 543 | } D3DLIGHTTYPE; 544 | 545 | typedef struct _D3DLIGHT { 546 | DWORD dwSize; 547 | D3DLIGHTTYPE dltType; 548 | D3DCOLORVALUE dcvColor; 549 | D3DVECTOR dvPosition; 550 | D3DVECTOR dvDirection; 551 | D3DVALUE dvRange; 552 | D3DVALUE dvFalloff; 553 | D3DVALUE dvAttenuation0; 554 | D3DVALUE dvAttenuation1; 555 | D3DVALUE dvAttenuation2; 556 | D3DVALUE dvTheta; 557 | D3DVALUE dvPhi; 558 | } D3DLIGHT,*LPD3DLIGHT; 559 | 560 | typedef struct _D3DLIGHT7 { 561 | D3DLIGHTTYPE dltType; 562 | D3DCOLORVALUE dcvDiffuse; 563 | D3DCOLORVALUE dcvSpecular; 564 | D3DCOLORVALUE dcvAmbient; 565 | D3DVECTOR dvPosition; 566 | D3DVECTOR dvDirection; 567 | D3DVALUE dvRange; 568 | D3DVALUE dvFalloff; 569 | D3DVALUE dvAttenuation0; 570 | D3DVALUE dvAttenuation1; 571 | D3DVALUE dvAttenuation2; 572 | D3DVALUE dvTheta; 573 | D3DVALUE dvPhi; 574 | } D3DLIGHT7, *LPD3DLIGHT7; 575 | 576 | #define D3DLIGHT_ACTIVE 0x00000001 577 | #define D3DLIGHT_NO_SPECULAR 0x00000002 578 | #define D3DLIGHT_ALL (D3DLIGHT_ACTIVE | D3DLIGHT_NO_SPECULAR) /* 0x3 */ 579 | 580 | #define D3DLIGHT_RANGE_MAX ((float)sqrt(FLT_MAX)) 581 | 582 | typedef struct _D3DLIGHT2 { 583 | DWORD dwSize; 584 | D3DLIGHTTYPE dltType; 585 | D3DCOLORVALUE dcvColor; 586 | D3DVECTOR dvPosition; 587 | D3DVECTOR dvDirection; 588 | D3DVALUE dvRange; 589 | D3DVALUE dvFalloff; 590 | D3DVALUE dvAttenuation0; 591 | D3DVALUE dvAttenuation1; 592 | D3DVALUE dvAttenuation2; 593 | D3DVALUE dvTheta; 594 | D3DVALUE dvPhi; 595 | DWORD dwFlags; 596 | } D3DLIGHT2, *LPD3DLIGHT2; 597 | 598 | typedef struct _D3DLIGHTDATA { 599 | DWORD dwSize; 600 | D3DLIGHTINGELEMENT *lpIn; 601 | DWORD dwInSize; 602 | D3DTLVERTEX *lpOut; 603 | DWORD dwOutSize; 604 | } D3DLIGHTDATA, *LPD3DLIGHTDATA; 605 | 606 | #define D3DCOLOR_MONO 1 607 | #define D3DCOLOR_RGB 2 608 | 609 | typedef DWORD D3DCOLORMODEL; 610 | 611 | 612 | #define D3DCLEAR_TARGET 0x00000001 613 | #define D3DCLEAR_ZBUFFER 0x00000002 614 | #define D3DCLEAR_STENCIL 0x00000004 615 | 616 | typedef enum _D3DOPCODE { 617 | D3DOP_POINT = 1, 618 | D3DOP_LINE = 2, 619 | D3DOP_TRIANGLE = 3, 620 | D3DOP_MATRIXLOAD = 4, 621 | D3DOP_MATRIXMULTIPLY = 5, 622 | D3DOP_STATETRANSFORM = 6, 623 | D3DOP_STATELIGHT = 7, 624 | D3DOP_STATERENDER = 8, 625 | D3DOP_PROCESSVERTICES = 9, 626 | D3DOP_TEXTURELOAD = 10, 627 | D3DOP_EXIT = 11, 628 | D3DOP_BRANCHFORWARD = 12, 629 | D3DOP_SPAN = 13, 630 | D3DOP_SETSTATUS = 14, 631 | 632 | D3DOP_FORCE_DWORD = 0x7fffffff 633 | } D3DOPCODE; 634 | 635 | typedef struct _D3DINSTRUCTION { 636 | BYTE bOpcode; 637 | BYTE bSize; 638 | WORD wCount; 639 | } D3DINSTRUCTION, *LPD3DINSTRUCTION; 640 | 641 | typedef struct _D3DTEXTURELOAD { 642 | D3DTEXTUREHANDLE hDestTexture; 643 | D3DTEXTUREHANDLE hSrcTexture; 644 | } D3DTEXTURELOAD, *LPD3DTEXTURELOAD; 645 | 646 | typedef struct _D3DPICKRECORD { 647 | BYTE bOpcode; 648 | BYTE bPad; 649 | DWORD dwOffset; 650 | D3DVALUE dvZ; 651 | } D3DPICKRECORD, *LPD3DPICKRECORD; 652 | 653 | typedef enum { 654 | D3DSHADE_FLAT = 1, 655 | D3DSHADE_GOURAUD = 2, 656 | D3DSHADE_PHONG = 3, 657 | D3DSHADE_FORCE_DWORD = 0x7fffffff 658 | } D3DSHADEMODE; 659 | 660 | typedef enum { 661 | D3DFILL_POINT = 1, 662 | D3DFILL_WIREFRAME = 2, 663 | D3DFILL_SOLID = 3, 664 | D3DFILL_FORCE_DWORD = 0x7fffffff 665 | } D3DFILLMODE; 666 | 667 | typedef struct _D3DLINEPATTERN { 668 | WORD wRepeatFactor; 669 | WORD wLinePattern; 670 | } D3DLINEPATTERN; 671 | 672 | typedef enum { 673 | D3DFILTER_NEAREST = 1, 674 | D3DFILTER_LINEAR = 2, 675 | D3DFILTER_MIPNEAREST = 3, 676 | D3DFILTER_MIPLINEAR = 4, 677 | D3DFILTER_LINEARMIPNEAREST = 5, 678 | D3DFILTER_LINEARMIPLINEAR = 6, 679 | D3DFILTER_FORCE_DWORD = 0x7fffffff 680 | } D3DTEXTUREFILTER; 681 | 682 | typedef enum { 683 | D3DBLEND_ZERO = 1, 684 | D3DBLEND_ONE = 2, 685 | D3DBLEND_SRCCOLOR = 3, 686 | D3DBLEND_INVSRCCOLOR = 4, 687 | D3DBLEND_SRCALPHA = 5, 688 | D3DBLEND_INVSRCALPHA = 6, 689 | D3DBLEND_DESTALPHA = 7, 690 | D3DBLEND_INVDESTALPHA = 8, 691 | D3DBLEND_DESTCOLOR = 9, 692 | D3DBLEND_INVDESTCOLOR = 10, 693 | D3DBLEND_SRCALPHASAT = 11, 694 | D3DBLEND_BOTHSRCALPHA = 12, 695 | D3DBLEND_BOTHINVSRCALPHA = 13, 696 | D3DBLEND_FORCE_DWORD = 0x7fffffff 697 | } D3DBLEND; 698 | 699 | typedef enum { 700 | D3DTBLEND_DECAL = 1, 701 | D3DTBLEND_MODULATE = 2, 702 | D3DTBLEND_DECALALPHA = 3, 703 | D3DTBLEND_MODULATEALPHA = 4, 704 | D3DTBLEND_DECALMASK = 5, 705 | D3DTBLEND_MODULATEMASK = 6, 706 | D3DTBLEND_COPY = 7, 707 | D3DTBLEND_ADD = 8, 708 | D3DTBLEND_FORCE_DWORD = 0x7fffffff 709 | } D3DTEXTUREBLEND; 710 | 711 | typedef enum _D3DTEXTUREADDRESS { 712 | D3DTADDRESS_WRAP = 1, 713 | D3DTADDRESS_MIRROR = 2, 714 | D3DTADDRESS_CLAMP = 3, 715 | D3DTADDRESS_BORDER = 4, 716 | D3DTADDRESS_FORCE_DWORD = 0x7fffffff 717 | } D3DTEXTUREADDRESS; 718 | 719 | typedef enum { 720 | D3DCULL_NONE = 1, 721 | D3DCULL_CW = 2, 722 | D3DCULL_CCW = 3, 723 | D3DCULL_FORCE_DWORD = 0x7fffffff 724 | } D3DCULL; 725 | 726 | typedef enum { 727 | D3DCMP_NEVER = 1, 728 | D3DCMP_LESS = 2, 729 | D3DCMP_EQUAL = 3, 730 | D3DCMP_LESSEQUAL = 4, 731 | D3DCMP_GREATER = 5, 732 | D3DCMP_NOTEQUAL = 6, 733 | D3DCMP_GREATEREQUAL = 7, 734 | D3DCMP_ALWAYS = 8, 735 | D3DCMP_FORCE_DWORD = 0x7fffffff 736 | } D3DCMPFUNC; 737 | 738 | typedef enum _D3DSTENCILOP { 739 | D3DSTENCILOP_KEEP = 1, 740 | D3DSTENCILOP_ZERO = 2, 741 | D3DSTENCILOP_REPLACE = 3, 742 | D3DSTENCILOP_INCRSAT = 4, 743 | D3DSTENCILOP_DECRSAT = 5, 744 | D3DSTENCILOP_INVERT = 6, 745 | D3DSTENCILOP_INCR = 7, 746 | D3DSTENCILOP_DECR = 8, 747 | D3DSTENCILOP_FORCE_DWORD = 0x7fffffff 748 | } D3DSTENCILOP; 749 | 750 | typedef enum _D3DFOGMODE { 751 | D3DFOG_NONE = 0, 752 | D3DFOG_EXP = 1, 753 | D3DFOG_EXP2 = 2, 754 | D3DFOG_LINEAR = 3, 755 | D3DFOG_FORCE_DWORD = 0x7fffffff 756 | } D3DFOGMODE; 757 | 758 | typedef enum _D3DZBUFFERTYPE { 759 | D3DZB_FALSE = 0, 760 | D3DZB_TRUE = 1, 761 | D3DZB_USEW = 2, 762 | D3DZB_FORCE_DWORD = 0x7fffffff 763 | } D3DZBUFFERTYPE; 764 | 765 | typedef enum _D3DANTIALIASMODE { 766 | D3DANTIALIAS_NONE = 0, 767 | D3DANTIALIAS_SORTDEPENDENT = 1, 768 | D3DANTIALIAS_SORTINDEPENDENT = 2, 769 | D3DANTIALIAS_FORCE_DWORD = 0x7fffffff 770 | } D3DANTIALIASMODE; 771 | 772 | typedef enum { 773 | D3DVT_VERTEX = 1, 774 | D3DVT_LVERTEX = 2, 775 | D3DVT_TLVERTEX = 3, 776 | D3DVT_FORCE_DWORD = 0x7fffffff 777 | } D3DVERTEXTYPE; 778 | 779 | typedef enum { 780 | D3DPT_POINTLIST = 1, 781 | D3DPT_LINELIST = 2, 782 | D3DPT_LINESTRIP = 3, 783 | D3DPT_TRIANGLELIST = 4, 784 | D3DPT_TRIANGLESTRIP = 5, 785 | D3DPT_TRIANGLEFAN = 6, 786 | D3DPT_FORCE_DWORD = 0x7fffffff 787 | } D3DPRIMITIVETYPE; 788 | 789 | #define D3DSTATE_OVERRIDE_BIAS 256 790 | 791 | #define D3DSTATE_OVERRIDE(type) (D3DRENDERSTATETYPE)(((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS)) 792 | 793 | typedef enum _D3DTRANSFORMSTATETYPE { 794 | D3DTRANSFORMSTATE_WORLD = 1, 795 | D3DTRANSFORMSTATE_VIEW = 2, 796 | D3DTRANSFORMSTATE_PROJECTION = 3, 797 | D3DTRANSFORMSTATE_WORLD1 = 4, 798 | D3DTRANSFORMSTATE_WORLD2 = 5, 799 | D3DTRANSFORMSTATE_WORLD3 = 6, 800 | D3DTRANSFORMSTATE_TEXTURE0 = 16, 801 | D3DTRANSFORMSTATE_TEXTURE1 = 17, 802 | D3DTRANSFORMSTATE_TEXTURE2 = 18, 803 | D3DTRANSFORMSTATE_TEXTURE3 = 19, 804 | D3DTRANSFORMSTATE_TEXTURE4 = 20, 805 | D3DTRANSFORMSTATE_TEXTURE5 = 21, 806 | D3DTRANSFORMSTATE_TEXTURE6 = 22, 807 | D3DTRANSFORMSTATE_TEXTURE7 = 23, 808 | D3DTRANSFORMSTATE_FORCE_DWORD = 0x7fffffff 809 | } D3DTRANSFORMSTATETYPE; 810 | 811 | typedef enum { 812 | D3DLIGHTSTATE_MATERIAL = 1, 813 | D3DLIGHTSTATE_AMBIENT = 2, 814 | D3DLIGHTSTATE_COLORMODEL = 3, 815 | D3DLIGHTSTATE_FOGMODE = 4, 816 | D3DLIGHTSTATE_FOGSTART = 5, 817 | D3DLIGHTSTATE_FOGEND = 6, 818 | D3DLIGHTSTATE_FOGDENSITY = 7, 819 | D3DLIGHTSTATE_COLORVERTEX = 8, 820 | D3DLIGHTSTATE_FORCE_DWORD = 0x7fffffff 821 | } D3DLIGHTSTATETYPE; 822 | 823 | typedef enum { 824 | D3DRENDERSTATE_TEXTUREHANDLE = 1, 825 | D3DRENDERSTATE_ANTIALIAS = 2, 826 | D3DRENDERSTATE_TEXTUREADDRESS = 3, 827 | D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4, 828 | D3DRENDERSTATE_WRAPU = 5, 829 | D3DRENDERSTATE_WRAPV = 6, 830 | D3DRENDERSTATE_ZENABLE = 7, 831 | D3DRENDERSTATE_FILLMODE = 8, 832 | D3DRENDERSTATE_SHADEMODE = 9, 833 | D3DRENDERSTATE_LINEPATTERN = 10, 834 | D3DRENDERSTATE_MONOENABLE = 11, 835 | D3DRENDERSTATE_ROP2 = 12, 836 | D3DRENDERSTATE_PLANEMASK = 13, 837 | D3DRENDERSTATE_ZWRITEENABLE = 14, 838 | D3DRENDERSTATE_ALPHATESTENABLE = 15, 839 | D3DRENDERSTATE_LASTPIXEL = 16, 840 | D3DRENDERSTATE_TEXTUREMAG = 17, 841 | D3DRENDERSTATE_TEXTUREMIN = 18, 842 | D3DRENDERSTATE_SRCBLEND = 19, 843 | D3DRENDERSTATE_DESTBLEND = 20, 844 | D3DRENDERSTATE_TEXTUREMAPBLEND = 21, 845 | D3DRENDERSTATE_CULLMODE = 22, 846 | D3DRENDERSTATE_ZFUNC = 23, 847 | D3DRENDERSTATE_ALPHAREF = 24, 848 | D3DRENDERSTATE_ALPHAFUNC = 25, 849 | D3DRENDERSTATE_DITHERENABLE = 26, 850 | D3DRENDERSTATE_ALPHABLENDENABLE = 27, 851 | D3DRENDERSTATE_FOGENABLE = 28, 852 | D3DRENDERSTATE_SPECULARENABLE = 29, 853 | D3DRENDERSTATE_ZVISIBLE = 30, 854 | D3DRENDERSTATE_SUBPIXEL = 31, 855 | D3DRENDERSTATE_SUBPIXELX = 32, 856 | D3DRENDERSTATE_STIPPLEDALPHA = 33, 857 | D3DRENDERSTATE_FOGCOLOR = 34, 858 | D3DRENDERSTATE_FOGTABLEMODE = 35, 859 | D3DRENDERSTATE_FOGTABLESTART = 36, 860 | D3DRENDERSTATE_FOGTABLEEND = 37, 861 | D3DRENDERSTATE_FOGTABLEDENSITY = 38, 862 | D3DRENDERSTATE_FOGSTART = 36, 863 | D3DRENDERSTATE_FOGEND = 37, 864 | D3DRENDERSTATE_FOGDENSITY = 38, 865 | D3DRENDERSTATE_STIPPLEENABLE = 39, 866 | D3DRENDERSTATE_EDGEANTIALIAS = 40, 867 | D3DRENDERSTATE_COLORKEYENABLE = 41, 868 | D3DRENDERSTATE_BORDERCOLOR = 43, 869 | D3DRENDERSTATE_TEXTUREADDRESSU = 44, 870 | D3DRENDERSTATE_TEXTUREADDRESSV = 45, 871 | D3DRENDERSTATE_MIPMAPLODBIAS = 46, 872 | D3DRENDERSTATE_ZBIAS = 47, 873 | D3DRENDERSTATE_RANGEFOGENABLE = 48, 874 | D3DRENDERSTATE_ANISOTROPY = 49, 875 | D3DRENDERSTATE_FLUSHBATCH = 50, 876 | D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT = 51, 877 | 878 | D3DRENDERSTATE_STENCILENABLE = 52, 879 | D3DRENDERSTATE_STENCILFAIL = 53, 880 | D3DRENDERSTATE_STENCILZFAIL = 54, 881 | D3DRENDERSTATE_STENCILPASS = 55, 882 | D3DRENDERSTATE_STENCILFUNC = 56, 883 | D3DRENDERSTATE_STENCILREF = 57, 884 | D3DRENDERSTATE_STENCILMASK = 58, 885 | D3DRENDERSTATE_STENCILWRITEMASK = 59, 886 | D3DRENDERSTATE_TEXTUREFACTOR = 60, 887 | 888 | D3DRENDERSTATE_STIPPLEPATTERN00 = 64, 889 | D3DRENDERSTATE_STIPPLEPATTERN01 = 65, 890 | D3DRENDERSTATE_STIPPLEPATTERN02 = 66, 891 | D3DRENDERSTATE_STIPPLEPATTERN03 = 67, 892 | D3DRENDERSTATE_STIPPLEPATTERN04 = 68, 893 | D3DRENDERSTATE_STIPPLEPATTERN05 = 69, 894 | D3DRENDERSTATE_STIPPLEPATTERN06 = 70, 895 | D3DRENDERSTATE_STIPPLEPATTERN07 = 71, 896 | D3DRENDERSTATE_STIPPLEPATTERN08 = 72, 897 | D3DRENDERSTATE_STIPPLEPATTERN09 = 73, 898 | D3DRENDERSTATE_STIPPLEPATTERN10 = 74, 899 | D3DRENDERSTATE_STIPPLEPATTERN11 = 75, 900 | D3DRENDERSTATE_STIPPLEPATTERN12 = 76, 901 | D3DRENDERSTATE_STIPPLEPATTERN13 = 77, 902 | D3DRENDERSTATE_STIPPLEPATTERN14 = 78, 903 | D3DRENDERSTATE_STIPPLEPATTERN15 = 79, 904 | D3DRENDERSTATE_STIPPLEPATTERN16 = 80, 905 | D3DRENDERSTATE_STIPPLEPATTERN17 = 81, 906 | D3DRENDERSTATE_STIPPLEPATTERN18 = 82, 907 | D3DRENDERSTATE_STIPPLEPATTERN19 = 83, 908 | D3DRENDERSTATE_STIPPLEPATTERN20 = 84, 909 | D3DRENDERSTATE_STIPPLEPATTERN21 = 85, 910 | D3DRENDERSTATE_STIPPLEPATTERN22 = 86, 911 | D3DRENDERSTATE_STIPPLEPATTERN23 = 87, 912 | D3DRENDERSTATE_STIPPLEPATTERN24 = 88, 913 | D3DRENDERSTATE_STIPPLEPATTERN25 = 89, 914 | D3DRENDERSTATE_STIPPLEPATTERN26 = 90, 915 | D3DRENDERSTATE_STIPPLEPATTERN27 = 91, 916 | D3DRENDERSTATE_STIPPLEPATTERN28 = 92, 917 | D3DRENDERSTATE_STIPPLEPATTERN29 = 93, 918 | D3DRENDERSTATE_STIPPLEPATTERN30 = 94, 919 | D3DRENDERSTATE_STIPPLEPATTERN31 = 95, 920 | 921 | D3DRENDERSTATE_WRAP0 = 128, 922 | D3DRENDERSTATE_WRAP1 = 129, 923 | D3DRENDERSTATE_WRAP2 = 130, 924 | D3DRENDERSTATE_WRAP3 = 131, 925 | D3DRENDERSTATE_WRAP4 = 132, 926 | D3DRENDERSTATE_WRAP5 = 133, 927 | D3DRENDERSTATE_WRAP6 = 134, 928 | D3DRENDERSTATE_WRAP7 = 135, 929 | D3DRENDERSTATE_CLIPPING = 136, 930 | D3DRENDERSTATE_LIGHTING = 137, 931 | D3DRENDERSTATE_EXTENTS = 138, 932 | D3DRENDERSTATE_AMBIENT = 139, 933 | D3DRENDERSTATE_FOGVERTEXMODE = 140, 934 | D3DRENDERSTATE_COLORVERTEX = 141, 935 | D3DRENDERSTATE_LOCALVIEWER = 142, 936 | D3DRENDERSTATE_NORMALIZENORMALS = 143, 937 | D3DRENDERSTATE_COLORKEYBLENDENABLE = 144, 938 | D3DRENDERSTATE_DIFFUSEMATERIALSOURCE = 145, 939 | D3DRENDERSTATE_SPECULARMATERIALSOURCE = 146, 940 | D3DRENDERSTATE_AMBIENTMATERIALSOURCE = 147, 941 | D3DRENDERSTATE_EMISSIVEMATERIALSOURCE = 148, 942 | D3DRENDERSTATE_VERTEXBLEND = 151, 943 | D3DRENDERSTATE_CLIPPLANEENABLE = 152, 944 | 945 | D3DRENDERSTATE_FORCE_DWORD = 0x7fffffff 946 | 947 | /* FIXME: We have some retired values that are being reused for DirectX 7 */ 948 | } D3DRENDERSTATETYPE; 949 | 950 | typedef enum _D3DMATERIALCOLORSOURCE 951 | { 952 | D3DMCS_MATERIAL = 0, 953 | D3DMCS_COLOR1 = 1, 954 | D3DMCS_COLOR2 = 2, 955 | D3DMCS_FORCE_DWORD = 0x7fffffff 956 | } D3DMATERIALCOLORSOURCE; 957 | 958 | #define D3DRENDERSTATE_BLENDENABLE D3DRENDERSTATE_ALPHABLENDENABLE 959 | #define D3DRENDERSTATE_WRAPBIAS __MSABI_LONG(128U) 960 | #define D3DWRAP_U __MSABI_LONG(0x00000001) 961 | #define D3DWRAP_V __MSABI_LONG(0x00000002) 962 | 963 | #define D3DWRAPCOORD_0 __MSABI_LONG(0x00000001) 964 | #define D3DWRAPCOORD_1 __MSABI_LONG(0x00000002) 965 | #define D3DWRAPCOORD_2 __MSABI_LONG(0x00000004) 966 | #define D3DWRAPCOORD_3 __MSABI_LONG(0x00000008) 967 | 968 | #define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y)) 969 | 970 | typedef struct _D3DSTATE { 971 | union { 972 | D3DTRANSFORMSTATETYPE dtstTransformStateType; 973 | D3DLIGHTSTATETYPE dlstLightStateType; 974 | D3DRENDERSTATETYPE drstRenderStateType; 975 | } DUMMYUNIONNAME1; 976 | union { 977 | DWORD dwArg[1]; 978 | D3DVALUE dvArg[1]; 979 | } DUMMYUNIONNAME2; 980 | } D3DSTATE, *LPD3DSTATE; 981 | 982 | typedef struct _D3DMATRIXLOAD { 983 | D3DMATRIXHANDLE hDestMatrix; 984 | D3DMATRIXHANDLE hSrcMatrix; 985 | } D3DMATRIXLOAD, *LPD3DMATRIXLOAD; 986 | 987 | typedef struct _D3DMATRIXMULTIPLY { 988 | D3DMATRIXHANDLE hDestMatrix; 989 | D3DMATRIXHANDLE hSrcMatrix1; 990 | D3DMATRIXHANDLE hSrcMatrix2; 991 | } D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY; 992 | 993 | typedef struct _D3DPROCESSVERTICES { 994 | DWORD dwFlags; 995 | WORD wStart; 996 | WORD wDest; 997 | DWORD dwCount; 998 | DWORD dwReserved; 999 | } D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES; 1000 | 1001 | #define D3DPROCESSVERTICES_TRANSFORMLIGHT __MSABI_LONG(0x00000000) 1002 | #define D3DPROCESSVERTICES_TRANSFORM __MSABI_LONG(0x00000001) 1003 | #define D3DPROCESSVERTICES_COPY __MSABI_LONG(0x00000002) 1004 | #define D3DPROCESSVERTICES_OPMASK __MSABI_LONG(0x00000007) 1005 | 1006 | #define D3DPROCESSVERTICES_UPDATEEXTENTS __MSABI_LONG(0x00000008) 1007 | #define D3DPROCESSVERTICES_NOCOLOR __MSABI_LONG(0x00000010) 1008 | 1009 | typedef enum _D3DTEXTURESTAGESTATETYPE 1010 | { 1011 | D3DTSS_COLOROP = 1, 1012 | D3DTSS_COLORARG1 = 2, 1013 | D3DTSS_COLORARG2 = 3, 1014 | D3DTSS_ALPHAOP = 4, 1015 | D3DTSS_ALPHAARG1 = 5, 1016 | D3DTSS_ALPHAARG2 = 6, 1017 | D3DTSS_BUMPENVMAT00 = 7, 1018 | D3DTSS_BUMPENVMAT01 = 8, 1019 | D3DTSS_BUMPENVMAT10 = 9, 1020 | D3DTSS_BUMPENVMAT11 = 10, 1021 | D3DTSS_TEXCOORDINDEX = 11, 1022 | D3DTSS_ADDRESS = 12, 1023 | D3DTSS_ADDRESSU = 13, 1024 | D3DTSS_ADDRESSV = 14, 1025 | D3DTSS_BORDERCOLOR = 15, 1026 | D3DTSS_MAGFILTER = 16, 1027 | D3DTSS_MINFILTER = 17, 1028 | D3DTSS_MIPFILTER = 18, 1029 | D3DTSS_MIPMAPLODBIAS = 19, 1030 | D3DTSS_MAXMIPLEVEL = 20, 1031 | D3DTSS_MAXANISOTROPY = 21, 1032 | D3DTSS_BUMPENVLSCALE = 22, 1033 | D3DTSS_BUMPENVLOFFSET = 23, 1034 | D3DTSS_TEXTURETRANSFORMFLAGS = 24, 1035 | D3DTSS_FORCE_DWORD = 0x7fffffff 1036 | } D3DTEXTURESTAGESTATETYPE; 1037 | 1038 | #define D3DTSS_TCI_PASSTHRU 0x00000000 1039 | #define D3DTSS_TCI_CAMERASPACENORMAL 0x00010000 1040 | #define D3DTSS_TCI_CAMERASPACEPOSITION 0x00020000 1041 | #define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x00030000 1042 | 1043 | typedef enum _D3DTEXTUREOP 1044 | { 1045 | D3DTOP_DISABLE = 1, 1046 | D3DTOP_SELECTARG1 = 2, 1047 | D3DTOP_SELECTARG2 = 3, 1048 | 1049 | D3DTOP_MODULATE = 4, 1050 | D3DTOP_MODULATE2X = 5, 1051 | D3DTOP_MODULATE4X = 6, 1052 | 1053 | D3DTOP_ADD = 7, 1054 | D3DTOP_ADDSIGNED = 8, 1055 | D3DTOP_ADDSIGNED2X = 9, 1056 | D3DTOP_SUBTRACT = 10, 1057 | D3DTOP_ADDSMOOTH = 11, 1058 | 1059 | D3DTOP_BLENDDIFFUSEALPHA = 12, 1060 | D3DTOP_BLENDTEXTUREALPHA = 13, 1061 | D3DTOP_BLENDFACTORALPHA = 14, 1062 | D3DTOP_BLENDTEXTUREALPHAPM = 15, 1063 | D3DTOP_BLENDCURRENTALPHA = 16, 1064 | 1065 | D3DTOP_PREMODULATE = 17, 1066 | D3DTOP_MODULATEALPHA_ADDCOLOR = 18, 1067 | D3DTOP_MODULATECOLOR_ADDALPHA = 19, 1068 | D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20, 1069 | D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21, 1070 | 1071 | D3DTOP_BUMPENVMAP = 22, 1072 | D3DTOP_BUMPENVMAPLUMINANCE = 23, 1073 | D3DTOP_DOTPRODUCT3 = 24, 1074 | 1075 | D3DTOP_FORCE_DWORD = 0x7fffffff 1076 | } D3DTEXTUREOP; 1077 | 1078 | #define D3DTA_SELECTMASK 0x0000000f 1079 | #define D3DTA_DIFFUSE 0x00000000 1080 | #define D3DTA_CURRENT 0x00000001 1081 | #define D3DTA_TEXTURE 0x00000002 1082 | #define D3DTA_TFACTOR 0x00000003 1083 | #define D3DTA_SPECULAR 0x00000004 1084 | #define D3DTA_COMPLEMENT 0x00000010 1085 | #define D3DTA_ALPHAREPLICATE 0x00000020 1086 | 1087 | typedef enum _D3DTEXTUREMAGFILTER 1088 | { 1089 | D3DTFG_POINT = 1, 1090 | D3DTFG_LINEAR = 2, 1091 | D3DTFG_FLATCUBIC = 3, 1092 | D3DTFG_GAUSSIANCUBIC = 4, 1093 | D3DTFG_ANISOTROPIC = 5, 1094 | D3DTFG_FORCE_DWORD = 0x7fffffff 1095 | } D3DTEXTUREMAGFILTER; 1096 | 1097 | typedef enum _D3DTEXTUREMINFILTER 1098 | { 1099 | D3DTFN_POINT = 1, 1100 | D3DTFN_LINEAR = 2, 1101 | D3DTFN_ANISOTROPIC = 3, 1102 | D3DTFN_FORCE_DWORD = 0x7fffffff 1103 | } D3DTEXTUREMINFILTER; 1104 | 1105 | typedef enum _D3DTEXTUREMIPFILTER 1106 | { 1107 | D3DTFP_NONE = 1, 1108 | D3DTFP_POINT = 2, 1109 | D3DTFP_LINEAR = 3, 1110 | D3DTFP_FORCE_DWORD = 0x7fffffff 1111 | } D3DTEXTUREMIPFILTER; 1112 | 1113 | #define D3DTRIFLAG_START __MSABI_LONG(0x00000000) 1114 | #define D3DTRIFLAG_STARTFLAT(len) (len) 1115 | #define D3DTRIFLAG_ODD __MSABI_LONG(0x0000001e) 1116 | #define D3DTRIFLAG_EVEN __MSABI_LONG(0x0000001f) 1117 | 1118 | #define D3DTRIFLAG_EDGEENABLE1 __MSABI_LONG(0x00000100) 1119 | #define D3DTRIFLAG_EDGEENABLE2 __MSABI_LONG(0x00000200) 1120 | #define D3DTRIFLAG_EDGEENABLE3 __MSABI_LONG(0x00000400) 1121 | #define D3DTRIFLAG_EDGEENABLETRIANGLE \ 1122 | (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3) 1123 | 1124 | typedef struct _D3DTRIANGLE { 1125 | union { 1126 | WORD v1; 1127 | WORD wV1; 1128 | } DUMMYUNIONNAME1; 1129 | union { 1130 | WORD v2; 1131 | WORD wV2; 1132 | } DUMMYUNIONNAME2; 1133 | union { 1134 | WORD v3; 1135 | WORD wV3; 1136 | } DUMMYUNIONNAME3; 1137 | WORD wFlags; 1138 | } D3DTRIANGLE, *LPD3DTRIANGLE; 1139 | 1140 | typedef struct _D3DLINE { 1141 | union { 1142 | WORD v1; 1143 | WORD wV1; 1144 | } DUMMYUNIONNAME1; 1145 | union { 1146 | WORD v2; 1147 | WORD wV2; 1148 | } DUMMYUNIONNAME2; 1149 | } D3DLINE, *LPD3DLINE; 1150 | 1151 | typedef struct _D3DSPAN { 1152 | WORD wCount; 1153 | WORD wFirst; 1154 | } D3DSPAN, *LPD3DSPAN; 1155 | 1156 | typedef struct _D3DPOINT { 1157 | WORD wCount; 1158 | WORD wFirst; 1159 | } D3DPOINT, *LPD3DPOINT; 1160 | 1161 | typedef struct _D3DBRANCH { 1162 | DWORD dwMask; 1163 | DWORD dwValue; 1164 | WINBOOL bNegate; 1165 | DWORD dwOffset; 1166 | } D3DBRANCH, *LPD3DBRANCH; 1167 | 1168 | typedef struct _D3DSTATUS { 1169 | DWORD dwFlags; 1170 | DWORD dwStatus; 1171 | D3DRECT drExtent; 1172 | } D3DSTATUS, *LPD3DSTATUS; 1173 | 1174 | #define D3DSETSTATUS_STATUS __MSABI_LONG(0x00000001) 1175 | #define D3DSETSTATUS_EXTENTS __MSABI_LONG(0x00000002) 1176 | #define D3DSETSTATUS_ALL (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS) 1177 | 1178 | typedef struct _D3DCLIPSTATUS { 1179 | DWORD dwFlags; 1180 | DWORD dwStatus; 1181 | float minx, maxx; 1182 | float miny, maxy; 1183 | float minz, maxz; 1184 | } D3DCLIPSTATUS, *LPD3DCLIPSTATUS; 1185 | 1186 | #define D3DCLIPSTATUS_STATUS __MSABI_LONG(0x00000001) 1187 | #define D3DCLIPSTATUS_EXTENTS2 __MSABI_LONG(0x00000002) 1188 | #define D3DCLIPSTATUS_EXTENTS3 __MSABI_LONG(0x00000004) 1189 | 1190 | typedef struct { 1191 | DWORD dwSize; 1192 | DWORD dwTrianglesDrawn; 1193 | DWORD dwLinesDrawn; 1194 | DWORD dwPointsDrawn; 1195 | DWORD dwSpansDrawn; 1196 | DWORD dwVerticesProcessed; 1197 | } D3DSTATS, *LPD3DSTATS; 1198 | 1199 | #define D3DEXECUTE_CLIPPED __MSABI_LONG(0x00000001) 1200 | #define D3DEXECUTE_UNCLIPPED __MSABI_LONG(0x00000002) 1201 | 1202 | typedef struct _D3DEXECUTEDATA { 1203 | DWORD dwSize; 1204 | DWORD dwVertexOffset; 1205 | DWORD dwVertexCount; 1206 | DWORD dwInstructionOffset; 1207 | DWORD dwInstructionLength; 1208 | DWORD dwHVertexOffset; 1209 | D3DSTATUS dsStatus; 1210 | } D3DEXECUTEDATA, *LPD3DEXECUTEDATA; 1211 | 1212 | #define D3DPAL_FREE 0x00 1213 | #define D3DPAL_READONLY 0x40 1214 | #define D3DPAL_RESERVED 0x80 1215 | 1216 | typedef struct _D3DVERTEXBUFFERDESC { 1217 | DWORD dwSize; 1218 | DWORD dwCaps; 1219 | DWORD dwFVF; 1220 | DWORD dwNumVertices; 1221 | } D3DVERTEXBUFFERDESC, *LPD3DVERTEXBUFFERDESC; 1222 | 1223 | #define D3DVBCAPS_SYSTEMMEMORY __MSABI_LONG(0x00000800) 1224 | #define D3DVBCAPS_WRITEONLY __MSABI_LONG(0x00010000) 1225 | #define D3DVBCAPS_OPTIMIZED __MSABI_LONG(0x80000000) 1226 | #define D3DVBCAPS_DONOTCLIP __MSABI_LONG(0x00000001) 1227 | 1228 | #define D3DVOP_LIGHT (1 << 10) 1229 | #define D3DVOP_TRANSFORM (1 << 0) 1230 | #define D3DVOP_CLIP (1 << 2) 1231 | #define D3DVOP_EXTENTS (1 << 3) 1232 | 1233 | #define D3DMAXNUMVERTICES ((1<<16) - 1) 1234 | 1235 | #define D3DMAXNUMPRIMITIVES ((1<<16) - 1) 1236 | 1237 | #define D3DPV_DONOTCOPYDATA (1 << 0) 1238 | 1239 | #define D3DFVF_RESERVED0 0x001 1240 | #define D3DFVF_POSITION_MASK 0x00E 1241 | #define D3DFVF_XYZ 0x002 1242 | #define D3DFVF_XYZRHW 0x004 1243 | #define D3DFVF_XYZB1 0x006 1244 | #define D3DFVF_XYZB2 0x008 1245 | #define D3DFVF_XYZB3 0x00a 1246 | #define D3DFVF_XYZB4 0x00c 1247 | #define D3DFVF_XYZB5 0x00e 1248 | 1249 | #define D3DFVF_NORMAL 0x010 1250 | #define D3DFVF_RESERVED1 0x020 1251 | #define D3DFVF_DIFFUSE 0x040 1252 | #define D3DFVF_SPECULAR 0x080 1253 | #define D3DFVF_TEXCOUNT_MASK 0xf00 1254 | #define D3DFVF_TEXCOUNT_SHIFT 8 1255 | #define D3DFVF_TEX0 0x000 1256 | #define D3DFVF_TEX1 0x100 1257 | #define D3DFVF_TEX2 0x200 1258 | #define D3DFVF_TEX3 0x300 1259 | #define D3DFVF_TEX4 0x400 1260 | #define D3DFVF_TEX5 0x500 1261 | #define D3DFVF_TEX6 0x600 1262 | #define D3DFVF_TEX7 0x700 1263 | #define D3DFVF_TEX8 0x800 1264 | 1265 | #define D3DFVF_RESERVED2 0xf000 1266 | 1267 | #define D3DFVF_VERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 ) 1268 | #define D3DFVF_LVERTEX ( D3DFVF_XYZ | D3DFVF_RESERVED1 | D3DFVF_DIFFUSE | \ 1269 | D3DFVF_SPECULAR | D3DFVF_TEX1 ) 1270 | #define D3DFVF_TLVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | \ 1271 | D3DFVF_TEX1 ) 1272 | 1273 | typedef struct _D3DDP_PTRSTRIDE 1274 | { 1275 | void *lpvData; 1276 | DWORD dwStride; 1277 | } D3DDP_PTRSTRIDE; 1278 | 1279 | #define D3DDP_MAXTEXCOORD 8 1280 | 1281 | typedef struct _D3DDRAWPRIMITIVESTRIDEDDATA { 1282 | D3DDP_PTRSTRIDE position; 1283 | D3DDP_PTRSTRIDE normal; 1284 | D3DDP_PTRSTRIDE diffuse; 1285 | D3DDP_PTRSTRIDE specular; 1286 | D3DDP_PTRSTRIDE textureCoords[D3DDP_MAXTEXCOORD]; 1287 | } D3DDRAWPRIMITIVESTRIDEDDATA ,*LPD3DDRAWPRIMITIVESTRIDEDDATA; 1288 | 1289 | #define D3DVIS_INSIDE_FRUSTUM 0 1290 | #define D3DVIS_INTERSECT_FRUSTUM 1 1291 | #define D3DVIS_OUTSIDE_FRUSTUM 2 1292 | #define D3DVIS_INSIDE_LEFT 0 1293 | #define D3DVIS_INTERSECT_LEFT (1 << 2) 1294 | #define D3DVIS_OUTSIDE_LEFT (2 << 2) 1295 | #define D3DVIS_INSIDE_RIGHT 0 1296 | #define D3DVIS_INTERSECT_RIGHT (1 << 4) 1297 | #define D3DVIS_OUTSIDE_RIGHT (2 << 4) 1298 | #define D3DVIS_INSIDE_TOP 0 1299 | #define D3DVIS_INTERSECT_TOP (1 << 6) 1300 | #define D3DVIS_OUTSIDE_TOP (2 << 6) 1301 | #define D3DVIS_INSIDE_BOTTOM 0 1302 | #define D3DVIS_INTERSECT_BOTTOM (1 << 8) 1303 | #define D3DVIS_OUTSIDE_BOTTOM (2 << 8) 1304 | #define D3DVIS_INSIDE_NEAR 0 1305 | #define D3DVIS_INTERSECT_NEAR (1 << 10) 1306 | #define D3DVIS_OUTSIDE_NEAR (2 << 10) 1307 | #define D3DVIS_INSIDE_FAR 0 1308 | #define D3DVIS_INTERSECT_FAR (1 << 12) 1309 | #define D3DVIS_OUTSIDE_FAR (2 << 12) 1310 | 1311 | #define D3DVIS_MASK_FRUSTUM (3 << 0) 1312 | #define D3DVIS_MASK_LEFT (3 << 2) 1313 | #define D3DVIS_MASK_RIGHT (3 << 4) 1314 | #define D3DVIS_MASK_TOP (3 << 6) 1315 | #define D3DVIS_MASK_BOTTOM (3 << 8) 1316 | #define D3DVIS_MASK_NEAR (3 << 10) 1317 | #define D3DVIS_MASK_FAR (3 << 12) 1318 | 1319 | #define D3DDEVINFOID_TEXTUREMANAGER 1 1320 | #define D3DDEVINFOID_D3DTEXTUREMANAGER 2 1321 | #define D3DDEVINFOID_TEXTURING 3 1322 | 1323 | typedef enum _D3DSTATEBLOCKTYPE 1324 | { 1325 | D3DSBT_ALL = 1, 1326 | D3DSBT_PIXELSTATE = 2, 1327 | D3DSBT_VERTEXSTATE = 3, 1328 | D3DSBT_FORCE_DWORD = 0xffffffff 1329 | } D3DSTATEBLOCKTYPE; 1330 | 1331 | typedef enum _D3DVERTEXBLENDFLAGS 1332 | { 1333 | D3DVBLEND_DISABLE = 0, 1334 | D3DVBLEND_1WEIGHT = 1, 1335 | D3DVBLEND_2WEIGHTS = 2, 1336 | D3DVBLEND_3WEIGHTS = 3, 1337 | } D3DVERTEXBLENDFLAGS; 1338 | 1339 | typedef enum _D3DTEXTURETRANSFORMFLAGS { 1340 | D3DTTFF_DISABLE = 0, 1341 | D3DTTFF_COUNT1 = 1, 1342 | D3DTTFF_COUNT2 = 2, 1343 | D3DTTFF_COUNT3 = 3, 1344 | D3DTTFF_COUNT4 = 4, 1345 | D3DTTFF_PROJECTED = 256, 1346 | D3DTTFF_FORCE_DWORD = 0x7fffffff 1347 | } D3DTEXTURETRANSFORMFLAGS; 1348 | 1349 | #define D3DFVF_TEXTUREFORMAT2 0 1350 | #define D3DFVF_TEXTUREFORMAT1 3 1351 | #define D3DFVF_TEXTUREFORMAT3 1 1352 | #define D3DFVF_TEXTUREFORMAT4 2 1353 | 1354 | #define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16)) 1355 | #define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2) 1356 | #define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16)) 1357 | #define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16)) 1358 | 1359 | #endif 1360 | -------------------------------------------------------------------------------- /directx_api/d3dx9.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 David Adam 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 | */ 18 | 19 | #ifndef __D3DX9_H__ 20 | #define __D3DX9_H__ 21 | 22 | #include 23 | 24 | #define D3DX_DEFAULT ((UINT)-1) 25 | #define D3DX_DEFAULT_NONPOW2 ((UINT)-2) 26 | #define D3DX_DEFAULT_FLOAT FLT_MAX 27 | #define D3DX_FROM_FILE ((UINT)-3) 28 | #define D3DFMT_FROM_FILE ((D3DFORMAT)-3) 29 | 30 | #include "d3d9.h" 31 | #include "d3dx9math.h" 32 | #include "d3dx9core.h" 33 | #include "d3dx9xof.h" 34 | #include "d3dx9mesh.h" 35 | #include "d3dx9shader.h" 36 | #include "d3dx9effect.h" 37 | #include "d3dx9shape.h" 38 | #include "d3dx9anim.h" 39 | #include "d3dx9tex.h" 40 | 41 | #define _FACDD 0x876 42 | #define MAKE_DDHRESULT(code) MAKE_HRESULT(1, _FACDD, code) 43 | 44 | enum _D3DXERR { 45 | D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), 46 | D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), 47 | D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), 48 | D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), 49 | D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), 50 | D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), 51 | D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), 52 | D3DXERR_DUPLICATENAMEDFRAGMENT = MAKE_DDHRESULT(2907), 53 | D3DXERR_CANNOTREMOVELASTITEM = MAKE_DDHRESULT(2908), 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /directx_api/dxcustomtypes.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef WINBOOL 4 | #define WINBOOL bool 5 | #endif 6 | 7 | #ifndef __MSABI_LONG 8 | #define __MSABI_LONG(x) x 9 | #endif 10 | -------------------------------------------------------------------------------- /helper/dummy_window.cpp: -------------------------------------------------------------------------------- 1 | #include "dummy_window.h" 2 | 3 | #include 4 | 5 | #pragma comment(lib, "user32.lib") 6 | 7 | namespace NQtScreen { 8 | 9 | static const char* DUMMY_WINDOW = "dummy_dx_test_cls"; 10 | 11 | LRESULT CALLBACK TestProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { 12 | if (msg == WM_NCCREATE) { 13 | return true; 14 | } 15 | return DefWindowProc(hwnd, msg, wparam, lparam); 16 | } 17 | 18 | static bool RegisterDummyWindow() { 19 | static bool registered = false; 20 | if (registered) { 21 | return true; 22 | } 23 | 24 | static WNDCLASSA wc; 25 | 26 | memset(&wc, 0, sizeof(wc)); 27 | wc.style = CS_OWNDC; 28 | wc.hInstance = GetModuleHandle(nullptr); 29 | wc.lpfnWndProc = TestProc; 30 | wc.lpszClassName = DUMMY_WINDOW; 31 | 32 | if (!RegisterClassA(&wc)) { 33 | return false; 34 | } 35 | 36 | registered = true; 37 | 38 | return true; 39 | } 40 | 41 | 42 | TDummyWindow::TDummyWindow(const std::string& caption) 43 | : Caption(caption) 44 | , Hwnd(0) 45 | { 46 | if (!RegisterDummyWindow()) { 47 | return; 48 | } 49 | HMODULE hmd = GetModuleHandle(nullptr); 50 | Hwnd = CreateWindowExA(0, DUMMY_WINDOW, Caption.c_str(), 51 | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, 52 | hmd, nullptr); 53 | } 54 | 55 | TDummyWindow::~TDummyWindow() { 56 | if (Hwnd) { 57 | DestroyWindow(Hwnd); 58 | } 59 | } 60 | 61 | TDummyWindow::operator HWND() { 62 | return Hwnd; 63 | } 64 | 65 | TDummyWindow::operator bool() { 66 | return bool(Hwnd); 67 | } 68 | 69 | } // NQtScreen 70 | -------------------------------------------------------------------------------- /helper/dummy_window.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace NQtScreen { 7 | 8 | class TDummyWindow { 9 | public: 10 | TDummyWindow(const std::string& caption); 11 | ~TDummyWindow(); 12 | operator HWND(); 13 | operator bool(); 14 | private: 15 | std::string Caption; 16 | HWND Hwnd; 17 | }; 18 | 19 | } // NQtScreen 20 | -------------------------------------------------------------------------------- /helper/dx8offsets.cpp: -------------------------------------------------------------------------------- 1 | #include "dxoffsets.h" 2 | #include "dummy_window.h" 3 | 4 | #include 5 | #include 6 | 7 | namespace NQtScreen { 8 | 9 | typedef IDirect3D8 *(WINAPI *DX8CreateFunc)(UINT); 10 | 11 | class TDirect3D8Ctx { 12 | public: 13 | TDirect3D8Ctx() 14 | : Wnd("dx8 test window") 15 | , Module(0) 16 | , DX8(nullptr) 17 | , Device(nullptr) 18 | { 19 | if (!Wnd) { 20 | return; 21 | } 22 | 23 | Module = LoadLibraryA("d3d8.dll"); 24 | if (!Module) { 25 | return; 26 | } 27 | DX8CreateFunc create = (DX8CreateFunc)GetProcAddress(Module, "Direct3DCreate8"); 28 | if (!create) { 29 | return; 30 | } 31 | DX8 = create(D3D_SDK_VERSION); 32 | if (!DX8) { 33 | return; 34 | } 35 | D3DPRESENT_PARAMETERS presentParams = {}; 36 | presentParams.Windowed = true; 37 | presentParams.SwapEffect = D3DSWAPEFFECT_FLIP; 38 | presentParams.BackBufferFormat = D3DFMT_A8R8G8B8; 39 | presentParams.BackBufferWidth = 4; 40 | presentParams.BackBufferHeight = 4; 41 | presentParams.BackBufferCount = 1; 42 | presentParams.hDeviceWindow = NULL; 43 | presentParams.hDeviceWindow = Wnd; 44 | 45 | HRESULT hr = DX8->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Wnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, 46 | &presentParams, &Device); 47 | 48 | } 49 | ~TDirect3D8Ctx() { 50 | if (Device) { 51 | Device->Release(); 52 | } 53 | if (DX8) { 54 | DX8->Release(); 55 | } 56 | } 57 | HMODULE GetModule() { 58 | return Module; 59 | } 60 | LPDIRECT3DDEVICE8 GetDevice() { 61 | return Device; 62 | } 63 | private: 64 | TDummyWindow Wnd; 65 | HMODULE Module; 66 | IDirect3D8* DX8; 67 | LPDIRECT3DDEVICE8 Device; 68 | }; 69 | 70 | void GetDX8Offsets(uint64_t& present) { 71 | TDirect3D8Ctx dx8; 72 | present = 0; 73 | if (dx8.GetModule() && dx8.GetDevice()) { 74 | present = GetVtableOffset((uint64_t)dx8.GetModule(), dx8.GetDevice(), 15); 75 | } 76 | } 77 | 78 | } // NQtScreen 79 | -------------------------------------------------------------------------------- /helper/dx9offsets.cpp: -------------------------------------------------------------------------------- 1 | #include "dxoffsets.h" 2 | #include "dummy_window.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace NQtScreen { 10 | 11 | typedef IDirect3D9 *(WINAPI *DX9CreateFunc)(UINT); 12 | 13 | class TDirect3D9Ctx { 14 | public: 15 | TDirect3D9Ctx() 16 | : Wnd("dx8 test window") 17 | , Module(0) 18 | , DX9(nullptr) 19 | , Device(nullptr) 20 | { 21 | if (!Wnd) { 22 | return; 23 | } 24 | Module = LoadLibraryA("d3d9.dll"); 25 | if (!Module) { 26 | return; 27 | } 28 | DX9CreateFunc create = (DX9CreateFunc)GetProcAddress(Module, "Direct3DCreate9"); 29 | if (!create) { 30 | return; 31 | } 32 | DX9 = create(D3D_SDK_VERSION); 33 | if (!DX9) { 34 | return; 35 | } 36 | D3DPRESENT_PARAMETERS presentParams = {}; 37 | presentParams.Windowed = true; 38 | presentParams.SwapEffect = D3DSWAPEFFECT_FLIP; 39 | presentParams.BackBufferFormat = D3DFMT_A8R8G8B8; 40 | presentParams.BackBufferWidth = 4; 41 | presentParams.BackBufferHeight = 4; 42 | presentParams.BackBufferCount = 1; 43 | presentParams.hDeviceWindow = Wnd; 44 | 45 | DX9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Wnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, 46 | &presentParams, &Device); 47 | } 48 | ~TDirect3D9Ctx() { 49 | if (Device) { 50 | Device->Release(); 51 | } 52 | if (DX9) { 53 | DX9->Release(); 54 | } 55 | } 56 | HMODULE GetModule() { 57 | return Module; 58 | } 59 | LPDIRECT3DDEVICE9 GetDevice() { 60 | return Device; 61 | } 62 | private: 63 | TDummyWindow Wnd; 64 | HMODULE Module; 65 | IDirect3D9* DX9; 66 | LPDIRECT3DDEVICE9 Device; 67 | }; 68 | 69 | 70 | void GetDX9Offsets(uint64_t& present, uint64_t& presentEx) { 71 | TDirect3D9Ctx dx9; 72 | present = 0; 73 | presentEx = 0; 74 | if (dx9.GetModule() && dx9.GetDevice()) { 75 | present = GetVtableOffset((uint64_t)dx9.GetModule(), dx9.GetDevice(), 17); 76 | presentEx = GetVtableOffset((uint64_t)dx9.GetModule(), dx9.GetDevice(), 121); 77 | } 78 | } 79 | 80 | } // NQtScreen 81 | -------------------------------------------------------------------------------- /helper/dxgi_offsets.cpp: -------------------------------------------------------------------------------- 1 | #include "dxoffsets.h" 2 | #include "dummy_window.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace NQtScreen { 9 | 10 | typedef HRESULT (WINAPI *DX10CreateFunc)(IDXGIAdapter*, 11 | D3D10_DRIVER_TYPE, HMODULE, UINT, UINT, 12 | DXGI_SWAP_CHAIN_DESC*, IDXGISwapChain**, IUnknown**); 13 | 14 | class TDirect3DgiCtx { 15 | public: 16 | TDirect3DgiCtx() 17 | : Wnd("dxgi test window") 18 | , DxgiModule(0) 19 | , Dx10Module(0) 20 | , Device(nullptr) 21 | , SwapChain(nullptr) 22 | { 23 | if (!Wnd) { 24 | return; 25 | } 26 | DxgiModule = LoadLibraryA("dxgi.dll"); 27 | if (!DxgiModule) { 28 | return; 29 | } 30 | Dx10Module = LoadLibraryA("d3d10.dll"); 31 | if (!Dx10Module) { 32 | return; 33 | } 34 | DX10CreateFunc create = (DX10CreateFunc)GetProcAddress(Dx10Module, 35 | "D3D10CreateDeviceAndSwapChain"); 36 | if (!create) { 37 | return; 38 | } 39 | DXGI_SWAP_CHAIN_DESC desc = {}; 40 | desc.BufferCount = 2; 41 | desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; 42 | desc.BufferDesc.Width = 2; 43 | desc.BufferDesc.Height = 2; 44 | desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; 45 | desc.OutputWindow = Wnd; 46 | desc.SampleDesc.Count = 1; 47 | desc.Windowed = true; 48 | 49 | create(nullptr, D3D10_DRIVER_TYPE_NULL, nullptr, 0, 50 | D3D10_SDK_VERSION, &desc, &SwapChain, &Device); 51 | } 52 | ~TDirect3DgiCtx() { 53 | if (Device) { 54 | Device->Release(); 55 | } 56 | if (SwapChain) { 57 | SwapChain->Release(); 58 | } 59 | } 60 | HMODULE GetDxgiModule() { 61 | return DxgiModule; 62 | } 63 | IDXGISwapChain* GetSwapChain() { 64 | return SwapChain; 65 | } 66 | private: 67 | TDummyWindow Wnd; 68 | HMODULE DxgiModule; 69 | HMODULE Dx10Module; 70 | IUnknown* Device; 71 | IDXGISwapChain* SwapChain; 72 | }; 73 | 74 | void GetDXGIOffsets(uint64_t& present) { 75 | TDirect3DgiCtx dgi; 76 | present = 0; 77 | if (dgi.GetSwapChain() && dgi.GetDxgiModule()) { 78 | present = GetVtableOffset((uint64_t)dgi.GetDxgiModule(), dgi.GetSwapChain(), 8); 79 | } 80 | } 81 | 82 | } // NQtScreen 83 | -------------------------------------------------------------------------------- /helper/dxoffsets.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace NQtScreen { 7 | 8 | inline uint64_t GetVtableOffset(uint64_t module, void* cls, uint32_t offset) { 9 | uintptr_t* virtualTable = *(uintptr_t**)cls; 10 | return (uint64_t)(virtualTable[offset] - module); 11 | } 12 | 13 | void GetDX8Offsets(uint64_t& present); 14 | void GetDX9Offsets(uint64_t& present, uint64_t& presentEx); 15 | void GetDXGIOffsets(uint64_t& present); 16 | 17 | } // NQtScreen 18 | -------------------------------------------------------------------------------- /helper/helper.pro: -------------------------------------------------------------------------------- 1 | TARGET=helper 2 | TEMPLATE=app 3 | 4 | QT += gui widgets core network 5 | 6 | QMAKE_CXXFLAGS += -std=c++11 7 | 8 | INCLUDEPATH += ../directx_api/ 9 | 10 | HEADERS += \ 11 | dummy_window.h \ 12 | dxoffsets.h \ 13 | inject.h 14 | 15 | SOURCES += main.cpp \ 16 | dummy_window.cpp \ 17 | dx8offsets.cpp \ 18 | dx9offsets.cpp \ 19 | dxgi_offsets.cpp \ 20 | inject.cpp 21 | -------------------------------------------------------------------------------- /helper/inject.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "inject.h" 6 | 7 | namespace NQtScreen { 8 | 9 | int GetProcessID(const std::wstring &exeFileName) { 10 | HANDLE snapHandle; 11 | PROCESSENTRY32 processEntry = {0}; 12 | 13 | if ((snapHandle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)) == INVALID_HANDLE_VALUE) { 14 | return 0; 15 | } 16 | 17 | processEntry.dwSize = sizeof(PROCESSENTRY32); 18 | Process32First(snapHandle, &processEntry); 19 | do { 20 | if (wcscmp(processEntry.szExeFile, exeFileName.c_str()) == 0 ) { 21 | return processEntry.th32ProcessID; 22 | } 23 | } while (Process32Next(snapHandle, &processEntry)); 24 | 25 | if (snapHandle != INVALID_HANDLE_VALUE) { 26 | CloseHandle(snapHandle); 27 | } 28 | 29 | return 0; 30 | } 31 | 32 | bool InjectDll(int pid, const std::string& dll) { 33 | 34 | HANDLE hProcess = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, FALSE, pid); 35 | HMODULE hKernel32 = ::GetModuleHandle(L"kernel32.dll"); 36 | 37 | void* remoteMemoryBlock = ::VirtualAllocEx(hProcess, NULL, dll.size() + 1, MEM_COMMIT, PAGE_READWRITE ); 38 | 39 | if (!remoteMemoryBlock) { 40 | return false; 41 | } 42 | 43 | ::WriteProcessMemory(hProcess, remoteMemoryBlock, (void*)dll.c_str(), dll.size() + 1, NULL); 44 | 45 | HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, 46 | (LPTHREAD_START_ROUTINE)::GetProcAddress(hKernel32, "LoadLibraryA"), 47 | remoteMemoryBlock, 0, NULL); 48 | 49 | if (hThread == NULL ) { 50 | ::VirtualFreeEx(hProcess, remoteMemoryBlock, dll.size(), MEM_RELEASE); 51 | return false; 52 | } 53 | 54 | return true; 55 | } 56 | 57 | } // NQtScreen 58 | -------------------------------------------------------------------------------- /helper/inject.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace NQtScreen { 4 | 5 | int GetProcessID(const std::wstring& exeFileName); 6 | bool InjectDll(int pid, const std::string& dll); 7 | 8 | } // NQtScreen 9 | -------------------------------------------------------------------------------- /helper/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "dxoffsets.h" 6 | #include "inject.h" 7 | 8 | int main(int argc, char** argv) { 9 | if (argc < 2) { 10 | return 1; 11 | } 12 | 13 | std::string command = argv[1]; 14 | if (command == "offsets") { 15 | uint64_t dx8Present; 16 | uint64_t dx9Present, dx9PresentEx; 17 | uint64_t dxGIPresent; 18 | new QTimer(); 19 | NQtScreen::GetDX8Offsets(dx8Present); 20 | NQtScreen::GetDX9Offsets(dx9Present, dx9PresentEx); 21 | NQtScreen::GetDXGIOffsets(dxGIPresent); 22 | std::cout << dx8Present << "\n"; 23 | std::cout << dx9Present << "\n"; 24 | std::cout << dx9PresentEx << "\n"; 25 | std::cout << dxGIPresent << "\n"; 26 | return 0; 27 | } 28 | if (command == "inject") { 29 | if (argc < 4) { 30 | return 2; 31 | } 32 | int pid = std::stoi(std::string(argv[2])); 33 | std::string dllPath = std::string(argv[3]); 34 | if (NQtScreen::InjectDll(pid, dllPath)) { 35 | return 0; 36 | } 37 | return 3; 38 | } 39 | return 4; 40 | } 41 | -------------------------------------------------------------------------------- /injected_dll/dx10screen.cpp: -------------------------------------------------------------------------------- 1 | #include "dxscreen.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | static DXGI_FORMAT GetDxgiFormat(DXGI_FORMAT format) { 9 | if (format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB) { 10 | return DXGI_FORMAT_B8G8R8A8_UNORM; 11 | } 12 | if (format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) { 13 | return DXGI_FORMAT_R8G8B8A8_UNORM; 14 | } 15 | return format; 16 | } 17 | 18 | void GetDX10Screenshot(IDXGISwapChain* swapChain, QByteArray& screen) { 19 | IDXGIResource *backbufferPtr = nullptr; 20 | swapChain->GetBuffer(0, __uuidof(ID3D10Resource), (void**)&backbufferPtr); 21 | if (!backbufferPtr) { 22 | return; 23 | } 24 | 25 | ID3D10Resource* backbuffer; 26 | HRESULT hr = backbufferPtr->QueryInterface(__uuidof(ID3D10Resource), (void**)&backbuffer); 27 | if (FAILED(hr)) { 28 | return; 29 | } 30 | ID3D10Device* device; 31 | hr = swapChain->GetDevice(__uuidof(ID3D10Device), (void**)&device); 32 | if (FAILED(hr)) { 33 | return; 34 | } 35 | 36 | DXGI_SWAP_CHAIN_DESC desc; 37 | hr = swapChain->GetDesc(&desc); 38 | if (FAILED(hr)) { 39 | return; 40 | } 41 | D3D10_TEXTURE2D_DESC textDesc = {}; 42 | textDesc.Format = GetDxgiFormat(desc.BufferDesc.Format); 43 | textDesc.Width = desc.BufferDesc.Width; 44 | textDesc.Height = desc.BufferDesc.Height; 45 | textDesc.MipLevels = 1; 46 | textDesc.ArraySize = 1; 47 | textDesc.SampleDesc.Count = 1; 48 | textDesc.Usage = D3D10_USAGE_STAGING; 49 | textDesc.CPUAccessFlags = D3D10_CPU_ACCESS_READ; 50 | 51 | ID3D10Texture2D* texture = nullptr; 52 | hr = device->CreateTexture2D(&textDesc, 0, &texture); 53 | if (FAILED(hr)) { 54 | return; 55 | } 56 | 57 | device->CopyResource(texture, backbuffer); 58 | 59 | D3D10_MAPPED_TEXTURE2D mapText = {0, 0}; 60 | hr = texture->Map(0, D3D10_MAP_READ, 0, &mapText); 61 | if (FAILED(hr)) { 62 | return; 63 | } 64 | 65 | NQtScreen::EImgByteFormat fmt = NQtScreen::BF_R8G8B8A8; 66 | if (textDesc.Format == DXGI_FORMAT_B8G8R8A8_UNORM || 67 | textDesc.Format == DXGI_FORMAT_B8G8R8X8_UNORM || 68 | textDesc.Format == DXGI_FORMAT_B8G8R8A8_TYPELESS || 69 | textDesc.Format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB || 70 | textDesc.Format == DXGI_FORMAT_B8G8R8X8_TYPELESS || 71 | textDesc.Format == DXGI_FORMAT_B8G8R8X8_UNORM_SRGB) 72 | { 73 | fmt = NQtScreen::BF_B8G8R8A8; 74 | } 75 | 76 | screen = PackImageData(fmt, (char*)mapText.pData, textDesc.Height, textDesc.Width); 77 | } 78 | -------------------------------------------------------------------------------- /injected_dll/dx11screen.cpp: -------------------------------------------------------------------------------- 1 | #include "dxscreen.h" 2 | #include "hook.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | static DXGI_FORMAT GetDxgiFormat(DXGI_FORMAT format) { 10 | if (format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB) { 11 | return DXGI_FORMAT_B8G8R8A8_UNORM; 12 | } 13 | if (format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) { 14 | return DXGI_FORMAT_R8G8B8A8_UNORM; 15 | } 16 | return format; 17 | } 18 | 19 | void GetDX11Screenshot(IDXGISwapChain* swapChain, QByteArray& screen) { 20 | IDXGIResource *backbufferPtr = nullptr; 21 | swapChain->GetBuffer(0, __uuidof(ID3D11Resource), (void**)&backbufferPtr); 22 | if (!backbufferPtr) { 23 | return; 24 | } 25 | 26 | ID3D11Resource* backbuffer; 27 | HRESULT hr = backbufferPtr->QueryInterface(__uuidof(ID3D11Resource), (void**)&backbuffer); 28 | if (FAILED(hr)) { 29 | return; 30 | } 31 | ID3D11Device* device; 32 | hr = swapChain->GetDevice(__uuidof(ID3D11Device), (void**)&device); 33 | if (FAILED(hr)) { 34 | return; 35 | } 36 | 37 | DXGI_SWAP_CHAIN_DESC desc; 38 | hr = swapChain->GetDesc(&desc); 39 | if (FAILED(hr)) { 40 | return; 41 | } 42 | D3D11_TEXTURE2D_DESC textDesc = {}; 43 | textDesc.Format = GetDxgiFormat(desc.BufferDesc.Format); 44 | textDesc.Width = desc.BufferDesc.Width; 45 | textDesc.Height = desc.BufferDesc.Height; 46 | textDesc.MipLevels = 1; 47 | textDesc.ArraySize = 1; 48 | textDesc.SampleDesc.Count = 1; 49 | textDesc.Usage = D3D11_USAGE_STAGING; 50 | textDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; 51 | 52 | ID3D11Texture2D* texture = nullptr; 53 | hr = device->CreateTexture2D(&textDesc, 0, &texture); 54 | if (FAILED(hr)) { 55 | return; 56 | } 57 | 58 | ID3D11DeviceContext* context = nullptr; 59 | 60 | device->Release(); 61 | 62 | device->GetImmediateContext(&context); 63 | if (!context) { 64 | return; 65 | } 66 | 67 | context->CopyResource(texture, backbuffer); 68 | 69 | D3D11_MAPPED_SUBRESOURCE mapSubres = {0, 0, 0}; 70 | 71 | hr = context->Map(texture, 0, D3D11_MAP_READ, 0, &mapSubres); 72 | if (FAILED(hr)) { 73 | return; 74 | } 75 | NQtScreen::EImgByteFormat fmt = NQtScreen::BF_R8G8B8A8; 76 | if (textDesc.Format == DXGI_FORMAT_B8G8R8A8_UNORM || 77 | textDesc.Format == DXGI_FORMAT_B8G8R8X8_UNORM || 78 | textDesc.Format == DXGI_FORMAT_B8G8R8A8_TYPELESS || 79 | textDesc.Format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB || 80 | textDesc.Format == DXGI_FORMAT_B8G8R8X8_TYPELESS || 81 | textDesc.Format == DXGI_FORMAT_B8G8R8X8_UNORM_SRGB) 82 | { 83 | fmt = NQtScreen::BF_B8G8R8A8; 84 | } 85 | 86 | screen = PackImageData(fmt, (char*)mapSubres.pData, textDesc.Height, textDesc.Width); 87 | } 88 | -------------------------------------------------------------------------------- /injected_dll/dx8screen.cpp: -------------------------------------------------------------------------------- 1 | #include "dxscreen.h" 2 | #include "hook.h" 3 | 4 | #include 5 | #include 6 | 7 | 8 | struct THookCtxDX8 { 9 | void* PresentFun = nullptr; 10 | TScreenCallback Callback; 11 | }; 12 | static THookCtxDX8* HookCtx = new THookCtxDX8(); 13 | 14 | 15 | void GetDX8Screenshot(IDirect3DDevice8* device) { 16 | HRESULT hr; 17 | 18 | IDirect3DSurface8* backbuffer; 19 | hr = device->GetRenderTarget(&backbuffer); 20 | if (FAILED(hr)) { 21 | return; 22 | } 23 | 24 | D3DSURFACE_DESC desc; 25 | hr = backbuffer->GetDesc(&desc); 26 | if (FAILED(hr)) { 27 | return; 28 | } 29 | 30 | IDirect3DSurface8* buffer; 31 | hr = device->CreateImageSurface(desc.Width, desc.Height, desc.Format, &buffer); 32 | if (FAILED(hr)) { 33 | return; 34 | } 35 | 36 | hr = device->CopyRects(backbuffer, NULL, 0, buffer, NULL); 37 | backbuffer->Release(); 38 | 39 | if (FAILED(hr)) { 40 | return; 41 | } 42 | 43 | D3DLOCKED_RECT rect; 44 | hr = buffer->LockRect(&rect, NULL, D3DLOCK_READONLY); 45 | if (FAILED(hr)) { 46 | return; 47 | } 48 | 49 | QByteArray screen = PackImageData(NQtScreen::BF_B8G8R8A8, (char*)rect.pBits, desc.Height, desc.Width); 50 | HookCtx->Callback(screen); 51 | 52 | buffer->Release(); 53 | } 54 | 55 | static HRESULT STDMETHODCALLTYPE HookPresent(IDirect3DDevice8* device, 56 | CONST RECT* srcRect, CONST RECT* dstRect, 57 | HWND overrideWindow, CONST RGNDATA* dirtyRegion) 58 | { 59 | UnHook(HookCtx->PresentFun); 60 | GetDX8Screenshot(device); 61 | return device->Present(srcRect, dstRect, overrideWindow, dirtyRegion); 62 | } 63 | 64 | bool MakeDX8Screen(const TScreenCallback& callback, uint64_t presentOffset) { 65 | HMODULE dx8module = GetSystemModule("d3d8.dll"); 66 | if (!dx8module) { 67 | return false; 68 | } 69 | HookCtx->PresentFun = (void*)((uintptr_t)dx8module + (uintptr_t)presentOffset); 70 | HookCtx->Callback = callback; 71 | Hook(HookCtx->PresentFun, HookPresent); 72 | return true; 73 | } 74 | -------------------------------------------------------------------------------- /injected_dll/dx9screen.cpp: -------------------------------------------------------------------------------- 1 | #include "dxscreen.h" 2 | #include "hook.h" 3 | 4 | #include 5 | 6 | #include 7 | 8 | 9 | struct THookCtxDX9 { 10 | void* PresentFun = nullptr; 11 | void* PresentExFun = nullptr; 12 | TScreenCallback Callback; 13 | }; 14 | static THookCtxDX9* HookCtx = new THookCtxDX9(); 15 | 16 | void GetDX9Screenshot(IDirect3DDevice9* device) { 17 | HRESULT hr; 18 | 19 | IDirect3DSurface9* backbuffer; 20 | hr = device->GetRenderTarget(0, &backbuffer); 21 | if (FAILED(hr)) { 22 | return; 23 | } 24 | 25 | D3DSURFACE_DESC desc; 26 | hr = backbuffer->GetDesc(&desc); 27 | if (FAILED(hr)) { 28 | return; 29 | } 30 | 31 | IDirect3DSurface9* buffer; 32 | hr = device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, 33 | D3DPOOL_SYSTEMMEM, &buffer, nullptr); 34 | if (FAILED(hr)) { 35 | return; 36 | } 37 | 38 | hr = device->GetRenderTargetData(backbuffer, buffer); 39 | if (FAILED(hr)) { 40 | return; 41 | } 42 | 43 | backbuffer->Release(); 44 | 45 | D3DLOCKED_RECT rect; 46 | hr = buffer->LockRect(&rect, NULL, D3DLOCK_READONLY); 47 | if (FAILED(hr)) { 48 | return; 49 | } 50 | 51 | NQtScreen::EImgByteFormat fmt = NQtScreen::BF_B8G8R8A8; 52 | if (desc.Format == D3DFMT_A8B8G8R8 || 53 | desc.Format == D3DFMT_X8B8G8R8) 54 | { 55 | fmt = NQtScreen::BF_R8G8B8A8; 56 | } 57 | 58 | QByteArray screen = PackImageData(fmt, (char*)rect.pBits, desc.Height, desc.Width); 59 | HookCtx->Callback(screen); 60 | 61 | buffer->Release(); 62 | } 63 | 64 | static HRESULT STDMETHODCALLTYPE HookPresent(IDirect3DDevice9* device, 65 | CONST RECT* srcRect, CONST RECT* dstRect, 66 | HWND overrideWindow, CONST RGNDATA* dirtyRegion) 67 | { 68 | UnHook(HookCtx->PresentFun); 69 | UnHook(HookCtx->PresentExFun); 70 | GetDX9Screenshot(device); 71 | return device->Present(srcRect, dstRect, overrideWindow, dirtyRegion); 72 | } 73 | 74 | static HRESULT STDMETHODCALLTYPE HookPresentEx(IDirect3DDevice9Ex* device, 75 | CONST RECT* srcRect, CONST RECT* dstRect, 76 | HWND overrideWindow, CONST RGNDATA* dirtyRegion, 77 | DWORD flags) 78 | { 79 | UnHook(HookCtx->PresentFun); 80 | UnHook(HookCtx->PresentExFun); 81 | GetDX9Screenshot(device); 82 | return device->PresentEx(srcRect, dstRect, overrideWindow, dirtyRegion, flags); 83 | } 84 | 85 | bool MakeDX9Screen(const TScreenCallback& callback, 86 | uint64_t presentOffset, 87 | uint64_t presentExOffset) 88 | { 89 | HMODULE dx9module = GetSystemModule("d3d9.dll"); 90 | if (!dx9module) { 91 | return false; 92 | } 93 | HookCtx->Callback = callback; 94 | HookCtx->PresentFun = (void*)((uintptr_t)dx9module + (uintptr_t)presentOffset); 95 | Hook(HookCtx->PresentFun, HookPresent); 96 | HookCtx->PresentExFun = (void*)((uintptr_t)dx9module + (uintptr_t)presentExOffset); 97 | Hook(HookCtx->PresentFun, HookPresentEx); 98 | 99 | return true; 100 | } 101 | -------------------------------------------------------------------------------- /injected_dll/dxgi_screen.cpp: -------------------------------------------------------------------------------- 1 | #include "dxscreen.h" 2 | #include "hook.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | void GetDX10Screenshot(IDXGISwapChain* swapChain, QByteArray& screen); 9 | void GetDX11Screenshot(IDXGISwapChain* swapChain, QByteArray& screen); 10 | 11 | struct THookCtxDXI { 12 | void* PresentFun = nullptr; 13 | TScreenCallback Callback; 14 | }; 15 | static THookCtxDXI* HookCtx = new THookCtxDXI(); 16 | 17 | static HRESULT STDMETHODCALLTYPE HookPresent(IDXGISwapChain* swapChain, 18 | UINT syncInterval, UINT flags) 19 | { 20 | UnHook(HookCtx->PresentFun); 21 | QByteArray screen; 22 | GetDX10Screenshot(swapChain, screen); 23 | if (screen.isEmpty()) { 24 | GetDX11Screenshot(swapChain, screen); 25 | } 26 | if (!screen.isEmpty()) { 27 | HookCtx->Callback(screen); 28 | } 29 | return swapChain->Present(syncInterval, flags); 30 | } 31 | 32 | bool MakeDXGIScreen(const TScreenCallback& callback, 33 | uint64_t dxgiOffset) 34 | { 35 | HMODULE dxgiModule = GetSystemModule("dxgi.dll"); 36 | if (!dxgiModule) { 37 | return false; 38 | } 39 | std::cerr << " === Making DXGI Screen\n"; 40 | HookCtx->Callback = callback; 41 | HookCtx->PresentFun = (void*)((uintptr_t)dxgiModule + (uintptr_t)dxgiOffset); 42 | Hook(HookCtx->PresentFun, HookPresent); 43 | std::cerr << " === HOOKED\n"; 44 | return true; 45 | } 46 | -------------------------------------------------------------------------------- /injected_dll/dxscreen.cpp: -------------------------------------------------------------------------------- 1 | #include "dxscreen.h" 2 | 3 | #include 4 | 5 | 6 | HMODULE GetSystemModule(const char* module) { 7 | static std::string systemPath; 8 | if (systemPath.empty()) { 9 | systemPath.resize(2048); 10 | uint32_t res = GetSystemDirectoryA(&systemPath[0], systemPath.size()); 11 | systemPath.resize(res); 12 | } 13 | 14 | std::string basePath = systemPath + "\\" + module; 15 | return GetModuleHandleA(basePath.c_str()); 16 | } 17 | 18 | QByteArray PackImageData(NQtScreen::EImgByteFormat fmt, 19 | char* intarray, 20 | unsigned rows, 21 | unsigned columns) 22 | { 23 | QByteArray data; 24 | if (fmt == NQtScreen::BF_B8G8R8A8 || fmt == NQtScreen::BF_R8G8B8A8) { 25 | data.resize(1 + 4 + 4 + rows * columns * 4); 26 | memcpy(data.data() + 1 + 4 + 4, intarray, rows * columns * 4); 27 | } else { 28 | data.resize(1 + 4 + 4 + rows * columns * 3); 29 | memcpy(data.data() + 1 + 4 + 4, intarray, rows * columns * 3); 30 | } 31 | data[0] = fmt; 32 | *(uint32_t*)(data.data() + 1) = (uint32_t)rows; 33 | *(uint32_t*)(data.data() + 1 + 4) = (uint32_t)columns; 34 | return data; 35 | } 36 | -------------------------------------------------------------------------------- /injected_dll/dxscreen.h: -------------------------------------------------------------------------------- 1 | #include "../libqtscreen/proto.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | using TScreenCallback = std::function; 9 | 10 | HMODULE GetSystemModule(const char* module); 11 | 12 | 13 | QByteArray PackImageData(NQtScreen::EImgByteFormat fmt, 14 | char* intarray, 15 | unsigned rows, 16 | unsigned columns); 17 | 18 | bool MakeDX8Screen(const TScreenCallback& callback, 19 | uint64_t presentOffset); 20 | 21 | bool MakeDX9Screen(const TScreenCallback& callback, 22 | uint64_t presentOffset, 23 | uint64_t presentExOffset); 24 | 25 | bool MakeDXGIScreen(const TScreenCallback& callback, 26 | uint64_t dxgiOffset); 27 | 28 | bool MakeOpenGLScreen(const TScreenCallback& callback); 29 | -------------------------------------------------------------------------------- /injected_dll/hook.cpp: -------------------------------------------------------------------------------- 1 | #include "hook.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | static std::map OldData; 11 | 12 | 13 | bool DoHook(void *addr,void *handler) { 14 | if (OldData.find((uint64_t)addr) != OldData.end()) { 15 | return false; 16 | } 17 | if (addr != nullptr && handler != nullptr) { 18 | DWORD old; 19 | if (VirtualProtect(addr, 32, PAGE_EXECUTE_READWRITE, &old) != FALSE) { 20 | BYTE* code=(BYTE*)addr; 21 | std::string oldData; 22 | #ifndef _WIN64 23 | oldData.resize(5); 24 | memcpy(&oldData[0], (BYTE*)addr, 5); 25 | *(BYTE*)&code[0] = 0xE9; 26 | *(int*)&code[1] = (BYTE*)handler - ((BYTE*)addr + 5); 27 | #else 28 | oldData.resize(12); 29 | memcpy(&oldData[0], (BYTE*)addr, 12); 30 | *(WORD*)&code[0] = 0xB848; 31 | *(void**)&code[2] = handler; 32 | *(WORD*)&code[10] = 0xE0FF; 33 | #endif 34 | OldData[(uint64_t)addr] = oldData; 35 | VirtualProtect(addr, 32, old, &old); 36 | return true; 37 | } 38 | } 39 | return false; 40 | } 41 | 42 | 43 | void DoUnHook(void *func) { 44 | uint8_t* origFunc = (uint8_t*)func; 45 | if (OldData.find((uint64_t)origFunc) == OldData.end()) { 46 | return; 47 | } 48 | std::string oldData = OldData[(uint64_t)origFunc]; 49 | #ifndef _WIN64 50 | DWORD prevProtect; 51 | VirtualProtect(origFunc, 5, PAGE_EXECUTE_READWRITE, &prevProtect); 52 | memcpy(origFunc, &oldData[0], 5); 53 | VirtualProtect(origFunc, 5, prevProtect, &prevProtect); 54 | #else 55 | DWORD prevProtect; 56 | VirtualProtect(origFunc, 12, PAGE_EXECUTE_READWRITE, &prevProtect); 57 | memcpy(origFunc, &oldData[0], 12); 58 | VirtualProtect(origFunc, 12, prevProtect, &prevProtect); 59 | #endif 60 | OldData.erase((uint64_t)origFunc); 61 | } 62 | -------------------------------------------------------------------------------- /injected_dll/hook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | bool DoHook(void *addr,void *handler); 4 | void DoUnHook(void* func); 5 | 6 | #define Hook(func, handler) (DoHook((void*)(func), (void*)(handler))) 7 | #define UnHook(func) (DoUnHook((void*)(func))) 8 | -------------------------------------------------------------------------------- /injected_dll/injected_app.cpp: -------------------------------------------------------------------------------- 1 | #include "injected_app.h" 2 | #include "dxscreen.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | TInjectedApp::TInjectedApp() { 10 | connect(&Sock, &QLocalSocket::readyRead, [this] { 11 | Buffer += Sock.readAll(); 12 | while (ProcessBuffer()) { 13 | } 14 | }); 15 | 16 | connect(&Sock, &QLocalSocket::connected, [this] { 17 | std::stringstream out; 18 | Info.Save(out); 19 | Send(NQtScreen::CMD_Info, QByteArray::fromStdString(out.str())); 20 | }); 21 | 22 | // Required to pass screenshot from directX thread to our thread. 23 | connect(this, &TInjectedApp::onScreenshotReadySignal, 24 | this, &TInjectedApp::onScreenshotReady, 25 | Qt::BlockingQueuedConnection); 26 | 27 | Info.PID = QCoreApplication::instance()->applicationPid(); 28 | Info.Name = QCoreApplication::instance()->applicationFilePath().toStdString(); 29 | Info.Is64Bit = sizeof(void*) == 8; 30 | 31 | startTimer(500); 32 | } 33 | 34 | void TInjectedApp::onScreenshotReady(QByteArray img) { 35 | Send(NQtScreen::CMD_ScreenShot, img); 36 | } 37 | 38 | bool TInjectedApp::ProcessBuffer() { 39 | if (Buffer.size() < 4) { 40 | return false; 41 | } 42 | uint32_t packetSize = *(uint32_t*)Buffer.data(); 43 | // todo: check packet size 44 | if ((uint32_t)Buffer.size() < packetSize + 6u) { 45 | return false; 46 | } 47 | uint16_t packetType = *(uint16_t*)(Buffer.data() + 4); 48 | QByteArray packetData = QByteArray(Buffer.data() + 6, packetSize); 49 | Buffer.remove(0, packetSize + 6); 50 | OnPacketReceived((NQtScreen::ECommand)packetType, packetData); 51 | return true; 52 | } 53 | 54 | void TInjectedApp::OnPacketReceived(NQtScreen::ECommand cmd, const QByteArray& data) { 55 | switch (cmd) { 56 | case NQtScreen::CMD_Ping: { 57 | Send(NQtScreen::CMD_Ping, "pong"); 58 | } break; 59 | case NQtScreen::CMD_Info: { 60 | NQtScreen::imemstream in(data.data(), data.size()); 61 | HelpInfo.Load(in); 62 | } break; 63 | case NQtScreen::CMD_ScreenShot: { 64 | if (!MakeScreenshot()) { 65 | Send(NQtScreen::CMD_Error, "error"); 66 | } 67 | } break; 68 | default: 69 | break; 70 | } 71 | } 72 | 73 | void TInjectedApp::Send(NQtScreen::ECommand cmd, const QByteArray& data) { 74 | QByteArray packet; 75 | packet.resize(6); 76 | packet += data; 77 | *(uint32_t*)(packet.data()) = (uint32_t)(data.size()); 78 | *(uint16_t*)(packet.data() + 4) = (uint16_t)cmd; 79 | Sock.write(packet); 80 | } 81 | 82 | bool TInjectedApp::MakeScreenshot() { 83 | bool success = false; 84 | success |= MakeDX8Screen([this](const QByteArray& img) { 85 | emit onScreenshotReadySignal(img); 86 | }, HelpInfo.DX8PresentOffset); 87 | success |= MakeDX9Screen([this](const QByteArray& img) { 88 | emit onScreenshotReadySignal(img); 89 | }, HelpInfo.DX9PresentOffset, HelpInfo.DX9PresentExOffset); 90 | success |= MakeDXGIScreen([this](const QByteArray& img) { 91 | emit onScreenshotReadySignal(img); 92 | }, HelpInfo.DXGIPresentOffset); 93 | success |= MakeOpenGLScreen([this](const QByteArray& img) { 94 | emit onScreenshotReadySignal(img); 95 | }); 96 | return success; 97 | } 98 | 99 | void TInjectedApp::timerEvent(QTimerEvent *) { 100 | if (Sock.state() == QLocalSocket::UnconnectedState) { 101 | Sock.connectToServer("libqtscreen"); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /injected_dll/injected_app.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../libqtscreen/proto.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class TInjectedApp : public QObject { 11 | Q_OBJECT 12 | public: 13 | TInjectedApp(); 14 | signals: 15 | void onScreenshotReadySignal(QByteArray img); 16 | private slots: 17 | void onScreenshotReady(QByteArray img); 18 | private: 19 | bool ProcessBuffer(); 20 | void OnPacketReceived(NQtScreen::ECommand cmd, const QByteArray& data); 21 | void Send(NQtScreen::ECommand cmd, const QByteArray& data); 22 | HMODULE GetSystemModule(const char* module); 23 | bool MakeScreenshot(); 24 | void timerEvent(QTimerEvent*); 25 | private: 26 | NQtScreen::TInjectedAppInfo Info; 27 | NQtScreen::TInjectorHelpInfo HelpInfo; 28 | QLocalSocket Sock; 29 | QByteArray Buffer; 30 | }; 31 | -------------------------------------------------------------------------------- /injected_dll/injected_dll.pro: -------------------------------------------------------------------------------- 1 | TARGET = injected_dll 2 | TEMPLATE = lib 3 | 4 | QMAKE_CXXFLAGS += -std=c++11 5 | 6 | QT += core network 7 | QT -= gui widgets 8 | 9 | INCLUDEPATH += ../directx_api/ 10 | 11 | HEADERS += \ 12 | injected_app.h \ 13 | dxscreen.h \ 14 | hook.h 15 | 16 | SOURCES += main.cpp \ 17 | injected_app.cpp \ 18 | dx8screen.cpp \ 19 | dx9screen.cpp \ 20 | dx10screen.cpp \ 21 | dx11screen.cpp \ 22 | dxgi_screen.cpp \ 23 | dxscreen.cpp \ 24 | hook.cpp \ 25 | opengl.cpp 26 | -------------------------------------------------------------------------------- /injected_dll/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #include "injected_app.h" 7 | 8 | DWORD WINAPI MainLoop(LPVOID) { 9 | // Check if this is a Qt application 10 | if (QCoreApplication::instance()) { 11 | QEventLoop loop; 12 | TInjectedApp myApp; 13 | return loop.exec(); 14 | } else { 15 | int argc = 0; 16 | char** argv = nullptr; 17 | QCoreApplication loop(argc, argv); 18 | TInjectedApp myApp; 19 | return loop.exec(); 20 | } 21 | } 22 | 23 | extern "C" 24 | { 25 | 26 | __declspec (dllexport) BOOL __stdcall DllMain(HMODULE, DWORD ul_reason_for_call, LPVOID) 27 | { 28 | switch (ul_reason_for_call) 29 | { 30 | case DLL_PROCESS_ATTACH: { 31 | DWORD thrID; 32 | CreateThread(0, 0, MainLoop, 0, 0, &thrID); 33 | } break; 34 | case DLL_THREAD_ATTACH: 35 | break; 36 | case DLL_THREAD_DETACH: 37 | break; 38 | case DLL_PROCESS_DETACH: 39 | break; 40 | } 41 | return TRUE; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /injected_dll/opengl.cpp: -------------------------------------------------------------------------------- 1 | #include "hook.h" 2 | #include "dxscreen.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | typedef void (APIENTRY *glBegin_t)(GLenum); 11 | typedef void (APIENTRY *glEnd_t)(void); 12 | typedef void (APIENTRY *glGetIntegerv_t)(GLenum pname, GLint *params); 13 | typedef void (APIENTRY *glPixelStorei_t)(GLenum pname, GLint param); 14 | typedef void (APIENTRY *glReadBuffer_t)(GLenum mode); 15 | typedef void (APIENTRY *glReadPixels_t)(GLint x, GLint y, GLsizei width, 16 | GLsizei height, GLenum format, 17 | GLenum type, GLvoid *pixels); 18 | 19 | struct THookCtxGL { 20 | glBegin_t glBeginFunc = nullptr; 21 | glEnd_t glEndFunc = nullptr; 22 | glGetIntegerv_t glGetIntegerv = nullptr; 23 | glPixelStorei_t glPixelStorei = nullptr; 24 | glReadBuffer_t glReadBuffer = nullptr; 25 | glReadPixels_t glReadPixels = nullptr; 26 | TScreenCallback Callback; 27 | }; 28 | static THookCtxGL* HookCtx = new THookCtxGL(); 29 | 30 | 31 | void Screenshot(int x, int y, int w, int h) { 32 | HookCtx->glPixelStorei(GL_PACK_ALIGNMENT, 1); 33 | HookCtx->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 34 | HookCtx->glReadBuffer(GL_FRONT); 35 | std::string buffer; 36 | buffer.resize(w * h * (3 * sizeof(uint8_t))); 37 | HookCtx->glReadPixels(x, y, w, h, GL_RGB, GL_UNSIGNED_BYTE, &buffer[0]); 38 | QByteArray screen = PackImageData(NQtScreen::BF_R8G8B8, &buffer[0], h, w); 39 | HookCtx->Callback(screen); 40 | } 41 | 42 | static void MakeScreen() { 43 | GLint m_viewport[4]; 44 | HookCtx->glGetIntegerv( GL_VIEWPORT, m_viewport ); 45 | int width = m_viewport[2]; 46 | int height = m_viewport[3]; 47 | Screenshot(0, 0, width, height); 48 | } 49 | 50 | DECLSPEC_NOINLINE void APIENTRY Hooked_glBegin(GLenum mode) { 51 | UnHook(HookCtx->glBeginFunc); 52 | MakeScreen(); 53 | HookCtx->glBeginFunc(mode); 54 | } 55 | 56 | bool MakeOpenGLScreen(const TScreenCallback& callback) { 57 | HMODULE hOpenGL = GetSystemModule("opengl32.dll"); 58 | if (!hOpenGL) { 59 | return false; 60 | } 61 | HookCtx->Callback = callback; 62 | HookCtx->glBeginFunc = (glBegin_t)GetProcAddress(hOpenGL, "glBegin"); 63 | HookCtx->glEndFunc = (glEnd_t)GetProcAddress(hOpenGL, "glEnd"); 64 | HookCtx->glGetIntegerv = (glGetIntegerv_t)GetProcAddress(hOpenGL, "glGetIntegerv"); 65 | HookCtx->glPixelStorei = (glPixelStorei_t)GetProcAddress(hOpenGL, "glPixelStorei"); 66 | HookCtx->glReadBuffer = (glReadBuffer_t)GetProcAddress(hOpenGL, "glReadBuffer"); 67 | HookCtx->glReadPixels = (glReadPixels_t)GetProcAddress(hOpenGL, "glReadPixels"); 68 | 69 | Hook(HookCtx->glBeginFunc, &Hooked_glBegin); 70 | return true; 71 | } 72 | -------------------------------------------------------------------------------- /libqtscreen/client.cpp: -------------------------------------------------------------------------------- 1 | #include "client.h" 2 | #include "screenshot_maker.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace NQtScreen { 10 | 11 | QImage RawDataToQImage(EImgByteFormat fmt, 12 | const char* intarray, 13 | unsigned rows, 14 | unsigned columns) 15 | { 16 | QImage resImg(columns, rows, QImage::Format_RGB32); 17 | if (fmt == BF_B8G8R8A8 || fmt == BF_R8G8B8A8) { 18 | for (unsigned row = rows; row; row--) { 19 | for (unsigned col = 0; col < columns; col++) { 20 | char red, green, blue; 21 | int idx = (int(row) - 1) * columns * 4 + col * 4; 22 | if (fmt == BF_R8G8B8A8) { 23 | red = intarray[idx]; 24 | green = intarray[idx + 1]; 25 | blue = intarray[idx + 2]; 26 | } else { 27 | blue = intarray[idx]; 28 | green = intarray[idx + 1]; 29 | red = intarray[idx + 2]; 30 | } 31 | resImg.setPixel(col, row - 1, qRgb(red, green, blue)); 32 | } 33 | } 34 | } else { 35 | for (size_t j = 0; j < rows; j++) { 36 | for (size_t i = 0; i < columns; i++) { 37 | int offset = (i + j * columns) * (3 * sizeof(uint8_t)); 38 | 39 | uint8_t r = intarray[offset + 0]; 40 | uint8_t g = intarray[offset + 1]; 41 | uint8_t b = intarray[offset + 2]; 42 | 43 | resImg.setPixel(i, j, qRgb(r, g, b)); 44 | } 45 | } 46 | } 47 | return resImg; 48 | } 49 | 50 | TClient::TClient(TScreenShotMaker* screener, QLocalSocket* sock) 51 | : Screener(screener) 52 | , Sock(sock) 53 | , Failed(true) 54 | { 55 | connect(sock, &QLocalSocket::readyRead, [this] { 56 | Buffer += Sock->readAll(); 57 | while (ProcessBuffer()) { 58 | } 59 | }); 60 | startTimer(1000); 61 | } 62 | 63 | TClient::~TClient() { 64 | } 65 | 66 | void TClient::MakeScreenshot() { 67 | Failed = false; 68 | Send(CMD_ScreenShot, "doit"); 69 | } 70 | 71 | QImage TClient::GetLastScreenshot() const { 72 | return LastScreenshot; 73 | } 74 | 75 | const TInjectedAppInfo& TClient::GetInfo() const { 76 | return Info; 77 | } 78 | 79 | bool TClient::IsActive() const { 80 | return Sock->state() == QLocalSocket::ConnectedState; 81 | } 82 | 83 | bool TClient::IsScreenFailed() const { 84 | return Failed; 85 | } 86 | 87 | void TClient::timerEvent(QTimerEvent *) { 88 | Send(CMD_Ping, "ping"); 89 | } 90 | 91 | bool TClient::ProcessBuffer() { 92 | if (Buffer.size() < 2) { 93 | return false; 94 | } 95 | uint32_t packetSize = *(uint32_t*)Buffer.data(); 96 | // todo: check packet size 97 | if ((uint32_t)Buffer.size() < packetSize + 6) { 98 | return false; 99 | } 100 | uint16_t packetType = *(uint16_t*)(Buffer.data() + 4); 101 | QByteArray packetData = QByteArray(Buffer.data() + 6, packetSize); 102 | Buffer.remove(0, packetSize + 6); 103 | OnPacketReceived((ECommand)packetType, packetData); 104 | return true; 105 | } 106 | 107 | void TClient::OnPacketReceived(ECommand cmd, const QByteArray& data) { 108 | switch (cmd) { 109 | case CMD_Ping: { 110 | } break; 111 | case CMD_Info: { 112 | imemstream in(data.data(), data.size()); 113 | Info.Load(in); 114 | std::stringstream out; 115 | if (Info.Is64Bit) { 116 | Screener->InjectorHelpInfo64.Save(out); 117 | } else { 118 | Screener->InjectorHelpInfo32.Save(out); 119 | } 120 | Send(CMD_Info, QByteArray::fromStdString(out.str())); 121 | } break; 122 | case CMD_ScreenShot: { 123 | EImgByteFormat fmt = (EImgByteFormat)data[0]; 124 | uint32_t rows = *(uint32_t*)(data.data() + 1); 125 | uint32_t columns = *(uint32_t*)(data.data() + 1 + 4); 126 | LastScreenshot = RawDataToQImage(fmt, data.data() + 1 + 4 + 4, rows, columns); 127 | emit OnScreenshotReady(); 128 | } break; 129 | case CMD_Error: { 130 | Failed = true; 131 | emit OnFailed(); 132 | } break; 133 | } 134 | } 135 | 136 | void TClient::Send(ECommand cmd, const QByteArray& data) { 137 | QByteArray packet; 138 | packet.resize(6); 139 | packet += data; 140 | *(uint32_t*)(packet.data()) = (uint32_t)(data.size()); 141 | *(uint16_t*)(packet.data() + 4) = (uint16_t)cmd; 142 | Sock->write(packet); 143 | } 144 | 145 | } // NQtScreen 146 | -------------------------------------------------------------------------------- /libqtscreen/client.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "proto.h" 9 | 10 | namespace NQtScreen { 11 | 12 | class TScreenShotMaker; 13 | class TClient: public QObject { 14 | Q_OBJECT 15 | public: 16 | TClient(TScreenShotMaker* screener, QLocalSocket* sock); 17 | virtual ~TClient(); 18 | void MakeScreenshot(); 19 | QImage GetLastScreenshot() const; 20 | const TInjectedAppInfo& GetInfo() const; 21 | bool IsActive() const; 22 | bool IsScreenFailed() const; 23 | signals: 24 | void OnScreenshotReady(); 25 | void OnFailed(); 26 | private: 27 | void timerEvent(QTimerEvent*); 28 | 29 | bool ProcessBuffer(); 30 | void OnPacketReceived(ECommand cmd, const QByteArray& data); 31 | void Send(ECommand cmd, const QByteArray& data); 32 | private: 33 | TScreenShotMaker* Screener; 34 | TInjectedAppInfo Info; 35 | QLocalSocket* Sock; 36 | QByteArray Buffer; 37 | QImage LastScreenshot; 38 | bool Failed; 39 | }; 40 | using TClientRef = std::shared_ptr; 41 | 42 | } // NQtScreen 43 | -------------------------------------------------------------------------------- /libqtscreen/libqtscreen.pri: -------------------------------------------------------------------------------- 1 | QT += core network 2 | 3 | HEADERS += \ 4 | $$PWD/proto.h \ 5 | $$PWD/saveload.h \ 6 | $$PWD/client.h \ 7 | $$PWD/screenshot_maker.h 8 | 9 | SOURCES += \ 10 | $$PWD/client.cpp \ 11 | $$PWD/screenshot_maker.cpp 12 | -------------------------------------------------------------------------------- /libqtscreen/proto.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "saveload.h" 4 | #include 5 | 6 | namespace NQtScreen { 7 | 8 | enum ELogLevel { 9 | LL_Info, 10 | LL_Warning, 11 | LL_Error, 12 | }; 13 | 14 | enum ECommand { 15 | CMD_Ping, 16 | CMD_Info, 17 | CMD_ScreenShot, 18 | CMD_Error, 19 | }; 20 | 21 | enum EImgByteFormat { 22 | BF_R8G8B8A8, 23 | BF_B8G8R8A8, 24 | BF_R8G8B8, 25 | }; 26 | 27 | struct TInjectedAppInfo { 28 | uint32_t PID = 0; 29 | std::string Name; 30 | bool Is64Bit = false; 31 | 32 | SAVELOAD(PID, Name, Is64Bit) 33 | }; 34 | 35 | struct TInjectorHelpInfo { 36 | uint64_t DX8PresentOffset = 0; 37 | uint64_t DX9PresentOffset = 0; 38 | uint64_t DX9PresentExOffset = 0; 39 | uint64_t DXGIPresentOffset = 0; 40 | 41 | SAVELOAD(DX8PresentOffset, DX9PresentOffset, 42 | DX9PresentExOffset, DXGIPresentOffset) 43 | }; 44 | 45 | } // NQtScreen 46 | -------------------------------------------------------------------------------- /libqtscreen/saveload.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace NQtScreen { 12 | 13 | template 14 | class TSerializer { 15 | public: 16 | static void Save(std::ostream& out, const T& object) { 17 | object.Save(out); 18 | } 19 | static void Load(std::istream& in, T& object) { 20 | object.Load(in); 21 | } 22 | }; 23 | 24 | template 25 | static inline void Save(std::ostream& out, const T& t); 26 | 27 | template 28 | static inline void Load(std::istream& in, T& t); 29 | 30 | 31 | template 32 | class TSerializer > { 33 | public: 34 | static void Save(std::ostream& out, const std::pair& object) { 35 | NQtScreen::Save(out, object.first); 36 | NQtScreen::Save(out, object.second); 37 | } 38 | static void Load(std::istream& in, std::pair& object) { 39 | NQtScreen::Load(in, object.first); 40 | NQtScreen::Load(in, object.second); 41 | } 42 | }; 43 | 44 | template 45 | class TVectorSerializer { 46 | public: 47 | static inline void Save(std::ostream& out, const TVec& object) { 48 | unsigned short size = object.size(); 49 | out.write((const char*)(&size), 2); 50 | for (const auto& obj: object) { 51 | NQtScreen::Save(out, obj); 52 | } 53 | } 54 | 55 | static inline void Load(std::istream& in, TVec& object) { 56 | unsigned short size; 57 | in.read((char*)(&size), 2); 58 | object.clear(); 59 | for (size_t i = 0; i < size; ++i) { 60 | TObj obj; 61 | NQtScreen::Load(in, obj); 62 | object.push_back(std::move(obj)); 63 | } 64 | } 65 | }; 66 | 67 | template class TSerializer >: public TVectorSerializer, T > {}; 68 | template class TSerializer >: public TVectorSerializer, T > {}; 69 | template <> class TSerializer: public TVectorSerializer {}; 70 | 71 | template 72 | class TPodSerializer { 73 | public: 74 | static inline void Save(std::ostream& out, const T& object) { 75 | out.write((const char*)(&object), sizeof(T)); 76 | } 77 | static inline void Load(std::istream& in, T& object) { 78 | in.read((char*)(&object), sizeof(T)); 79 | } 80 | }; 81 | 82 | template <> class TSerializer: public TPodSerializer {}; 83 | template <> class TSerializer: public TPodSerializer {}; 84 | template <> class TSerializer: public TPodSerializer {}; 85 | template <> class TSerializer: public TPodSerializer {}; 86 | template <> class TSerializer: public TPodSerializer {}; 87 | template <> class TSerializer: public TPodSerializer {}; 88 | template <> class TSerializer: public TPodSerializer {}; 89 | template <> class TSerializer: public TPodSerializer {}; 90 | template <> class TSerializer: public TPodSerializer {}; 91 | template <> class TSerializer: public TPodSerializer {}; 92 | 93 | template <> class TSerializer: public TPodSerializer {}; 94 | template <> class TSerializer: public TPodSerializer {}; 95 | 96 | template <> class TSerializer: public TPodSerializer {}; 97 | template <> class TSerializer: public TPodSerializer {}; 98 | 99 | template 100 | static inline void Save(std::ostream& out, const T& t) { 101 | TSerializer::Save(out, t); 102 | } 103 | 104 | template 105 | static inline void Load(std::istream& in, T& t) { 106 | TSerializer::Load(in, t); 107 | } 108 | 109 | template 110 | static inline void SaveMany(std::ostream& out, const T1& t1) { 111 | NQtScreen::Save(out, t1); 112 | } 113 | template 114 | static inline void LoadMany(std::istream& in, T1& t1) { 115 | NQtScreen::Load(in, t1); 116 | } 117 | 118 | template 119 | static inline void SaveMany(std::ostream& out, const T1& t1, const T2& t2) { 120 | NQtScreen::Save(out, t1); 121 | NQtScreen::Save(out, t2); 122 | } 123 | template 124 | static inline void LoadMany(std::istream& in, T1& t1, T2& t2) { 125 | NQtScreen::Load(in, t1); 126 | NQtScreen::Load(in, t2); 127 | } 128 | 129 | template 130 | static inline void SaveMany(std::ostream& out, const T1& t1, const T2& t2, const T3& t3) { 131 | NQtScreen::Save(out, t1); 132 | NQtScreen::Save(out, t2); 133 | NQtScreen::Save(out, t3); 134 | } 135 | template 136 | static inline void LoadMany(std::istream& in, T1& t1, T2& t2, T3& t3) { 137 | NQtScreen::Load(in, t1); 138 | NQtScreen::Load(in, t2); 139 | NQtScreen::Load(in, t3); 140 | } 141 | 142 | template 143 | static inline void SaveMany(std::ostream& out, const T1& t1, const T2& t2, const T3& t3, const T4& t4) { 144 | NQtScreen::Save(out, t1); 145 | NQtScreen::Save(out, t2); 146 | NQtScreen::Save(out, t3); 147 | NQtScreen::Save(out, t4); 148 | } 149 | template 150 | static inline void LoadMany(std::istream& in, T1& t1, T2& t2, T3& t3, T4& t4) { 151 | NQtScreen::Load(in, t1); 152 | NQtScreen::Load(in, t2); 153 | NQtScreen::Load(in, t3); 154 | NQtScreen::Load(in, t4); 155 | } 156 | 157 | template 158 | static inline void SaveMany(std::ostream& out, const T1& t1, const T2& t2, 159 | const T3& t3, const T4& t4, const T5& t5) 160 | { 161 | NQtScreen::Save(out, t1); 162 | NQtScreen::Save(out, t2); 163 | NQtScreen::Save(out, t3); 164 | NQtScreen::Save(out, t4); 165 | NQtScreen::Save(out, t5); 166 | } 167 | template 168 | static inline void LoadMany(std::istream& in, T1& t1, T2& t2, T3& t3, 169 | T4& t4, T5& t5) 170 | { 171 | NQtScreen::Load(in, t1); 172 | NQtScreen::Load(in, t2); 173 | NQtScreen::Load(in, t3); 174 | NQtScreen::Load(in, t4); 175 | NQtScreen::Load(in, t5); 176 | } 177 | 178 | template 179 | static inline void SaveMany(std::ostream& out, const T1& t1, const T2& t2, 180 | const T3& t3, const T4& t4, const T5& t5, const T6& t6) 181 | { 182 | NQtScreen::Save(out, t1); 183 | NQtScreen::Save(out, t2); 184 | NQtScreen::Save(out, t3); 185 | NQtScreen::Save(out, t4); 186 | NQtScreen::Save(out, t5); 187 | NQtScreen::Save(out, t6); 188 | } 189 | template 190 | static inline void LoadMany(std::istream& in, T1& t1, T2& t2, T3& t3, 191 | T4& t4, T5& t5, T6& t6) 192 | { 193 | NQtScreen::Load(in, t1); 194 | NQtScreen::Load(in, t2); 195 | NQtScreen::Load(in, t3); 196 | NQtScreen::Load(in, t4); 197 | NQtScreen::Load(in, t5); 198 | NQtScreen::Load(in, t6); 199 | } 200 | 201 | template 202 | static inline void SaveMany(std::ostream& out, const T1& t1, const T2& t2, 203 | const T3& t3, const T4& t4, const T5& t5, const T6& t6, 204 | const T7& t7) 205 | { 206 | NQtScreen::Save(out, t1); 207 | NQtScreen::Save(out, t2); 208 | NQtScreen::Save(out, t3); 209 | NQtScreen::Save(out, t4); 210 | NQtScreen::Save(out, t5); 211 | NQtScreen::Save(out, t6); 212 | NQtScreen::Save(out, t7); 213 | } 214 | template 215 | static inline void LoadMany(std::istream& in, T1& t1, T2& t2, T3& t3, 216 | T4& t4, T5& t5, T6& t6, T7& t7) 217 | { 218 | NQtScreen::Load(in, t1); 219 | NQtScreen::Load(in, t2); 220 | NQtScreen::Load(in, t3); 221 | NQtScreen::Load(in, t4); 222 | NQtScreen::Load(in, t5); 223 | NQtScreen::Load(in, t6); 224 | NQtScreen::Load(in, t7); 225 | } 226 | 227 | template 228 | static inline void SaveMany(std::ostream& out, const T1& t1, const T2& t2, 229 | const T3& t3, const T4& t4, const T5& t5, const T6& t6, 230 | const T7& t7, const T8& t8) 231 | { 232 | NQtScreen::Save(out, t1); 233 | NQtScreen::Save(out, t2); 234 | NQtScreen::Save(out, t3); 235 | NQtScreen::Save(out, t4); 236 | NQtScreen::Save(out, t5); 237 | NQtScreen::Save(out, t6); 238 | NQtScreen::Save(out, t7); 239 | NQtScreen::Save(out, t8); 240 | } 241 | template 242 | static inline void LoadMany(std::istream& in, T1& t1, T2& t2, T3& t3, 243 | T4& t4, T5& t5, T6& t6, T7& t7, T8& t8) 244 | { 245 | NQtScreen::Load(in, t1); 246 | NQtScreen::Load(in, t2); 247 | NQtScreen::Load(in, t3); 248 | NQtScreen::Load(in, t4); 249 | NQtScreen::Load(in, t5); 250 | NQtScreen::Load(in, t6); 251 | NQtScreen::Load(in, t7); 252 | NQtScreen::Load(in, t8); 253 | } 254 | 255 | template 256 | static inline void SaveMany(std::ostream& out, const T1& t1, const T2& t2, 257 | const T3& t3, const T4& t4, const T5& t5, const T6& t6, 258 | const T7& t7, const T8& t8, const T9& t9) 259 | { 260 | NQtScreen::Save(out, t1); 261 | NQtScreen::Save(out, t2); 262 | NQtScreen::Save(out, t3); 263 | NQtScreen::Save(out, t4); 264 | NQtScreen::Save(out, t5); 265 | NQtScreen::Save(out, t6); 266 | NQtScreen::Save(out, t7); 267 | NQtScreen::Save(out, t8); 268 | NQtScreen::Save(out, t9); 269 | } 270 | template 271 | static inline void LoadMany(std::istream& in, T1& t1, T2& t2, T3& t3, 272 | T4& t4, T5& t5, T6& t6, T7& t7, T8& t8, T9& t9) 273 | { 274 | NQtScreen::Load(in, t1); 275 | NQtScreen::Load(in, t2); 276 | NQtScreen::Load(in, t3); 277 | NQtScreen::Load(in, t4); 278 | NQtScreen::Load(in, t5); 279 | NQtScreen::Load(in, t6); 280 | NQtScreen::Load(in, t7); 281 | NQtScreen::Load(in, t8); 282 | NQtScreen::Load(in, t9); 283 | } 284 | 285 | #define SAVELOAD(...) \ 286 | inline virtual void Save(std::ostream& out) const { \ 287 | NQtScreen::SaveMany(out, __VA_ARGS__); \ 288 | } \ 289 | \ 290 | inline virtual void Load(std::istream& in) { \ 291 | NQtScreen::LoadMany(in, __VA_ARGS__); \ 292 | } 293 | 294 | 295 | struct membuf: std::streambuf { 296 | membuf(char const* base, size_t size) { 297 | char* p(const_cast(base)); 298 | this->setg(p, p, p + size); 299 | } 300 | }; 301 | struct imemstream: virtual membuf, std::istream { 302 | imemstream(char const* base, size_t size) 303 | : membuf(base, size) 304 | , std::istream(static_cast(this)) { 305 | } 306 | }; 307 | 308 | #define SAVELOAD_POD(TypeName) template <> class TSerializer: public TPodSerializer {}; 309 | 310 | } // NQtScreen 311 | -------------------------------------------------------------------------------- /libqtscreen/screenshot_maker.cpp: -------------------------------------------------------------------------------- 1 | #include "screenshot_maker.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #pragma comment(lib, "user32.lib") 12 | 13 | namespace NQtScreen { 14 | 15 | static bool IsOs64Bit() { 16 | #if defined(_WIN64) 17 | return true; 18 | #elif defined(_WIN32) 19 | BOOL res = false; 20 | IsWow64Process(GetCurrentProcess(), &res); 21 | return res; 22 | #else 23 | return false; 24 | #endif 25 | } 26 | 27 | static bool IsProcess64Bit(uint32_t pid) { 28 | HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid); 29 | BOOL res = false; 30 | IsWow64Process(processHandle, &res); 31 | return !res; 32 | } 33 | 34 | static QString GetFullPath(const QString& path) { 35 | QFileInfo checkFile(path); 36 | return checkFile.absoluteFilePath(); 37 | } 38 | 39 | static bool FileExists(const QString& path) { 40 | QFileInfo checkFile(path); 41 | return checkFile.exists() && checkFile.isFile(); 42 | } 43 | 44 | bool TScreenShotMaker::GetOffsets(TInjectorHelpInfo& offsets, const QString& helperExe) { 45 | QProcess helper32; 46 | QStringList args; 47 | args.push_back("offsets"); 48 | helper32.start(helperExe, args); 49 | if (!helper32.waitForStarted()) { 50 | WriteLog(LL_Error, "failed to execute helper " + helperExe); 51 | return false; 52 | } 53 | QByteArray data; 54 | while (helper32.waitForReadyRead()) { 55 | data.append(helper32.readAll()); 56 | } 57 | QList lines = data.split('\n'); 58 | if (lines.size() < 4) { 59 | WriteLog(LL_Error, "wrong output for helper " + helperExe); 60 | return false; 61 | } 62 | offsets.DX8PresentOffset = lines[0].trimmed().toInt(); 63 | offsets.DX9PresentOffset = lines[1].trimmed().toInt(); 64 | offsets.DX9PresentExOffset = lines[2].trimmed().toInt(); 65 | offsets.DXGIPresentOffset = lines[3].trimmed().toInt(); 66 | WriteLog(LL_Info, "offsets for " + helperExe); 67 | WriteLog(LL_Info, QString("DX8PresentOffset: %1").arg(offsets.DX8PresentOffset)); 68 | WriteLog(LL_Info, QString("DX9PresentOffset: %1").arg(offsets.DX9PresentOffset)); 69 | WriteLog(LL_Info, QString("DX9PresentExOffset: %1").arg(offsets.DX9PresentExOffset)); 70 | WriteLog(LL_Info, QString("DXGIPresentOffset: %1").arg(offsets.DXGIPresentOffset)); 71 | return true; 72 | } 73 | 74 | static bool InjectDll(uint32_t processId, const QString& helperExe, const QString& dll) { 75 | QProcess helper32; 76 | QStringList args; 77 | args.push_back("inject"); 78 | args.push_back(QString::number(processId)); 79 | args.push_back(dll); 80 | helper32.start(helperExe, args); 81 | helper32.waitForStarted(); 82 | QByteArray data; 83 | while (helper32.waitForReadyRead()) { 84 | data.append(helper32.readAll()); 85 | } 86 | return helper32.exitCode() == 0; 87 | } 88 | 89 | TScreenShotMaker::TScreenShotMaker(const TScreenShotMakerConfig& config) 90 | : Config(config) 91 | , MakingScreen(false) 92 | , FullScreenProcessID(0) 93 | , ProcessDetectedCounter(0) 94 | , IsOs64(IsOs64Bit()) 95 | { 96 | Initialized = false; 97 | WriteLog(LL_Info, "Starting LibQtScreen"); 98 | if (!FileExists(config.DLL32Path) || 99 | !FileExists(config.DLL64Path)) 100 | { 101 | WriteLog(LL_Error, "libqtscreen32.dll or libqtscreen64.dll not found"); 102 | return; 103 | } 104 | 105 | if (!FileExists(config.Helper32Path) || 106 | !FileExists(config.Helper64Path)) 107 | { 108 | WriteLog(LL_Error, "helper32.exe or helper64.exe not found"); 109 | return; 110 | } 111 | 112 | if (!GetOffsets(InjectorHelpInfo32, config.Helper32Path)) { 113 | return; 114 | } 115 | 116 | if (!GetOffsets(InjectorHelpInfo64, config.Helper64Path)) { 117 | return; 118 | } 119 | 120 | connect(&Server, &QLocalServer::newConnection, [this] { 121 | WriteLog(LL_Info, "new connection"); 122 | Connections.emplace_back(new TClient(this, Server.nextPendingConnection())); 123 | TClient* client = Connections.back().get(); 124 | connect(client, &TClient::OnScreenshotReady, [this, client] { 125 | if (!MakingScreen) { 126 | WriteLog(LL_Warning, "screenshot received after timeout"); 127 | return; 128 | } 129 | LastScreenshot = client->GetLastScreenshot(); 130 | MakingScreen = false; 131 | TimeoutTimer.stop(); 132 | WriteLog(LL_Info, "screenshot successful"); 133 | emit OnScreenshotReady(); 134 | }); 135 | connect(client, &TClient::OnFailed, [this] { 136 | CheckFailedScreens(); 137 | }); 138 | }); 139 | 140 | connect(&TimeoutTimer, &QTimer::timeout, [this] { 141 | TimeoutTimer.stop(); 142 | MakingScreen = false; 143 | WriteLog(LL_Warning, "failed to make screenshot: time out"); 144 | emit OnFailed(); 145 | }); 146 | 147 | Server.setSocketOptions(QLocalServer::WorldAccessOption); 148 | if (!Server.listen("libqtscreen")) { 149 | WriteLog(LL_Error, "failed to listen named pipe libqtscreen - may be there is another libqtscreen server"); 150 | return; 151 | } 152 | Initialized = true; 153 | WriteLog(LL_Info, "Successfuly initialized!"); 154 | startTimer(500); 155 | } 156 | 157 | bool TScreenShotMaker::IsInitialized() const { 158 | return Initialized; 159 | } 160 | 161 | void TScreenShotMaker::MakeScreenshot(uint64_t pid) { 162 | if (!Initialized) { 163 | WriteLog(LL_Warning, "failed to make screenshot: not initialized"); 164 | emit OnFailed(); 165 | return; 166 | } 167 | 168 | if (Connections.size() == 0) { 169 | WriteLog(LL_Warning, "failed to make screenshot: missing any connected dll"); 170 | emit OnFailed(); 171 | return; 172 | } 173 | 174 | if (!FullScreenProcessID && !pid) { 175 | WriteLog(LL_Warning, "failed to make screenshot: no fullscreen app detected"); 176 | emit OnFailed(); 177 | return; 178 | } 179 | for (auto&& cli: Connections) { 180 | if (cli->GetInfo().PID == FullScreenProcessID || 181 | cli->GetInfo().PID == pid) 182 | { 183 | MakingScreen = true; 184 | TimeoutTimer.start(1000); 185 | WriteLog(LL_Info, QString("making screenshot of process %1").arg(cli->GetInfo().PID)); 186 | cli->MakeScreenshot(); 187 | return; 188 | } 189 | } 190 | WriteLog(LL_Warning, "failed to make screenshot: missing connection to required process"); 191 | emit OnFailed(); 192 | } 193 | 194 | QImage TScreenShotMaker::GetLastScreenshot() { 195 | return LastScreenshot; 196 | } 197 | 198 | bool TScreenShotMaker::InjectToPID(uint64_t PID) { 199 | if (InjectedPIDs.find(PID) != InjectedPIDs.end()) { 200 | WriteLog(LL_Info, QString("already injected to %1").arg(PID)); 201 | return true; 202 | } 203 | 204 | bool injected = false; 205 | if (IsOs64 && IsProcess64Bit(PID)) { 206 | injected = InjectDll(PID, Config.Helper64Path, GetFullPath(Config.DLL64Path)); 207 | } else { 208 | injected = InjectDll(PID, Config.Helper32Path, GetFullPath(Config.DLL32Path)); 209 | } 210 | if (injected) { 211 | WriteLog(LL_Info, QString("successfully injected to %1").arg(PID)); 212 | } else { 213 | WriteLog(LL_Warning, QString("failed to inject to %1").arg(PID)); 214 | } 215 | return injected; 216 | } 217 | 218 | void TScreenShotMaker::timerEvent(QTimerEvent*) { 219 | RemoveInactiveConnections(); 220 | if (Config.AutoInjectToFullscreen) { 221 | InjectAll(); 222 | } 223 | } 224 | 225 | void TScreenShotMaker::InjectAll() { 226 | HWND window = GetForegroundWindow(); 227 | if (!window) { 228 | FullScreenProcessID = 0; 229 | return; 230 | } 231 | RECT rect; 232 | if (!GetWindowRect(window, &rect)) { 233 | FullScreenProcessID = 0; 234 | return; 235 | } 236 | 237 | DWORD styles = GetWindowLongPtr(window, GWL_STYLE); 238 | if ((styles & WS_MAXIMIZE) && (styles & WS_BORDER)) { 239 | FullScreenProcessID = 0; 240 | return; 241 | } 242 | 243 | MONITORINFO lpmi = {0}; 244 | HMONITOR monitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST); 245 | if (!monitor) { 246 | FullScreenProcessID = 0; 247 | return; 248 | } 249 | lpmi.cbSize = sizeof(lpmi); 250 | if (!GetMonitorInfoA(monitor, &lpmi)) { 251 | FullScreenProcessID = 0; 252 | return; 253 | } 254 | 255 | if (rect.left != lpmi.rcMonitor.left || 256 | rect.right != lpmi.rcMonitor.right || 257 | rect.bottom != lpmi.rcMonitor.bottom || 258 | rect.top != lpmi.rcMonitor.top) 259 | { 260 | FullScreenProcessID = 0; 261 | return; 262 | } 263 | 264 | DWORD pid = 0; 265 | GetWindowThreadProcessId(window, &pid); 266 | if (!pid) { 267 | FullScreenProcessID = 0; 268 | return; 269 | } 270 | 271 | if (pid != FullScreenProcessID) { 272 | ProcessDetectedCounter = 0; 273 | } 274 | 275 | FullScreenProcessID = pid; 276 | 277 | ProcessDetectedCounter += 1; 278 | 279 | // Give some time to process to initialize 280 | // and to connect to ourselv if we already injected 281 | if (ProcessDetectedCounter > 3) { 282 | InjectToPID(pid); 283 | // Next inject retry in 30 seconds 284 | ProcessDetectedCounter = -60; 285 | } 286 | } 287 | 288 | void TScreenShotMaker::RemoveInactiveConnections() { 289 | std::vector newConnections; 290 | std::set prevPids; 291 | InjectedPIDs.swap(prevPids); 292 | for (auto&& c: Connections) { 293 | if (c->IsActive()) { 294 | newConnections.push_back(c); 295 | if (c->GetInfo().PID) { 296 | if (prevPids.find(c->GetInfo().PID) == prevPids.end()) { 297 | WriteLog(LL_Info, QString("injected dll with pid %1 sent initial info").arg(c->GetInfo().PID)); 298 | } 299 | InjectedPIDs.insert(uint64_t(c->GetInfo().PID)); 300 | } 301 | } else { 302 | WriteLog(LL_Info, QString("injected dll with pid %1 disconnected").arg(c->GetInfo().PID)); 303 | } 304 | } 305 | Connections.swap(newConnections); 306 | } 307 | 308 | void TScreenShotMaker::CheckFailedScreens() { 309 | if (!MakingScreen) { 310 | return; 311 | } 312 | bool anyInProgress = false; 313 | for (auto&& c: Connections) { 314 | if (!c->IsScreenFailed()) { 315 | anyInProgress = true; 316 | } 317 | } 318 | if (!anyInProgress) { 319 | MakingScreen = false; 320 | TimeoutTimer.stop(); 321 | WriteLog(LL_Warning, "failed to make screenshot: injected dll was unable to make screenshot"); 322 | emit OnFailed(); 323 | } 324 | } 325 | 326 | void TScreenShotMaker::WriteLog(ELogLevel logLevel, const QString& message) { 327 | if (!Config.LogOutput || logLevel < Config.LogLevel) { 328 | return; 329 | } 330 | QString level; 331 | switch (logLevel) { 332 | case LL_Info: 333 | level = "INFO"; 334 | break; 335 | case LL_Warning: 336 | level = "WARNING"; 337 | break; 338 | case LL_Error: 339 | level = "ERROR"; 340 | break; 341 | default: 342 | break; 343 | } 344 | QString msg = "[" + QDate::currentDate().toString("dd.MM.yy") + " " + QTime::currentTime().toString() + " " + level + "] " + message; 345 | (*Config.LogOutput) << msg << "\n"; 346 | Config.LogOutput->flush(); 347 | } 348 | 349 | } // NQtScreen 350 | -------------------------------------------------------------------------------- /libqtscreen/screenshot_maker.h: -------------------------------------------------------------------------------- 1 | #include "client.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace NQtScreen { 13 | 14 | struct TScreenShotMakerConfig { 15 | // Path to x86 dll 16 | QString DLL32Path = "libqtscreen32.dll"; 17 | 18 | // Path to x64 dll 19 | QString DLL64Path = "libqtscreen64.dll"; 20 | 21 | // Path to x86 helper binary 22 | QString Helper32Path = "helper32.exe"; 23 | 24 | // Path to x64 helper binary 25 | QString Helper64Path = "helper64.exe"; 26 | 27 | // Time to wait for screenshot, milliseconds. 28 | // OnFailed will be emmited after timeout expire. 29 | int Timeout = 300; 30 | 31 | // Disable if you don't want to inject automatically. 32 | // In this case you should inject yourself using InjectToPID. 33 | bool AutoInjectToFullscreen = true; 34 | 35 | // Enable logs. Pass stdout or file stream pointer. 36 | QTextStream* LogOutput = nullptr; 37 | 38 | // Select log level. 39 | ELogLevel LogLevel = LL_Info; 40 | }; 41 | 42 | class TScreenShotMaker: public QObject { 43 | Q_OBJECT 44 | friend class TClient; 45 | public: 46 | TScreenShotMaker(const TScreenShotMakerConfig& config = TScreenShotMakerConfig()); 47 | 48 | // Returns False in case of initialization issues. 49 | // Enable logs to see detailed information. 50 | bool IsInitialized() const; 51 | 52 | // Async request to make screenshot. Singals OnScreenshotReady 53 | // or OnFailed emitted wher ready (or fail). 54 | // pid (optional) - custom pid (for non-fullscreen apps), use InjectToPID before. 55 | void MakeScreenshot(uint64_t pid = 0); 56 | 57 | // Returns last successful screenshot. Use it to extract 58 | // screenshot when OnScreenshotReady emitted. 59 | QImage GetLastScreenshot(); 60 | 61 | // Use it if you want to capture some non-fullscreen applications 62 | bool InjectToPID(uint64_t PID); 63 | signals: 64 | void OnScreenshotReady(); 65 | void OnFailed(); 66 | private: 67 | void timerEvent(QTimerEvent*); 68 | void InjectAll(); 69 | void RemoveInactiveConnections(); 70 | void CheckFailedScreens(); 71 | bool GetOffsets(TInjectorHelpInfo& offsets, const QString& helperExe); 72 | void WriteLog(ELogLevel logLevel, const QString& message); 73 | private: 74 | TScreenShotMakerConfig Config; 75 | QImage LastScreenshot; 76 | QLocalServer Server; 77 | std::vector Connections; 78 | std::set InjectedPIDs; 79 | TInjectorHelpInfo InjectorHelpInfo32; 80 | TInjectorHelpInfo InjectorHelpInfo64; 81 | QTimer TimeoutTimer; 82 | bool MakingScreen; 83 | uint32_t FullScreenProcessID; 84 | int32_t ProcessDetectedCounter; 85 | bool IsOs64; 86 | bool Initialized; 87 | }; 88 | 89 | } // NQtScreen 90 | -------------------------------------------------------------------------------- /qtscreen.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscreen 2 | TEMPLATE = subdirs 3 | 4 | CONFIG += ordered 5 | 6 | SUBDIRS += injected_dll helper screener 7 | -------------------------------------------------------------------------------- /screener/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | using TCallback = std::function; 11 | 12 | int main(int argc, char **argv) { 13 | TScreener screener(argc, argv); 14 | return screener.exec(); 15 | } 16 | -------------------------------------------------------------------------------- /screener/screener.cpp: -------------------------------------------------------------------------------- 1 | #include "screener.h" 2 | 3 | #include 4 | 5 | TScreener::TScreener(int &argc, char **argv) 6 | : QCoreApplication(argc, argv) 7 | , Out(stderr, QIODevice::WriteOnly) 8 | { 9 | NQtScreen::TScreenShotMakerConfig config; 10 | config.LogOutput = &Out; 11 | 12 | Screener.reset(new NQtScreen::TScreenShotMaker(config)); 13 | startTimer(1000); 14 | connect(Screener.get(), &NQtScreen::TScreenShotMaker::OnScreenshotReady, [this] { 15 | QImage screenShot = Screener->GetLastScreenshot(); 16 | qDebug() << "screenshot created" << screenShot.width(); 17 | }); 18 | connect(Screener.get(), &NQtScreen::TScreenShotMaker::OnFailed, [this] { 19 | qDebug() << "screenshot failed"; 20 | }); 21 | } 22 | 23 | TScreener::~TScreener() { 24 | } 25 | 26 | void TScreener::timerEvent(QTimerEvent *) { 27 | static int n = 10; 28 | n -= 1; 29 | if (n > 0) { 30 | qDebug() << "screenshot in" << n; 31 | } 32 | if (n == 0) { 33 | qDebug() << "making screenshot"; 34 | Screener->MakeScreenshot(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /screener/screener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class TScreener : public QCoreApplication { 8 | Q_OBJECT 9 | public: 10 | TScreener(int &argc, char **argv); 11 | virtual ~TScreener(); 12 | private: 13 | void timerEvent(QTimerEvent*); 14 | QTextStream Out; 15 | std::unique_ptr Screener; 16 | }; 17 | -------------------------------------------------------------------------------- /screener/screener.pro: -------------------------------------------------------------------------------- 1 | TARGET=screener 2 | TEMPLATE=app 3 | 4 | INCLUDEPATH += $$PWD/../ 5 | 6 | SOURCES += main.cpp \ 7 | screener.cpp 8 | 9 | HEADERS += \ 10 | screener.h 11 | 12 | QT += gui widgets core network 13 | 14 | QMAKE_CXXFLAGS += -std=c++11 15 | 16 | include(../libqtscreen/libqtscreen.pri) 17 | --------------------------------------------------------------------------------