Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

439 lines
17 KiB

  1. #include "pch.h"
  2. #include "SampleSW.h"
  3. #pragma hdrstop
  4. const D3DCAPS8 CMyDriver::c_D3DCaps=
  5. {
  6. // Indicates this is software rasterizer.
  7. /*D3DDEVTYPE_HAL|| D3DDEVTYPE_REF||*/ D3DDEVTYPE_SW,
  8. // Adapter ordinal (isn't used to report anything).
  9. 0,
  10. // Caps (See ddraw.h & d3d8caps.h for details of each CAP).
  11. /*DDCAPS_3D| DDCAPS_ALIGNBOUNDARYDEST| DDCAPS_ALIGNSIZEDEST|
  12. DDCAPS_ALIGNBOUNDARYSRC| DDCAPS_ALIGNSIZESRC| DDCAPS_ALIGNSTRIDE|
  13. DDCAPS_BLT| DDCAPS_BLTQUEUE| DDCAPS_BLTFOURCC| DDCAPS_BLTSTRETCH|
  14. DDCAPS_GDI| DDCAPS_OVERLAY| DDCAPS_OVERLAYCANTCLIP| DDCAPS_OVERLAYFOURCC|
  15. DDCAPS_OVERLAYSTRETCH| DDCAPS_PALETTE| DDCAPS_PALETTEVSYNC|
  16. DDCAPS_READSCANLINE| DDCAPS_VBI| DDCAPS_ZBLTS| DDCAPS_ZOVERLAYS|
  17. DDCAPS_COLORKEY| DDCAPS_ALPHA| DDCAPS_COLORKEYHWASSIST| DDCAPS_NOHARDWARE|
  18. DDCAPS_BLTCOLORFILL| DDCAPS_BANKSWITCHED| DDCAPS_BLTDEPTHFILL|
  19. DDCAPS_CANCLIP| DDCAPS_CANCLIPSTRETCHED| DDCAPS_CANBLTSYSMEM|
  20. D3DCAPS_READ_SCANLINE|*/ 0,
  21. // Caps2
  22. /*DDCAPS2_CERTIFIED| DDCAPS2_NO2DDURING3DSCENE| DDCAPS2_VIDEOPORT|
  23. DDCAPS2_AUTOFLIPOVERLAY| DDCAPS2_CANBOBINTERLEAVED|
  24. DDCAPS2_CANBOBNONINTERLEAVED| DDCAPS2_COLORCONTROLOVERLAY|
  25. DDCAPS2_COLORCONTROLPRIMARY|*/ DDCAPS2_CANDROPZ16BIT|
  26. /*DDCAPS2_NONLOCALVIDMEM| DDCAPS2_NONLOCALVIDMEMCAPS|
  27. DDCAPS2_NOPAGELOCKREQUIRED|*/ DDCAPS2_WIDESURFACES|
  28. /*DDCAPS2_CANFLIPODDEVEN| DDCAPS2_CANBOBHARDWARE| DDCAPS2_COPYFOURCC|
  29. DDCAPS2_PRIMARYGAMMA|*/ DDCAPS2_CANRENDERWINDOWED|
  30. /*DDCAPS2_CANCALIBRATEGAMMA| DDCAPS2_FLIPINTERVAL|
  31. DDCAPS2_FLIPNOVSYNC| DDCAPS2_CANMANAGETEXTURE|
  32. DDCAPS2_TEXMANINNONLOCALVIDMEM| DDCAPS2_STEREO|
  33. DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL| D3DCAPS2_NO2DDURING3DSCENE|
  34. D3DCAPS2_FULLSCREENGAMMA|*/ D3DCAPS2_CANRENDERWINDOWED|
  35. /*D3DCAPS2_CANCALIBRATEGAMMA|*/ 0,
  36. // Caps3
  37. 0,
  38. // Presentation Intervals
  39. 0,
  40. // Cursor Caps
  41. 0,
  42. // DevCaps (See d3d8caps.h & d3dhal.h)
  43. // The SDDI driver should keep D3DDEVCAPS_TEXTUREVIDEOMEMORY enabled. The
  44. // runtime does not behave correctly if the driver does not enable and
  45. // support this cap. In other words, all textures must be able to be
  46. // vid mem (driver allocated) textures, at least.
  47. D3DDEVCAPS_EXECUTESYSTEMMEMORY| /*D3DDEVCAPS_EXECUTEVIDEOMEMORY|*/
  48. D3DDEVCAPS_TLVERTEXSYSTEMMEMORY| /*D3DDEVCAPS_TLVERTEXVIDEOMEMORY|*/
  49. D3DDEVCAPS_TEXTURESYSTEMMEMORY| D3DDEVCAPS_TEXTUREVIDEOMEMORY|
  50. D3DDEVCAPS_DRAWPRIMTLVERTEX| /*D3DDEVCAPS_CANRENDERAFTERFLIP|
  51. D3DDEVCAPS_TEXTURENONLOCALVIDMEM| D3DDEVCAPS_DRAWPRIMITIVES2|*/
  52. /*D3DDEVCAPS_SEPARATETEXTUREMEMORIES|*/ D3DDEVCAPS_DRAWPRIMITIVES2EX|
  53. /*D3DDEVCAPS_HWTRANSFORMANDLIGHT| D3DDEVCAPS_CANBLTSYSTONONLOCAL|*/
  54. D3DDEVCAPS_HWRASTERIZATION| /*D3DDEVCAPS_PUREDEVICE|
  55. D3DDEVCAPS_QUINTICRTPATCHES| D3DDEVCAPS_RTPATCHES|
  56. D3DDEVCAPS_RTPATCHHANDLEZERO| D3DDEVCAPS_NPATCHES|
  57. D3DDEVCAPS_HWVERTEXBUFFER| D3DDEVCAPS_HWINDEXBUFFER|*/ 0,
  58. // Primitive Misc Caps
  59. D3DPMISCCAPS_MASKZ| D3DPMISCCAPS_LINEPATTERNREP| D3DPMISCCAPS_CULLNONE|
  60. D3DPMISCCAPS_CULLCW| D3DPMISCCAPS_CULLCCW| D3DPMISCCAPS_COLORWRITEENABLE|
  61. /*D3DPMISCCAPS_CLIPPLANESCALEDPOINTS| D3DPMISCCAPS_CLIPTLVERTS|*/
  62. D3DPMISCCAPS_TSSARGTEMP| D3DPMISCCAPS_BLENDOP| 0,
  63. // Raster Caps
  64. /*D3DPRASTERCAPS_DITHER| D3DPRASTERCAPS_ROP2| D3DPRASTERCAPS_XOR|
  65. D3DPRASTERCAPS_PAT|*/ D3DPRASTERCAPS_ZTEST| /*D3DPRASTERCAPS_FOGVERTEX|
  66. D3DPRASTERCAPS_FOGTABLE| D3DPRASTERCAPS_ANTIALIASEDGES|
  67. D3DPRASTERCAPS_MIPMAPLODBIAS| D3DPRASTERCAPS_ZBIAS|
  68. D3DPRASTERCAPS_ZBUFFERLESSHSR| D3DPRASTERCAPS_FOGRANGE|
  69. D3DPRASTERCAPS_ANISOTROPY| D3DPRASTERCAPS_WBUFFER|
  70. D3DPRASTERCAPS_WFOG| D3DPRASTERCAPS_ZFOG|
  71. D3DPRASTERCAPS_COLORPERSPECTIVE| D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE|
  72. */ 0,
  73. // Z Compare Caps
  74. D3DPCMPCAPS_NEVER| D3DPCMPCAPS_LESS| D3DPCMPCAPS_EQUAL|
  75. D3DPCMPCAPS_LESSEQUAL| D3DPCMPCAPS_GREATER| D3DPCMPCAPS_NOTEQUAL|
  76. D3DPCMPCAPS_GREATEREQUAL| D3DPCMPCAPS_ALWAYS| 0,
  77. // Src Blend Caps
  78. D3DPBLENDCAPS_ZERO| D3DPBLENDCAPS_ONE| D3DPBLENDCAPS_SRCCOLOR|
  79. D3DPBLENDCAPS_INVSRCCOLOR| D3DPBLENDCAPS_SRCALPHA|
  80. D3DPBLENDCAPS_INVSRCALPHA| D3DPBLENDCAPS_DESTALPHA|
  81. D3DPBLENDCAPS_INVDESTALPHA| D3DPBLENDCAPS_DESTCOLOR|
  82. D3DPBLENDCAPS_INVDESTCOLOR| D3DPBLENDCAPS_SRCALPHASAT|
  83. D3DPBLENDCAPS_BOTHSRCALPHA| D3DPBLENDCAPS_BOTHINVSRCALPHA| 0,
  84. // Dest Blend Caps
  85. D3DPBLENDCAPS_ZERO| D3DPBLENDCAPS_ONE| D3DPBLENDCAPS_SRCCOLOR|
  86. D3DPBLENDCAPS_INVSRCCOLOR| D3DPBLENDCAPS_SRCALPHA|
  87. D3DPBLENDCAPS_INVSRCALPHA| D3DPBLENDCAPS_DESTALPHA|
  88. D3DPBLENDCAPS_INVDESTALPHA| D3DPBLENDCAPS_DESTCOLOR|
  89. D3DPBLENDCAPS_INVDESTCOLOR| D3DPBLENDCAPS_SRCALPHASAT| 0,
  90. // Alpha Compare Caps
  91. D3DPCMPCAPS_NEVER| D3DPCMPCAPS_LESS| D3DPCMPCAPS_EQUAL|
  92. D3DPCMPCAPS_LESSEQUAL| D3DPCMPCAPS_GREATER| D3DPCMPCAPS_NOTEQUAL|
  93. D3DPCMPCAPS_GREATEREQUAL| D3DPCMPCAPS_ALWAYS| 0,
  94. // Shade Caps
  95. D3DPSHADECAPS_COLORGOURAUDRGB| D3DPSHADECAPS_SPECULARGOURAUDRGB|
  96. D3DPSHADECAPS_ALPHAGOURAUDBLEND| D3DPSHADECAPS_FOGGOURAUD| 0,
  97. // Texture Caps
  98. D3DPTEXTURECAPS_PERSPECTIVE| /*D3DPTEXTURECAPS_POW2|*/
  99. D3DPTEXTURECAPS_ALPHA| /*D3DPTEXTURECAPS_SQUAREONLY|*/
  100. D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE| D3DPTEXTURECAPS_ALPHAPALETTE|
  101. /*D3DPTEXTURECAPS_NONPOW2CONDITIONAL|*/ D3DPTEXTURECAPS_PROJECTED|
  102. D3DPTEXTURECAPS_CUBEMAP| D3DPTEXTURECAPS_VOLUMEMAP|
  103. D3DPTEXTURECAPS_MIPMAP| D3DPTEXTURECAPS_MIPVOLUMEMAP|
  104. D3DPTEXTURECAPS_MIPCUBEMAP| /*D3DPTEXTURECAPS_CUBEMAP_POW2|
  105. D3DPTEXTURECAPS_VOLUMEMAP_POW2|*/ 0,
  106. // Texture Filter Caps
  107. D3DPTFILTERCAPS_MINFPOINT| D3DPTFILTERCAPS_MINFLINEAR|
  108. D3DPTFILTERCAPS_MINFANISOTROPIC| D3DPTFILTERCAPS_MIPFPOINT|
  109. D3DPTFILTERCAPS_MIPFLINEAR| D3DPTFILTERCAPS_MAGFPOINT|
  110. D3DPTFILTERCAPS_MAGFLINEAR| D3DPTFILTERCAPS_MAGFANISOTROPIC|
  111. D3DPTFILTERCAPS_MAGFAFLATCUBIC| D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC| 0,
  112. // Cube Texture Filter Caps
  113. D3DPTFILTERCAPS_MINFPOINT| D3DPTFILTERCAPS_MINFLINEAR|
  114. D3DPTFILTERCAPS_MINFANISOTROPIC| D3DPTFILTERCAPS_MIPFPOINT|
  115. D3DPTFILTERCAPS_MIPFLINEAR| D3DPTFILTERCAPS_MAGFPOINT|
  116. D3DPTFILTERCAPS_MAGFLINEAR| D3DPTFILTERCAPS_MAGFANISOTROPIC|
  117. D3DPTFILTERCAPS_MAGFAFLATCUBIC| D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC| 0,
  118. // Volume Texture Filter Caps
  119. D3DPTFILTERCAPS_MINFPOINT| D3DPTFILTERCAPS_MINFLINEAR|
  120. D3DPTFILTERCAPS_MINFANISOTROPIC| D3DPTFILTERCAPS_MIPFPOINT|
  121. D3DPTFILTERCAPS_MIPFLINEAR| D3DPTFILTERCAPS_MAGFPOINT|
  122. D3DPTFILTERCAPS_MAGFLINEAR| D3DPTFILTERCAPS_MAGFANISOTROPIC|
  123. D3DPTFILTERCAPS_MAGFAFLATCUBIC| D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC| 0,
  124. // Texture Address Caps
  125. D3DPTADDRESSCAPS_WRAP| D3DPTADDRESSCAPS_MIRROR|
  126. D3DPTADDRESSCAPS_CLAMP| D3DPTADDRESSCAPS_BORDER|
  127. D3DPTADDRESSCAPS_INDEPENDENTUV| D3DPTADDRESSCAPS_MIRRORONCE| 0,
  128. // Volume Texture Address Caps
  129. D3DPTADDRESSCAPS_WRAP| D3DPTADDRESSCAPS_MIRROR|
  130. D3DPTADDRESSCAPS_CLAMP| D3DPTADDRESSCAPS_BORDER|
  131. D3DPTADDRESSCAPS_INDEPENDENTUV| D3DPTADDRESSCAPS_MIRRORONCE| 0,
  132. // Line Caps
  133. D3DLINECAPS_TEXTURE| D3DLINECAPS_ZTEST| D3DLINECAPS_BLEND|
  134. D3DLINECAPS_ALPHACMP| D3DLINECAPS_FOG| 0,
  135. // Max Texture Width, Height, Volume Extent
  136. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF,
  137. // Max Texture Repeat, Texture Aspect Ratio, Anisotropy
  138. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF,
  139. // Max VertexW
  140. 1.0e10f,
  141. // Guard Band left, top, right, bottom
  142. -32768.0f, -32768.0f, 32767.0f, 32767.0f,
  143. // Extents Adjust
  144. 0.0f,
  145. // Stencil Caps
  146. D3DSTENCILCAPS_KEEP| D3DSTENCILCAPS_ZERO| D3DSTENCILCAPS_REPLACE|
  147. D3DSTENCILCAPS_INCRSAT| D3DSTENCILCAPS_DECRSAT| D3DSTENCILCAPS_INVERT|
  148. D3DSTENCILCAPS_INCR| D3DSTENCILCAPS_DECR| 0,
  149. // FVF Caps
  150. (8& D3DFVFCAPS_TEXCOORDCOUNTMASK)| D3DFVFCAPS_DONOTSTRIPELEMENTS|
  151. D3DFVFCAPS_PSIZE| 0,
  152. // TextureOpCaps
  153. D3DTEXOPCAPS_DISABLE| D3DTEXOPCAPS_SELECTARG1| D3DTEXOPCAPS_SELECTARG2|
  154. D3DTEXOPCAPS_MODULATE| D3DTEXOPCAPS_MODULATE2X|
  155. D3DTEXOPCAPS_MODULATE4X| D3DTEXOPCAPS_ADD| D3DTEXOPCAPS_ADDSIGNED|
  156. D3DTEXOPCAPS_ADDSIGNED2X| D3DTEXOPCAPS_SUBTRACT|
  157. D3DTEXOPCAPS_ADDSMOOTH| D3DTEXOPCAPS_BLENDDIFFUSEALPHA|
  158. D3DTEXOPCAPS_BLENDTEXTUREALPHA| D3DTEXOPCAPS_BLENDFACTORALPHA|
  159. D3DTEXOPCAPS_BLENDTEXTUREALPHAPM| D3DTEXOPCAPS_BLENDCURRENTALPHA|
  160. D3DTEXOPCAPS_PREMODULATE| D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR|
  161. D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA|
  162. D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR|
  163. D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA| D3DTEXOPCAPS_BUMPENVMAP|
  164. D3DTEXOPCAPS_BUMPENVMAPLUMINANCE| D3DTEXOPCAPS_DOTPRODUCT3|
  165. D3DTEXOPCAPS_MULTIPLYADD| D3DTEXOPCAPS_LERP| 0,
  166. // Max Texture Blend Stages, Simulatenous Textures
  167. D3DHAL_TSS_MAXSTAGES, D3DHAL_TSS_MAXSTAGES,
  168. // Vertex Processing Caps
  169. /*D3DVTXPCAPS_TEXGEN| D3DVTXPCAPS_MATERIALSOURCE7|
  170. D3DVTXPCAPS_DIRECTIONALLIGHTS| D3DVTXPCAPS_POSITIONALLIGHTS|
  171. D3DVTXPCAPS_LOCALVIEWER| D3DVTXPCAPS_TWEENING|*/ 0,
  172. // Max Active Lights, User Clip Planes, Vertex Blend Matrices
  173. 0, 0, 0,
  174. // Max Vertex Blend Matrix Index, Point Size, Primitive Count
  175. 0, 1.0f, 0xFFFFFFFF,
  176. // Max Vertex Index, Streams, Stream Stride,
  177. 0xFFFFFFFF, 1, 256,
  178. // Vertex Shader version, Max Vertex Shader Const
  179. D3DVS_VERSION(0,0), 0,
  180. // Pixel Shader version, Max Pixel Shader Value
  181. D3DPS_VERSION(1,0), 16.0f,
  182. };
  183. const CMyDriver::CSurfaceCapWrap CMyDriver::c_aSurfaces[]=
  184. {
  185. // Tex, VTex, CTex, OffSTarg, SameFmtTarg, Z/S, Z/SWColor, SameFmtToA, 3D
  186. CSurfaceCapWrap( D3DFMT_A4R4G4B4,
  187. true, false, false, false, false, false, false, false, false),
  188. CSurfaceCapWrap( D3DFMT_R5G6B5,
  189. true, false, false, false, false, false, false, false, false),
  190. CSurfaceCapWrap( D3DFMT_A8R8G8B8,
  191. true, false, false, true, true, false, false, false, true),
  192. CSurfaceCapWrap( D3DFMT_X8R8G8B8,
  193. true, false, false, true, true, false, false, false, true),
  194. CSurfaceCapWrap( D3DFMT_D16_LOCKABLE,
  195. false, false, false, false, false, true, true, false, false),
  196. /* CSurfaceCapWrap( D3DFMT_D32,
  197. false, false, false, false, false, true, true, false, false),*/
  198. };
  199. CMyDriver::CMyDriver():
  200. CMinimalDriver< CMyDriver, CMyRasterizer>( c_aSurfaces,
  201. c_aSurfaces+ sizeof(c_aSurfaces)/ sizeof(c_aSurfaces[0]))
  202. {
  203. }
  204. /*
  205. const CMyContext::TDP2CmdBind CMyContext::c_aDP2Bindings[]=
  206. {
  207. TDP2CmdBind( D3DDP2OP_VIEWPORTINFO, DP2ViewportInfo),
  208. TDP2CmdBind( D3DDP2OP_WINFO, DP2WInfo),
  209. TDP2CmdBind( D3DDP2OP_RENDERSTATE, DP2RenderState),
  210. TDP2CmdBind( D3DDP2OP_TEXTURESTAGESTATE, DP2TextureStageState),
  211. TDP2CmdBind( D3DDP2OP_CLEAR, DP2Clear),
  212. TDP2CmdBind( D3DDP2OP_SETVERTEXSHADER, DP2SetVertexShader),
  213. TDP2CmdBind( D3DDP2OP_SETSTREAMSOURCE, DP2SetStreamSource),
  214. TDP2CmdBind( D3DDP2OP_SETINDICES, DP2SetIndices),
  215. TDP2CmdBind( D3DDP2OP_DRAWPRIMITIVE2, DP2DrawPrimitive2),
  216. TDP2CmdBind( D3DDP2OP_DRAWPRIMITIVE, DP2DrawPrimitive),
  217. TDP2CmdBind( D3DDP2OP_SETRENDERTARGET, DP2SetRenderTarget)
  218. };
  219. const CMyContext::TDP2CmdBind* CMyContext::GetDP2Bindings( unsigned int& iBindings)
  220. {
  221. iBindings= sizeof(c_aDP2Bindings)/ sizeof(c_aDP2Bindings[0]);
  222. return c_aDP2Bindings;
  223. }
  224. HRESULT CMyContext::DP2DrawPrimitive( TDP2Data& DP2Data, const D3DHAL_DP2COMMAND* pCmd,
  225. const void* pP)
  226. {
  227. const D3DHAL_DP2DRAWPRIMITIVE* pParam=
  228. reinterpret_cast< const D3DHAL_DP2DRAWPRIMITIVE*>(pP);
  229. const D3DHAL_DP2VIEWPORTINFO& ViewportInfo= (*this);
  230. const D3DHAL_DP2VERTEXSHADER& VertexShader= (*this);
  231. const D3DHAL_DP2SETSTREAMSOURCE& StreamSource= (*this);
  232. const D3DHAL_DP2SETINDICES& Indices= (*this);
  233. LPDDRAWI_DDRAWSURFACE_LCL pVBuffer= m_pGblDriver->SurfaceDBFind(
  234. m_pAssociatedDDraw, StreamSource.dwVBHandle);
  235. assert( pVBuffer!= NULL);
  236. if((VertexShader.dwHandle& D3DFVF_POSITION_MASK)!= D3DFVF_XYZRHW)
  237. return D3DERR_COMMAND_UNPARSED;
  238. const UINT8* pData= reinterpret_cast< const UINT8*>(
  239. pVBuffer->lpGbl->fpVidMem);
  240. pData+= pParam->VStart* StreamSource.dwStride;
  241. WORD wPrimitiveCount( pCmd->wPrimitiveCount);
  242. if( wPrimitiveCount) do
  243. {
  244. assert( pParam->primType== D3DPT_TRIANGLELIST);
  245. DWORD dwPrimCount( pParam->PrimitiveCount);
  246. if( dwPrimCount) do
  247. {
  248. const float* pfXYZ= reinterpret_cast<const float*>(pData);
  249. int iX( pfXYZ[0]);
  250. int iY( pfXYZ[1]);
  251. // TODO: Fix.
  252. if( iX>= 0 && iX< ViewportInfo.dwWidth &&
  253. iY>= 0 && iY< ViewportInfo.dwHeight)
  254. {
  255. DWORD* pPixel= reinterpret_cast<DWORD*>(
  256. reinterpret_cast<UINT8*>(m_pDDSLcl->lpGbl->fpVidMem)+
  257. (m_pDDSLcl->lpGbl->lPitch)* iY+ sizeof( DWORD)* iX);
  258. *pPixel= 0xFFFFFFFF;
  259. }
  260. pData+= StreamSource.dwStride;
  261. pfXYZ= reinterpret_cast<const float*>(pData);
  262. iX= pfXYZ[0];
  263. iY= pfXYZ[1];
  264. // TODO: Fix.
  265. if( iX>= 0 && iX< ViewportInfo.dwWidth &&
  266. iY>= 0 && iY< ViewportInfo.dwHeight)
  267. {
  268. DWORD* pPixel= reinterpret_cast<DWORD*>(
  269. reinterpret_cast<UINT8*>(m_pDDSLcl->lpGbl->fpVidMem)+
  270. (m_pDDSLcl->lpGbl->lPitch)* iY+ sizeof( DWORD)* iX);
  271. *pPixel= 0xFFFFFFFF;
  272. }
  273. pData+= StreamSource.dwStride;
  274. pfXYZ= reinterpret_cast<const float*>(pData);
  275. iX= pfXYZ[0];
  276. iY= pfXYZ[1];
  277. // TODO: Fix.
  278. if( iX>= 0 && iX< ViewportInfo.dwWidth &&
  279. iY>= 0 && iY< ViewportInfo.dwHeight)
  280. {
  281. DWORD* pPixel= reinterpret_cast<DWORD*>(
  282. reinterpret_cast<UINT8*>(m_pDDSLcl->lpGbl->fpVidMem)+
  283. (m_pDDSLcl->lpGbl->lPitch)* iY+ sizeof( DWORD)* iX);
  284. *pPixel= 0xFFFFFFFF;
  285. }
  286. pData+= StreamSource.dwStride;
  287. } while( --dwPrimCount);
  288. pParam++;
  289. } while( --wPrimitiveCount);
  290. return DD_OK;
  291. }
  292. HRESULT CMyContext::DP2DrawPrimitive2( TDP2Data& DP2Data, const D3DHAL_DP2COMMAND* pCmd,
  293. const void* pP)
  294. {
  295. const D3DHAL_DP2DRAWPRIMITIVE2* pParam=
  296. reinterpret_cast< const D3DHAL_DP2DRAWPRIMITIVE2*>(pP);
  297. const D3DHAL_DP2VIEWPORTINFO& ViewportInfo= (*this);
  298. const D3DHAL_DP2VERTEXSHADER& VertexShader= (*this);
  299. const D3DHAL_DP2SETSTREAMSOURCE& StreamSource= (*this);
  300. const D3DHAL_DP2SETINDICES& Indices= (*this);
  301. LPDDRAWI_DDRAWSURFACE_LCL pVBuffer= m_pGblDriver->SurfaceDBFind(
  302. m_pAssociatedDDraw, StreamSource.dwVBHandle);
  303. assert( pVBuffer!= NULL);
  304. assert((VertexShader.dwHandle& D3DFVF_POSITION_MASK)== D3DFVF_XYZRHW);
  305. const UINT8* pData= reinterpret_cast< const UINT8*>(
  306. pVBuffer->lpGbl->fpVidMem);
  307. pData+= pParam->FirstVertexOffset;
  308. WORD wPrimitiveCount( pCmd->wPrimitiveCount);
  309. if( wPrimitiveCount) do
  310. {
  311. assert( pParam->primType== D3DPT_TRIANGLELIST);
  312. DWORD dwPrimCount( pParam->PrimitiveCount);
  313. if( dwPrimCount) do
  314. {
  315. const float* pfXYZ= reinterpret_cast<const float*>(pData);
  316. int iX( pfXYZ[0]);
  317. int iY( pfXYZ[1]);
  318. // TODO: Fix.
  319. if( iX>= 0 && iX< ViewportInfo.dwWidth &&
  320. iY>= 0 && iY< ViewportInfo.dwHeight)
  321. {
  322. DWORD* pPixel= reinterpret_cast<DWORD*>(
  323. reinterpret_cast<UINT8*>(m_pDDSLcl->lpGbl->fpVidMem)+
  324. (m_pDDSLcl->lpGbl->lPitch)* iY+ sizeof( DWORD)* iX);
  325. *pPixel= 0xFFFFFFFF;
  326. }
  327. pData+= StreamSource.dwStride;
  328. pfXYZ= reinterpret_cast<const float*>(pData);
  329. iX= pfXYZ[0];
  330. iY= pfXYZ[1];
  331. // TODO: Fix.
  332. if( iX>= 0 && iX< ViewportInfo.dwWidth &&
  333. iY>= 0 && iY< ViewportInfo.dwHeight)
  334. {
  335. DWORD* pPixel= reinterpret_cast<DWORD*>(
  336. reinterpret_cast<UINT8*>(m_pDDSLcl->lpGbl->fpVidMem)+
  337. (m_pDDSLcl->lpGbl->lPitch)* iY+ sizeof( DWORD)* iX);
  338. *pPixel= 0xFFFFFFFF;
  339. }
  340. pData+= StreamSource.dwStride;
  341. pfXYZ= reinterpret_cast<const float*>(pData);
  342. iX= pfXYZ[0];
  343. iY= pfXYZ[1];
  344. // TODO: Fix.
  345. if( iX>= 0 && iX< ViewportInfo.dwWidth &&
  346. iY>= 0 && iY< ViewportInfo.dwHeight)
  347. {
  348. DWORD* pPixel= reinterpret_cast<DWORD*>(
  349. reinterpret_cast<UINT8*>(m_pDDSLcl->lpGbl->fpVidMem)+
  350. (m_pDDSLcl->lpGbl->lPitch)* iY+ sizeof( DWORD)* iX);
  351. *pPixel= 0xFFFFFFFF;
  352. }
  353. pData+= StreamSource.dwStride;
  354. } while( --dwPrimCount);
  355. pParam++;
  356. } while( --wPrimitiveCount);
  357. return DD_OK;
  358. }
  359. */