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.

866 lines
25 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3ddevice7obj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3dDeviceObj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3d7Obj.h"
  15. #include "d3dDevice7Obj.h"
  16. #include "ddSurface7Obj.h"
  17. #include "d3dEnumPixelFormats7Obj.h"
  18. extern BSTR D3DGUIDtoBSTR(LPGUID);
  19. //////////////////////////////////////////////////////////////////
  20. // C_dxj_Direct3dDevice7Object
  21. //////////////////////////////////////////////////////////////////
  22. C_dxj_Direct3dDevice7Object::C_dxj_Direct3dDevice7Object(){
  23. m__dxj_Direct3dDevice7=NULL;
  24. parent=NULL;
  25. pinterface=NULL;
  26. creationid = ++g_creationcount;
  27. DPF1(1,"Constructor Creation Direct3dDevice7[%d] \n",g_creationcount);
  28. nextobj = g_dxj_Direct3dDevice7;
  29. g_dxj_Direct3dDevice7 = (void *)this;
  30. }
  31. //////////////////////////////////////////////////////////////////
  32. // ~C_dxj_Direct3dDevice7Object
  33. //////////////////////////////////////////////////////////////////
  34. C_dxj_Direct3dDevice7Object::~C_dxj_Direct3dDevice7Object()
  35. {
  36. C_dxj_Direct3dDevice7Object *prev=NULL;
  37. for(C_dxj_Direct3dDevice7Object *ptr=(C_dxj_Direct3dDevice7Object *)g_dxj_Direct3dDevice7; ptr; ptr=(C_dxj_Direct3dDevice7Object *)ptr->nextobj)
  38. {
  39. if(ptr == this)
  40. {
  41. if(prev)
  42. prev->nextobj = ptr->nextobj;
  43. else
  44. g_dxj_Direct3dDevice7 = (void*)ptr->nextobj;
  45. break;
  46. }
  47. prev = ptr;
  48. }
  49. if(m__dxj_Direct3dDevice7){
  50. int count = IUNK(m__dxj_Direct3dDevice7)->Release();
  51. DPF1(1, "DirectX IDirect3dDevice7 Ref count [%d] \n",count);
  52. if(count==0) m__dxj_Direct3dDevice7 = NULL;
  53. }
  54. if(parent) IUNK(parent)->Release();
  55. if(parent2) IUNK(parent2)->Release();
  56. parent=NULL;
  57. parent2=NULL;
  58. }
  59. ///////////////// /////////////////////////////////////////////////
  60. // InternalAddRef
  61. //////////////////////////////////////////////////////////////////
  62. DWORD C_dxj_Direct3dDevice7Object::InternalAddRef(){
  63. DWORD i;
  64. i=CComObjectRoot::InternalAddRef();
  65. DPF2(1,"Direct3dDevice7[%d] AddRef %d \n",creationid,i);
  66. return i;
  67. }
  68. //////////////////////////////////////////////////////////////////
  69. // InternalRelease
  70. //////////////////////////////////////////////////////////////////
  71. DWORD C_dxj_Direct3dDevice7Object::InternalRelease(){
  72. DWORD i;
  73. i=CComObjectRoot::InternalRelease();
  74. DPF2(szBuf,"Direct3dDevice7 [%d] Release %d \n",creationid,i);
  75. return i;
  76. }
  77. //////////////////////////////////////////////////////////////////
  78. // InternalGetObject
  79. // InternalSetObject
  80. //////////////////////////////////////////////////////////////////
  81. GETSET_OBJECT(_dxj_Direct3dDevice7);
  82. //////////////////////////////////////////////////////////////////
  83. // beginScene
  84. // endScene
  85. // setClipStatus
  86. // setLightState
  87. // setRenderState
  88. // getClipStatus
  89. // getLightState
  90. // getRenderState
  91. //////////////////////////////////////////////////////////////////
  92. PASS_THROUGH_R(_dxj_Direct3dDevice7, beginScene, BeginScene);
  93. PASS_THROUGH_CAST_1_R(_dxj_Direct3dDevice7, setClipStatus, SetClipStatus, D3dClipStatus*,(D3DCLIPSTATUS*));
  94. PASS_THROUGH_CAST_2_R(_dxj_Direct3dDevice7, setRenderState, SetRenderState, long,(D3DRENDERSTATETYPE), long ,(DWORD));
  95. PASS_THROUGH_CAST_1_R(_dxj_Direct3dDevice7, getClipStatus, GetClipStatus, D3dClipStatus*, (D3DCLIPSTATUS *));
  96. PASS_THROUGH_CAST_2_R(_dxj_Direct3dDevice7, getRenderState, GetRenderState, long ,(D3DRENDERSTATETYPE), long*,(DWORD*));
  97. //////////////////////////////////////////////////////////////////
  98. // endScene
  99. //////////////////////////////////////////////////////////////////
  100. STDMETHODIMP C_dxj_Direct3dDevice7Object::endScene()
  101. {
  102. HRESULT hr;
  103. hr=m__dxj_Direct3dDevice7->EndScene();
  104. #ifdef _X86_
  105. _asm FINIT
  106. #endif
  107. return hr;
  108. }
  109. //////////////////////////////////////////////////////////////////
  110. // getRenderTarget
  111. //////////////////////////////////////////////////////////////////
  112. STDMETHODIMP C_dxj_Direct3dDevice7Object::getRenderTarget(I_dxj_DirectDrawSurface7 **ppsurf)
  113. {
  114. LPDIRECTDRAWSURFACE7 lpSurf=NULL;
  115. HRESULT hr;
  116. hr=m__dxj_Direct3dDevice7->GetRenderTarget(&lpSurf);
  117. INTERNAL_CREATE(_dxj_DirectDrawSurface7, lpSurf, ppsurf);
  118. return S_OK;
  119. }
  120. //////////////////////////////////////////////////////////////////
  121. // getTransform
  122. //////////////////////////////////////////////////////////////////
  123. STDMETHODIMP C_dxj_Direct3dDevice7Object::getTransform(long transtype,
  124. D3dMatrix *m){
  125. return m__dxj_Direct3dDevice7->GetTransform(
  126. (D3DTRANSFORMSTATETYPE) transtype,
  127. (LPD3DMATRIX)m);
  128. }
  129. //////////////////////////////////////////////////////////////////
  130. // multiplyTransform
  131. //////////////////////////////////////////////////////////////////
  132. STDMETHODIMP C_dxj_Direct3dDevice7Object::multiplyTransform(long transtype,
  133. D3dMatrix *m){
  134. return m__dxj_Direct3dDevice7->MultiplyTransform(
  135. (D3DTRANSFORMSTATETYPE) transtype,
  136. (LPD3DMATRIX) m);
  137. }
  138. //////////////////////////////////////////////////////////////////
  139. // setTransform
  140. //////////////////////////////////////////////////////////////////
  141. STDMETHODIMP C_dxj_Direct3dDevice7Object::setTransform(long transtype,
  142. D3dMatrix *m){
  143. return m__dxj_Direct3dDevice7->SetTransform(
  144. (D3DTRANSFORMSTATETYPE) transtype,
  145. (LPD3DMATRIX) m);
  146. }
  147. //////////////////////////////////////////////////////////////////
  148. // setRenderTarget
  149. //////////////////////////////////////////////////////////////////
  150. STDMETHODIMP C_dxj_Direct3dDevice7Object::setRenderTarget(I_dxj_DirectDrawSurface7 *surf)
  151. {
  152. HRESULT hr;
  153. if (!surf) return E_INVALIDARG;
  154. DO_GETOBJECT_NOTNULL(LPDIRECTDRAWSURFACE7, lpref, surf);
  155. hr= m__dxj_Direct3dDevice7->SetRenderTarget(lpref,0);
  156. return hr;
  157. }
  158. //////////////////////////////////////////////////////////////////
  159. // getTextureFormatsEnum
  160. //////////////////////////////////////////////////////////////////
  161. STDMETHODIMP C_dxj_Direct3dDevice7Object::getTextureFormatsEnum(I_dxj_Direct3DEnumPixelFormats **ppRet)
  162. {
  163. HRESULT hr;
  164. hr=C_dxj_Direct3DEnumPixelFormats7Object::create1(m__dxj_Direct3dDevice7,ppRet);
  165. return hr;
  166. }
  167. //////////////////////////////////////////////////////////////////
  168. // validateDevice
  169. //////////////////////////////////////////////////////////////////
  170. STDMETHODIMP C_dxj_Direct3dDevice7Object::validateDevice(
  171. /* [retval][out] */ long __RPC_FAR *passes)
  172. {
  173. HRESULT hr=m__dxj_Direct3dDevice7->ValidateDevice((DWORD*)passes);
  174. return hr;
  175. }
  176. //////////////////////////////////////////////////////////////////
  177. // getTexture
  178. //////////////////////////////////////////////////////////////////
  179. STDMETHODIMP C_dxj_Direct3dDevice7Object::getTexture(
  180. /* [in] */ long stage,
  181. /* [retval][out] */ I_dxj_DirectDrawSurface7 __RPC_FAR *__RPC_FAR *retv)
  182. {
  183. LPDIRECTDRAWSURFACE7 lpNew=NULL;
  184. HRESULT hr;
  185. *retv=NULL;
  186. hr=m__dxj_Direct3dDevice7->GetTexture((DWORD)stage,&lpNew);
  187. //null is valid
  188. if (lpNew==NULL) return S_OK;
  189. INTERNAL_CREATE(_dxj_DirectDrawSurface7, lpNew, retv);
  190. if (*retv==NULL) return E_OUTOFMEMORY;
  191. return hr;
  192. }
  193. //////////////////////////////////////////////////////////////////
  194. // getTextureStageState
  195. //////////////////////////////////////////////////////////////////
  196. STDMETHODIMP C_dxj_Direct3dDevice7Object::getTextureStageState(
  197. /* [in] */ long stage,
  198. /* [in] */ long state,
  199. /* [retval][out] */ long __RPC_FAR *retv)
  200. {
  201. HRESULT hr;
  202. hr=m__dxj_Direct3dDevice7->GetTextureStageState((DWORD)stage,(D3DTEXTURESTAGESTATETYPE) state, (DWORD*)retv);
  203. return hr;
  204. }
  205. //////////////////////////////////////////////////////////////////
  206. // setTexture
  207. //////////////////////////////////////////////////////////////////
  208. STDMETHODIMP C_dxj_Direct3dDevice7Object::setTexture(
  209. long stage,
  210. I_dxj_DirectDrawSurface7 *tex)
  211. {
  212. HRESULT hr;
  213. DO_GETOBJECT_NOTNULL(LPDIRECTDRAWSURFACE7, lpTex, tex);
  214. hr=m__dxj_Direct3dDevice7->SetTexture((DWORD)stage,lpTex);
  215. return hr;
  216. }
  217. //////////////////////////////////////////////////////////////////
  218. // setTextureStageState
  219. //////////////////////////////////////////////////////////////////
  220. STDMETHODIMP C_dxj_Direct3dDevice7Object::setTextureStageState(
  221. /* [in] */ long stage,
  222. /* [in] */ long state,
  223. /* [in] */ long val)
  224. {
  225. HRESULT hr;
  226. hr=m__dxj_Direct3dDevice7->SetTextureStageState((DWORD)stage,(D3DTEXTURESTAGESTATETYPE) state, (DWORD)val);
  227. return hr;
  228. }
  229. //////////////////////////////////////////////////////////////////
  230. // getCaps
  231. //////////////////////////////////////////////////////////////////
  232. STDMETHODIMP C_dxj_Direct3dDevice7Object::getCaps(
  233. D3dDeviceDesc7 *a)
  234. {
  235. //if (a) a->lSize=sizeof(D3DDEVICEDESC7);
  236. HRESULT hr;
  237. hr=m__dxj_Direct3dDevice7->GetCaps((D3DDEVICEDESC7*)a);
  238. return hr;
  239. }
  240. //////////////////////////////////////////////////////////////////
  241. // getDirect3D
  242. //////////////////////////////////////////////////////////////////
  243. STDMETHODIMP C_dxj_Direct3dDevice7Object::getDirect3D( I_dxj_Direct3d7 **ret)
  244. {
  245. HRESULT hr;
  246. LPDIRECT3D7 lpD3D=NULL;
  247. hr=m__dxj_Direct3dDevice7->GetDirect3D(&lpD3D);
  248. if FAILED(hr) return hr;
  249. if (!lpD3D) return E_FAIL;
  250. INTERNAL_CREATE(_dxj_Direct3d7,lpD3D,ret);
  251. return hr;
  252. }
  253. //////////////////////////////////////////////////////////////////
  254. // setViewport
  255. //////////////////////////////////////////////////////////////////
  256. STDMETHODIMP C_dxj_Direct3dDevice7Object::setViewport( D3dViewport7 *viewport)
  257. {
  258. HRESULT hr;
  259. if(!viewport) return E_INVALIDARG;
  260. hr=m__dxj_Direct3dDevice7->SetViewport((D3DVIEWPORT7*)viewport);
  261. return hr;
  262. }
  263. //////////////////////////////////////////////////////////////////
  264. // getViewport
  265. //////////////////////////////////////////////////////////////////
  266. STDMETHODIMP C_dxj_Direct3dDevice7Object::getViewport( D3dViewport7 *viewport)
  267. {
  268. HRESULT hr;
  269. if(!viewport) return E_INVALIDARG;
  270. hr=m__dxj_Direct3dDevice7->GetViewport((D3DVIEWPORT7*)viewport);
  271. return hr;
  272. }
  273. //////////////////////////////////////////////////////////////////
  274. // setMaterial
  275. //////////////////////////////////////////////////////////////////
  276. STDMETHODIMP C_dxj_Direct3dDevice7Object::setMaterial( D3dMaterial7 *mat)
  277. {
  278. HRESULT hr;
  279. if(!mat) return E_INVALIDARG;
  280. hr=m__dxj_Direct3dDevice7->SetMaterial((D3DMATERIAL7*)mat);
  281. return hr;
  282. }
  283. //////////////////////////////////////////////////////////////////
  284. // getMaterial
  285. //////////////////////////////////////////////////////////////////
  286. STDMETHODIMP C_dxj_Direct3dDevice7Object::getMaterial( D3dMaterial7 *mat)
  287. {
  288. HRESULT hr;
  289. if(!mat) return E_INVALIDARG;
  290. hr=m__dxj_Direct3dDevice7->GetMaterial((D3DMATERIAL7*)mat);
  291. return hr;
  292. }
  293. //////////////////////////////////////////////////////////////////
  294. // setLight
  295. //////////////////////////////////////////////////////////////////
  296. STDMETHODIMP C_dxj_Direct3dDevice7Object::setLight( long i,D3dLight7 *lgt)
  297. {
  298. HRESULT hr;
  299. if(!lgt) return E_INVALIDARG;
  300. hr=m__dxj_Direct3dDevice7->SetLight((DWORD)i,(D3DLIGHT7*)lgt);
  301. return hr;
  302. }
  303. //////////////////////////////////////////////////////////////////
  304. // getLight
  305. //////////////////////////////////////////////////////////////////
  306. STDMETHODIMP C_dxj_Direct3dDevice7Object::getLight( long i,D3dLight7 *lgt)
  307. {
  308. HRESULT hr;
  309. if(!lgt) return E_INVALIDARG;
  310. hr=m__dxj_Direct3dDevice7->GetLight((DWORD)i,(D3DLIGHT7*)lgt);
  311. return hr;
  312. }
  313. //////////////////////////////////////////////////////////////////
  314. // beginStateBlock
  315. //////////////////////////////////////////////////////////////////
  316. STDMETHODIMP C_dxj_Direct3dDevice7Object::beginStateBlock()
  317. {
  318. HRESULT hr;
  319. hr=m__dxj_Direct3dDevice7->BeginStateBlock();
  320. return hr;
  321. }
  322. //////////////////////////////////////////////////////////////////
  323. // endStateBlock
  324. //////////////////////////////////////////////////////////////////
  325. STDMETHODIMP C_dxj_Direct3dDevice7Object::endStateBlock( long *retv)
  326. {
  327. HRESULT hr;
  328. hr=m__dxj_Direct3dDevice7->EndStateBlock((DWORD*)retv);
  329. return hr;
  330. }
  331. //////////////////////////////////////////////////////////////////
  332. // deleteStateBlock
  333. //////////////////////////////////////////////////////////////////
  334. STDMETHODIMP C_dxj_Direct3dDevice7Object::deleteStateBlock(long m)
  335. {
  336. HRESULT hr;
  337. hr=m__dxj_Direct3dDevice7->DeleteStateBlock((DWORD)m);
  338. return hr;
  339. }
  340. //////////////////////////////////////////////////////////////////
  341. // ApplyStateBlock
  342. //////////////////////////////////////////////////////////////////
  343. STDMETHODIMP C_dxj_Direct3dDevice7Object::applyStateBlock(long m)
  344. {
  345. HRESULT hr;
  346. hr=m__dxj_Direct3dDevice7->ApplyStateBlock((DWORD)m);
  347. return hr;
  348. }
  349. //////////////////////////////////////////////////////////////////
  350. // createStateBlock
  351. //////////////////////////////////////////////////////////////////
  352. STDMETHODIMP C_dxj_Direct3dDevice7Object::createStateBlock(long type, long *retval)
  353. {
  354. HRESULT hr;
  355. hr=m__dxj_Direct3dDevice7->CreateStateBlock((D3DSTATEBLOCKTYPE)type,(DWORD*)retval);
  356. return hr;
  357. }
  358. //////////////////////////////////////////////////////////////////
  359. // captureStateBlock
  360. //////////////////////////////////////////////////////////////////
  361. STDMETHODIMP C_dxj_Direct3dDevice7Object::captureStateBlock(long m)
  362. {
  363. HRESULT hr;
  364. hr=m__dxj_Direct3dDevice7->CaptureStateBlock((DWORD)m);
  365. return hr;
  366. }
  367. //////////////////////////////////////////////////////////////////
  368. // lightEnable
  369. //////////////////////////////////////////////////////////////////
  370. STDMETHODIMP C_dxj_Direct3dDevice7Object::lightEnable( long index, VARIANT_BOOL b){
  371. HRESULT hr;
  372. hr=m__dxj_Direct3dDevice7->LightEnable((DWORD)index,(b!=VARIANT_FALSE));
  373. return hr;
  374. }
  375. //////////////////////////////////////////////////////////////////
  376. // lightEnable
  377. //////////////////////////////////////////////////////////////////
  378. STDMETHODIMP C_dxj_Direct3dDevice7Object::getLightEnable( long index, VARIANT_BOOL *bOut){
  379. HRESULT hr;
  380. BOOL b;
  381. hr=m__dxj_Direct3dDevice7->GetLightEnable((DWORD)index,&b);
  382. if (b){
  383. *bOut=VARIANT_TRUE;
  384. }
  385. else {
  386. *bOut=VARIANT_FALSE;
  387. }
  388. return hr;
  389. }
  390. //////////////////////////////////////////////////////////////////
  391. // drawIndexedPrimitive
  392. //////////////////////////////////////////////////////////////////
  393. STDMETHODIMP C_dxj_Direct3dDevice7Object::drawIndexedPrimitive(
  394. d3dPrimitiveType d3dpt,
  395. long d3dvt,
  396. void *Verts,
  397. long vertexCount,
  398. SAFEARRAY **ppsaIndex,
  399. long indexArraySize,
  400. long flags){
  401. HRESULT hr;
  402. __try {
  403. hr=m__dxj_Direct3dDevice7->DrawIndexedPrimitive(
  404. (D3DPRIMITIVETYPE) d3dpt,
  405. (DWORD) d3dvt,
  406. (void*) Verts,
  407. (DWORD)vertexCount,
  408. (unsigned short*) ((SAFEARRAY*)*ppsaIndex)->pvData,
  409. (DWORD)indexArraySize,
  410. (DWORD) flags);
  411. }
  412. __except(1, 1){
  413. return DDERR_EXCEPTION;
  414. }
  415. return hr;
  416. }
  417. //////////////////////////////////////////////////////////////////
  418. // drawPrimitive
  419. //////////////////////////////////////////////////////////////////
  420. STDMETHODIMP C_dxj_Direct3dDevice7Object::drawPrimitive(
  421. d3dPrimitiveType d3dpt,
  422. long d3dvt,
  423. void* Verts,
  424. long vertexCount,
  425. long flags){
  426. HRESULT hr;
  427. __try {
  428. hr= m__dxj_Direct3dDevice7->DrawPrimitive(
  429. (D3DPRIMITIVETYPE) d3dpt,
  430. (DWORD) d3dvt,
  431. (void*) Verts,
  432. (DWORD)vertexCount,
  433. (DWORD) flags);
  434. }
  435. __except(1, 1){
  436. return DDERR_EXCEPTION;
  437. }
  438. return hr;
  439. }
  440. //////////////////////////////////////////////////////////////////
  441. // clear
  442. //////////////////////////////////////////////////////////////////
  443. STDMETHODIMP C_dxj_Direct3dDevice7Object::clear(long count,SAFEARRAY **psa, long flags, long color, float z, long stencil )
  444. {
  445. if (!ISSAFEARRAY1D(psa,(DWORD)count)) return E_INVALIDARG;
  446. return m__dxj_Direct3dDevice7->Clear( (DWORD)count,(D3DRECT*)((SAFEARRAY*)*psa)->pvData, flags ,color,z,stencil);
  447. }
  448. //////////////////////////////////////////////////////////////////
  449. // computeSphereVisibility
  450. //////////////////////////////////////////////////////////////////
  451. STDMETHODIMP C_dxj_Direct3dDevice7Object::computeSphereVisibility(
  452. D3dVector __RPC_FAR *center,
  453. float __RPC_FAR *radi,
  454. /* [retval][out] */ long __RPC_FAR *returnVal)
  455. {
  456. HRESULT hr=m__dxj_Direct3dDevice7->ComputeSphereVisibility((LPD3DVECTOR)center,radi,1,0,(DWORD*)returnVal);
  457. return hr;
  458. }
  459. //////////////////////////////////////////////////////////////////
  460. // drawIndexedPrimitiveVB
  461. //////////////////////////////////////////////////////////////////
  462. STDMETHODIMP C_dxj_Direct3dDevice7Object::drawIndexedPrimitiveVB(
  463. /* [in] */ d3dPrimitiveType d3dpt,
  464. /* [in] */ I_dxj_Direct3dVertexBuffer7 __RPC_FAR *vertexBuffer,
  465. long startIndex,
  466. long numIndex,
  467. /* [in] */ SAFEARRAY __RPC_FAR * __RPC_FAR *indexArray,
  468. /* [in] */ long indexcount,
  469. /* [in] */ long flags)
  470. {
  471. HRESULT hr;
  472. if (!indexArray) return E_FAIL;
  473. DO_GETOBJECT_NOTNULL( LPDIRECT3DVERTEXBUFFER7 , lpVB, vertexBuffer);
  474. __try{
  475. hr=m__dxj_Direct3dDevice7->DrawIndexedPrimitiveVB
  476. ((D3DPRIMITIVETYPE)d3dpt,
  477. lpVB,
  478. (DWORD) startIndex,
  479. (DWORD) numIndex,
  480. (WORD*) ((SAFEARRAY*)*indexArray)->pvData,
  481. (DWORD)indexcount,
  482. (DWORD)flags);
  483. }
  484. __except(1,1){
  485. return DDERR_EXCEPTION;
  486. }
  487. return hr;
  488. }
  489. //////////////////////////////////////////////////////////////////
  490. // drawPrimitiveVB
  491. //////////////////////////////////////////////////////////////////
  492. STDMETHODIMP C_dxj_Direct3dDevice7Object::drawPrimitiveVB(
  493. /* [in] */ d3dPrimitiveType d3dpt,
  494. /* [in] */ I_dxj_Direct3dVertexBuffer7 __RPC_FAR *vertexBuffer,
  495. /* [in] */ long startVertex,
  496. /* [in] */ long numVertices,
  497. /* [in] */ long flags)
  498. {
  499. HRESULT hr;
  500. DO_GETOBJECT_NOTNULL( LPDIRECT3DVERTEXBUFFER7 , lpVB, vertexBuffer);
  501. __try{
  502. hr=m__dxj_Direct3dDevice7->DrawPrimitiveVB
  503. ((D3DPRIMITIVETYPE)d3dpt,
  504. lpVB,
  505. (DWORD) startVertex,
  506. (DWORD) numVertices,
  507. (DWORD)flags);
  508. }
  509. __except(1,1){
  510. return DDERR_EXCEPTION;
  511. }
  512. return hr;
  513. }
  514. STDMETHODIMP C_dxj_Direct3dDevice7Object::preLoad( I_dxj_DirectDrawSurface7 *surf)
  515. {
  516. HRESULT hr;
  517. DO_GETOBJECT_NOTNULL( LPDIRECTDRAWSURFACE7 , lpSurf, surf);
  518. hr= m__dxj_Direct3dDevice7->PreLoad(lpSurf);
  519. return hr;
  520. }
  521. //////////////////////////////////////////////////////////////////
  522. // load
  523. //////////////////////////////////////////////////////////////////
  524. STDMETHODIMP C_dxj_Direct3dDevice7Object::load(
  525. /* [in] */ I_dxj_DirectDrawSurface7 __RPC_FAR *tex1,
  526. /* [in] */ long x,
  527. /* [in] */ long y,
  528. /* [in] */ I_dxj_DirectDrawSurface7 __RPC_FAR *tex2,
  529. /* [in] */ Rect __RPC_FAR *rc,
  530. /* [in] */ long flags)
  531. {
  532. HRESULT hr;
  533. if (!tex1) return E_INVALIDARG;
  534. if (!tex2) return E_INVALIDARG;
  535. if (!rc) return E_INVALIDARG;
  536. DO_GETOBJECT_NOTNULL(LPDIRECTDRAWSURFACE7,lpTex1,tex1);
  537. DO_GETOBJECT_NOTNULL(LPDIRECTDRAWSURFACE7,lpTex2,tex2);
  538. //dont allow this as it gpfs some drivers and is invalid anyway
  539. if (lpTex1==lpTex2) return E_INVALIDARG;
  540. POINT p;
  541. p.x=x;
  542. p.y=y;
  543. hr=m__dxj_Direct3dDevice7->Load(lpTex1,&p,lpTex2,(LPRECT)rc,(DWORD)flags);
  544. return hr;
  545. }
  546. //PASS_THROUGH_CAST_2_R(_dxj_Direct3dDevice7, setRenderState, SetRenderState, long,(D3DRENDERSTATETYPE), long ,(DWORD));
  547. //////////////////////////////////////////////////////////////////
  548. // setRenderStateSingle
  549. //////////////////////////////////////////////////////////////////
  550. STDMETHODIMP C_dxj_Direct3dDevice7Object::setRenderStateSingle(
  551. /* [in] */ long renderstate,
  552. /* [in] */ float val)
  553. {
  554. HRESULT hr;
  555. hr=m__dxj_Direct3dDevice7->SetRenderState((D3DRENDERSTATETYPE) renderstate, *((DWORD*)&val));
  556. return hr;
  557. }
  558. //////////////////////////////////////////////////////////////////
  559. // getRenderStateSingle
  560. //////////////////////////////////////////////////////////////////
  561. STDMETHODIMP C_dxj_Direct3dDevice7Object::getRenderStateSingle(
  562. /* [in] */ long renderstate,
  563. /* [in] */ float *val)
  564. {
  565. HRESULT hr;
  566. hr=m__dxj_Direct3dDevice7->GetRenderState((D3DRENDERSTATETYPE) renderstate, (DWORD*)val);
  567. return hr;
  568. }
  569. //////////////////////////////////////////////////////////////////
  570. // setTextureStageStateSingle
  571. //////////////////////////////////////////////////////////////////
  572. STDMETHODIMP C_dxj_Direct3dDevice7Object::setTextureStageStateSingle(
  573. /* [in] */ long stage,
  574. /* [in] */ long state,
  575. /* [in] */ float val)
  576. {
  577. HRESULT hr;
  578. hr=m__dxj_Direct3dDevice7->SetTextureStageState((DWORD)stage,(D3DTEXTURESTAGESTATETYPE) state, *((DWORD*)&val));
  579. return hr;
  580. }
  581. //////////////////////////////////////////////////////////////////
  582. // getTextureStageState
  583. //////////////////////////////////////////////////////////////////
  584. STDMETHODIMP C_dxj_Direct3dDevice7Object::getTextureStageStateSingle(
  585. /* [in] */ long stage,
  586. /* [in] */ long state,
  587. /* [in] */ float *val)
  588. {
  589. HRESULT hr;
  590. hr=m__dxj_Direct3dDevice7->GetTextureStageState((DWORD)stage,(D3DTEXTURESTAGESTATETYPE) state, (DWORD*)val);
  591. return hr;
  592. }
  593. //////////////////////////////////////////////////////////////////
  594. // getInfo
  595. //////////////////////////////////////////////////////////////////
  596. STDMETHODIMP C_dxj_Direct3dDevice7Object::getInfo(
  597. /* [in] */ long lDevInfoID,
  598. /* [out][in] */ void __RPC_FAR *DevInfoType,
  599. /* [in] */ long lSize)
  600. {
  601. HRESULT hr;
  602. __try
  603. {
  604. hr=m__dxj_Direct3dDevice7->GetInfo((DWORD)lDevInfoID,DevInfoType, (DWORD)lSize);
  605. }
  606. __except(1,1)
  607. {
  608. return E_FAIL;
  609. }
  610. return hr;
  611. }
  612. //////////////////////////////////////////////////////////////////
  613. // getDeviceGuid
  614. //////////////////////////////////////////////////////////////////
  615. STDMETHODIMP C_dxj_Direct3dDevice7Object::getDeviceGuid( BSTR *ret)
  616. {
  617. HRESULT hr;
  618. D3DDEVICEDESC7 desc;
  619. if (!ret) return E_INVALIDARG;
  620. //desc.dwSize=sizeof(D3DDEVICEDESC7);
  621. hr=m__dxj_Direct3dDevice7->GetCaps(&desc);
  622. if FAILED(hr) return hr;
  623. *ret=D3DGUIDtoBSTR(&desc.deviceGUID);
  624. return hr;
  625. }
  626. //////////////////////////////////////////////////////////////////
  627. // setClipPlane
  628. //////////////////////////////////////////////////////////////////
  629. STDMETHODIMP C_dxj_Direct3dDevice7Object::setClipPlane(long index,float A, float B, float C, float D)
  630. {
  631. HRESULT hr;
  632. float floats[4];
  633. floats[0]=A;
  634. floats[1]=B;
  635. floats[2]=C;
  636. floats[3]=D;
  637. hr=m__dxj_Direct3dDevice7->SetClipPlane((DWORD)index, floats);
  638. return hr;
  639. }
  640. //////////////////////////////////////////////////////////////////
  641. // setClipPlane
  642. //////////////////////////////////////////////////////////////////
  643. STDMETHODIMP C_dxj_Direct3dDevice7Object::getClipPlane(long index,float *A, float *B, float *C, float *D)
  644. {
  645. HRESULT hr;
  646. float floats[4];
  647. hr=m__dxj_Direct3dDevice7->GetClipPlane((DWORD)index, floats);
  648. if FAILED(hr) return hr;
  649. *A=floats[0];
  650. *B=floats[1];
  651. *C=floats[2];
  652. *D=floats[3];
  653. return hr;
  654. }
  655. #if 0
  656. //////////////////////////////////////////////////////////////////
  657. // clear
  658. //////////////////////////////////////////////////////////////////
  659. STDMETHODIMP C_dxj_Direct3dDevice7Object::clear(
  660. /* [in] */ long l1,
  661. /* [in] */ D3dRect __RPC_FAR *rc,
  662. /* [in] */ long l2,
  663. /* [in] */ long color,
  664. /* [in] */ float z,
  665. /* [in] */ long l3)
  666. {
  667. HRESULT hr;
  668. if (!rc) return E_INVALIDARG;
  669. __try{
  670. hr=m__dxj_Direct3dDevice7->Clear((DWORD)l1,(D3DRECT*)rc,(DWORD)l2,(DWORD)color,(float)z,(DWORD)l3);
  671. }
  672. __except(1,1){
  673. return E_INVALIDARG;
  674. }
  675. return hr;
  676. }
  677. //////////////////////////////////////////////////////////////////
  678. // setVertexComponent
  679. //////////////////////////////////////////////////////////////////
  680. STDMETHODIMP C_dxj_Direct3dDevice7Object::setVertexComponent(
  681. /* [in] */ long __RPC_FAR component,
  682. /* [in] */ I_dxj_Direct3dVertexBuffer7 __RPC_FAR *vb,
  683. /* [in] */ long l1,
  684. /* [in] */ long l2)
  685. {
  686. HRESULT hr;
  687. if (!vb) return E_INVALIDARG;
  688. DO_GETOBJECT_NOTNULL(LPDIRECT3DVERTEXBUFFER7,pVB,vb);
  689. hr=m__dxj_Direct3dDevice7->SetVertexComponent((D3DVERTEXCOMPONENT)component, pVB,(DWORD)l1,(DWORD)l2);
  690. return hr;
  691. }
  692. #endif