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.

2028 lines
55 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1998
  6. //
  7. // File: d3dx8obj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "stdafx.h"
  11. #include "Direct.h"
  12. #include "dms.h"
  13. #include "d3dx8Obj.h"
  14. #include "d3dx8.h"
  15. #include "filestrm.h"
  16. #include "dxerr8.h"
  17. #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
  18. STDMETHODIMP C_dxj_D3DX8Object::CreateFont(
  19. /* [in] */ IUnknown *Device,
  20. #ifdef _WIN64
  21. /* [in] */ HANDLE hFont,
  22. #else
  23. /* [in] */ long hFont,
  24. #endif
  25. /* [retval][out] */ D3DXFont **retFont)
  26. {
  27. HRESULT hr;
  28. hr= ::D3DXCreateFont(
  29. (IDirect3DDevice8*) Device,
  30. (HFONT) hFont,
  31. (ID3DXFont**) retFont);
  32. return hr;
  33. }
  34. STDMETHODIMP C_dxj_D3DX8Object::DrawText(
  35. /* [in] */ D3DXFont *BitmapFont,
  36. /* [in] */ long Color,
  37. /* [in] */ BSTR TextString,
  38. /* [in] */ RECT *Rect,
  39. /* [in] */ long Format)
  40. {
  41. HRESULT hr;
  42. if (!BitmapFont) return E_INVALIDARG;
  43. USES_CONVERSION;
  44. char *szStr = NULL;
  45. __try { szStr=W2T(TextString); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  46. ((ID3DXFont*)BitmapFont)->DrawTextA(szStr,-1, Rect, (DWORD) Format,(DWORD) Color);
  47. return S_OK;
  48. }
  49. STDMETHODIMP C_dxj_D3DX8Object::GetFVFVertexSize(
  50. /* [in] */ long FVF,
  51. /* [retval][out] */ long*size)
  52. {
  53. *size=(long)::D3DXGetFVFVertexSize((DWORD)FVF);
  54. return S_OK;
  55. }
  56. STDMETHODIMP C_dxj_D3DX8Object::AssembleShaderFromFile(
  57. /* [in] */ BSTR SrcFile,
  58. /* [in] */ long flags,
  59. /* [in] */ BSTR *ErrLog,
  60. /* [in] */ D3DXBuffer **Constants,
  61. /* [retval][out] */ D3DXBuffer **ppVertexShader)
  62. {
  63. HRESULT hr;
  64. USES_CONVERSION;
  65. char *szFile = NULL;
  66. __try { szFile=W2T(SrcFile); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  67. LPD3DXBUFFER pBuffer = NULL;
  68. WCHAR *wszData = NULL;
  69. hr=::D3DXAssembleShaderFromFile(
  70. szFile,
  71. (DWORD) flags,
  72. (ID3DXBuffer**) Constants,
  73. (ID3DXBuffer**) ppVertexShader,
  74. &pBuffer);
  75. if (FAILED(hr))
  76. {
  77. if (ErrLog)
  78. {
  79. if (*ErrLog)
  80. {
  81. SysFreeString(*ErrLog);
  82. }
  83. }
  84. if (pBuffer)
  85. {
  86. wszData = T2W((TCHAR*)pBuffer->GetBufferPointer());
  87. *ErrLog = SysAllocString(wszData);
  88. }
  89. }
  90. SAFE_RELEASE(pBuffer)
  91. //Wide string version still not exported
  92. //
  93. //hr=::D3DXAssembleVertexShaderFromFileW(
  94. // (WCHAR*) SrcFile,
  95. // (ID3DXBuffer**) ppVertexShader,
  96. // NULL);
  97. return hr;
  98. }
  99. STDMETHODIMP C_dxj_D3DX8Object::AssembleShader(
  100. /* [in] */ BSTR SrcData,
  101. /* [in] */ long flags,
  102. /* [in] */ D3DXBuffer **Constants,
  103. /* [in][out][optional] */ BSTR *ErrLog,
  104. /* [retval][out] */ D3DXBuffer **ppVertexShader)
  105. {
  106. WCHAR *wszData = NULL;
  107. char *szData=NULL;
  108. LPD3DXBUFFER pBuffer = NULL;
  109. DWORD dwLen=0;
  110. HRESULT hr;
  111. USES_CONVERSION;
  112. if (SrcData == NULL)
  113. return E_INVALIDARG;
  114. __try {
  115. szData=W2T((WCHAR*)SrcData);
  116. dwLen=strlen(szData);
  117. hr=::D3DXAssembleShader(
  118. szData,
  119. dwLen,
  120. (DWORD) flags,
  121. (ID3DXBuffer**) Constants,
  122. (ID3DXBuffer**) ppVertexShader,
  123. (ID3DXBuffer**) &pBuffer);
  124. if (FAILED(hr))
  125. {
  126. if (ErrLog)
  127. {
  128. if (*ErrLog)
  129. {
  130. SysFreeString(*ErrLog);
  131. }
  132. }
  133. if (pBuffer)
  134. {
  135. wszData = T2W((TCHAR*)pBuffer->GetBufferPointer());
  136. *ErrLog = SysAllocString(wszData);
  137. }
  138. }
  139. SAFE_RELEASE(pBuffer)
  140. }
  141. __except(1,1)
  142. {
  143. SAFE_RELEASE(pBuffer)
  144. return E_INVALIDARG;
  145. }
  146. return hr;
  147. }
  148. STDMETHODIMP C_dxj_D3DX8Object::GetErrorString(
  149. /* [in] */ long hr,
  150. /* [retval][out] */ BSTR* retStr)
  151. {
  152. if (!retStr) return E_INVALIDARG;
  153. //NOT SysAllocString return NULL if DXGetErrorString returns NULL
  154. *retStr=SysAllocString(DXGetErrorString8W(hr));
  155. return S_OK;
  156. }
  157. STDMETHODIMP C_dxj_D3DX8Object::LoadSurfaceFromFile(
  158. /* [in] */ IUnknown *DestSurface,
  159. /* [in] */ void *DestPalette,
  160. /* [in] */ void*DestRect,
  161. /* [in] */ BSTR SrcFile,
  162. /* [in] */ void*SrcRect,
  163. /* [in] */ long Filter,
  164. /* [in] */ long ColorKey,
  165. /* [in] */ void *SrcInfo)
  166. {
  167. HRESULT hr;
  168. hr=::D3DXLoadSurfaceFromFileW(
  169. (IDirect3DSurface8*) DestSurface,
  170. (PALETTEENTRY*) DestPalette,
  171. (RECT*) DestRect,
  172. (WCHAR*) SrcFile,
  173. (RECT*) SrcRect,
  174. (DWORD) Filter,
  175. (D3DCOLOR) ColorKey,
  176. (D3DXIMAGE_INFO*)SrcInfo);
  177. return hr;
  178. }
  179. STDMETHODIMP C_dxj_D3DX8Object::LoadSurfaceFromFileInMemory(
  180. /* [in] */ IUnknown *DestSurface,
  181. /* [in] */ void* DestPalette,
  182. /* [in] */ void* DestRect,
  183. /* [in] */ void* SrcData,
  184. /* [in] */ long LengthInBytes,
  185. /* [in] */ void* SrcRect,
  186. /* [in] */ long Filter,
  187. /* [in] */ long ColorKey,
  188. /* [in] */ void *SrcInfo)
  189. {
  190. HRESULT hr;
  191. __try {
  192. hr=::D3DXLoadSurfaceFromFileInMemory(
  193. (IDirect3DSurface8*) DestSurface,
  194. (PALETTEENTRY*) DestPalette,
  195. (RECT*) DestRect,
  196. SrcData,
  197. (DWORD) LengthInBytes,
  198. (RECT*) SrcRect,
  199. (DWORD) Filter,
  200. (D3DCOLOR) ColorKey,
  201. (D3DXIMAGE_INFO*)SrcInfo);
  202. }
  203. __except(1,1)
  204. {
  205. return E_INVALIDARG;
  206. }
  207. return hr;
  208. }
  209. // TODO: fix from RECT to void pointer
  210. STDMETHODIMP C_dxj_D3DX8Object::LoadSurfaceFromSurface(
  211. /* [in] */ IUnknown *DestSurface,
  212. /* [in] */ void *DestPalette,
  213. /* [in] */ void *DestRect,
  214. /* [in] */ IUnknown *SrcSurface,
  215. /* [in] */ void *SrcPalette,
  216. /* [in] */ void *SrcRect,
  217. /* [in] */ long Filter,
  218. /* [in] */ long ColorKey)
  219. {
  220. HRESULT hr;
  221. hr=::D3DXLoadSurfaceFromSurface(
  222. (IDirect3DSurface8*) DestSurface,
  223. (PALETTEENTRY*) DestPalette,
  224. (RECT*) DestRect,
  225. (IDirect3DSurface8*) SrcSurface,
  226. (PALETTEENTRY*) SrcPalette,
  227. (RECT*) SrcRect,
  228. (DWORD) Filter,
  229. (D3DCOLOR) ColorKey);
  230. return hr;
  231. }
  232. STDMETHODIMP C_dxj_D3DX8Object::LoadSurfaceFromMemory(
  233. /* [in] */ IUnknown *DestSurface,
  234. /* [in] */ void *DestPalette,
  235. /* [in] */ void *DestRect,
  236. /* [in] */ void *SrcData,
  237. /* [in] */ long formatSrc,
  238. /* [in] */ long SrcPitch,
  239. /* [in] */ void *SrcPalette,
  240. /* [in] */ RECT_CDESC *SrcRect,
  241. /* [in] */ long Filter,
  242. /* [in] */ long ColorKey)
  243. {
  244. HRESULT hr;
  245. hr =::D3DXLoadSurfaceFromMemory(
  246. (IDirect3DSurface8*) DestSurface,
  247. (PALETTEENTRY*) DestPalette,
  248. (RECT*) DestRect,
  249. SrcData,
  250. (D3DFORMAT) formatSrc,
  251. (DWORD) SrcPitch,
  252. (PALETTEENTRY*) SrcPalette,
  253. (RECT*) SrcRect,
  254. (DWORD) Filter,
  255. (D3DCOLOR) ColorKey);
  256. return hr;
  257. }
  258. STDMETHODIMP C_dxj_D3DX8Object::LoadSurfaceFromResource(
  259. IUnknown *pDestSurface,
  260. void* pDestPalette,
  261. void* pDestRect,
  262. #ifdef _WIN64
  263. HANDLE hSrcModule,
  264. #else
  265. long hSrcModule,
  266. #endif
  267. BSTR SrcResource,
  268. void* pSrcRect,
  269. long Filter,
  270. long ColorKey,
  271. void* SrcInfo)
  272. {
  273. HRESULT hr;
  274. hr=::D3DXLoadSurfaceFromResourceW(
  275. (LPDIRECT3DSURFACE8)pDestSurface,
  276. (PALETTEENTRY*) pDestPalette,
  277. (RECT*) pDestRect,
  278. (HMODULE) hSrcModule,
  279. (LPCWSTR) SrcResource,
  280. (RECT*) pSrcRect,
  281. (DWORD) Filter,
  282. (D3DCOLOR) ColorKey,
  283. (D3DXIMAGE_INFO*) SrcInfo);
  284. return hr;
  285. }
  286. STDMETHODIMP C_dxj_D3DX8Object::CheckTextureRequirements(
  287. /* [out][in] */ IUnknown *Device,
  288. /* [out][in] */ long*Width,
  289. /* [out][in] */ long*Height,
  290. /* [out][in] */ long*NumMipLevels,
  291. long Usage,
  292. /* [out][in] */ long*pPixelFormat,
  293. long Pool)
  294. {
  295. HRESULT hr;
  296. hr=::D3DXCheckTextureRequirements(
  297. (IDirect3DDevice8*) Device,
  298. (UINT*) Width,
  299. (UINT*) Height,
  300. (UINT*) NumMipLevels,
  301. (DWORD) Usage,
  302. (D3DFORMAT*) pPixelFormat,
  303. (D3DPOOL) Pool);
  304. return hr;
  305. }
  306. STDMETHODIMP C_dxj_D3DX8Object::CreateTexture(
  307. /* [in] */ IUnknown *Device,
  308. /* [in] */ long Width,
  309. /* [in] */ long Height,
  310. /* [in] */ long MipLevels,
  311. /* [in] */ long Usage,
  312. /* [in] */ long PixelFormat,
  313. /* [in] */ long Pool,
  314. /* [retval][out] */ IUnknown **ppTexture)
  315. {
  316. HRESULT hr;
  317. hr=::D3DXCreateTexture(
  318. (IDirect3DDevice8*) Device,
  319. (DWORD) Width,
  320. (DWORD) Height,
  321. (DWORD) MipLevels,
  322. (DWORD) Usage,
  323. (D3DFORMAT) PixelFormat,
  324. (D3DPOOL) Pool,
  325. (IDirect3DTexture8**) ppTexture);
  326. return hr;
  327. }
  328. STDMETHODIMP C_dxj_D3DX8Object::CreateTextureFromResource(
  329. /* [in] */ IUnknown *Device,
  330. #ifdef _WIN64
  331. /* [in] */ HANDLE hSrcModule,
  332. #else
  333. /* [in] */ long hSrcModule,
  334. #endif
  335. /* [in] */ BSTR SrcResource,
  336. /* [retval][out] */ IUnknown **ppTexture)
  337. {
  338. HRESULT hr;
  339. hr=::D3DXCreateTextureFromResourceW(
  340. (IDirect3DDevice8*) Device,
  341. (HMODULE) hSrcModule,
  342. (WCHAR*) SrcResource,
  343. (IDirect3DTexture8**) ppTexture);
  344. return hr;
  345. }
  346. STDMETHODIMP C_dxj_D3DX8Object::CreateTextureFromResourceEx(
  347. /* [in] */ IUnknown *Device,
  348. #ifdef _WIN64
  349. /* [in] */ HANDLE hSrcModule,
  350. #else
  351. /* [in] */ long hSrcModule,
  352. #endif
  353. /* [in] */ BSTR SrcResource,
  354. /* [in] */ long Width,
  355. /* [in] */ long Height,
  356. /* [in] */ long MipLevels,
  357. /* [in] */ long Usage,
  358. /* [in] */ long PixelFormat,
  359. /* [in] */ long Pool,
  360. /* [in] */ long Filter,
  361. /* [in] */ long MipFilter,
  362. /* [in] */ long ColorKey,
  363. /* [in] */ void *SrcInfo,
  364. /* [in] */ void *Palette,
  365. /* [retval][out] */ IUnknown **ppTexture)
  366. {
  367. HRESULT hr;
  368. hr=::D3DXCreateTextureFromResourceExW(
  369. (IDirect3DDevice8*) Device,
  370. (HMODULE) hSrcModule,
  371. (WCHAR*) SrcResource,
  372. (UINT) Width,
  373. (UINT) Height,
  374. (UINT) MipLevels,
  375. (DWORD) Usage,
  376. (D3DFORMAT) PixelFormat,
  377. (D3DPOOL) Pool,
  378. (DWORD) Filter,
  379. (DWORD) MipFilter,
  380. (D3DCOLOR) ColorKey,
  381. (D3DXIMAGE_INFO*) SrcInfo,
  382. (PALETTEENTRY*) Palette,
  383. (LPDIRECT3DTEXTURE8*) ppTexture);
  384. return hr;
  385. }
  386. STDMETHODIMP C_dxj_D3DX8Object::CreateTextureFromFile(
  387. /* [in] */ IUnknown *Device,
  388. /* [in] */ BSTR SrcFile,
  389. /* [retval][out] */ IUnknown **ppTexture)
  390. {
  391. HRESULT hr;
  392. hr=::D3DXCreateTextureFromFileW(
  393. (IDirect3DDevice8*) Device,
  394. (WCHAR*) SrcFile,
  395. (IDirect3DTexture8**) ppTexture);
  396. return hr;
  397. }
  398. STDMETHODIMP C_dxj_D3DX8Object::CreateTextureFromFileEx(
  399. /* [in] */ IUnknown *Device,
  400. /* [in] */ BSTR SrcFile,
  401. /* [in] */ long Width,
  402. /* [in] */ long Height,
  403. /* [in] */ long MipLevels,
  404. /* [in] */ long Usage,
  405. /* [in] */ long PixelFormat,
  406. /* [in] */ long Pool,
  407. /* [in] */ long Filter,
  408. /* [in] */ long MipFilter,
  409. long ColorKey,
  410. /* [in] */ void *SrcInfo,
  411. /* [in] */ void*Palette,
  412. /* [retval][out] */ IUnknown **ppTexture)
  413. {
  414. HRESULT hr;
  415. hr=::D3DXCreateTextureFromFileExW(
  416. (IDirect3DDevice8*) Device,
  417. (WCHAR*) SrcFile,
  418. (DWORD) Width,
  419. (DWORD) Height,
  420. (DWORD) MipLevels,
  421. (DWORD) Usage,
  422. (D3DFORMAT) PixelFormat,
  423. (D3DPOOL) Pool,
  424. (DWORD) Filter,
  425. (DWORD) MipFilter,
  426. (D3DCOLOR) ColorKey,
  427. (D3DXIMAGE_INFO*) SrcInfo,
  428. (PALETTEENTRY*) Palette,
  429. (IDirect3DTexture8**) ppTexture);
  430. return hr;
  431. }
  432. STDMETHODIMP C_dxj_D3DX8Object::CreateTextureFromFileInMemory(
  433. /* [in] */ IUnknown *Device,
  434. /* [in] */ void *SrcData,
  435. /* [in] */ long LengthInBytes,
  436. /* [retval][out] */ IUnknown **ppTexture)
  437. {
  438. HRESULT hr;
  439. hr=::D3DXCreateTextureFromFileInMemory(
  440. (IDirect3DDevice8*) Device,
  441. (void*) SrcData,
  442. (DWORD) LengthInBytes,
  443. (IDirect3DTexture8**) ppTexture);
  444. return hr;
  445. }
  446. STDMETHODIMP C_dxj_D3DX8Object::CreateTextureFromFileInMemoryEx(
  447. /* [in] */ IUnknown *Device,
  448. /* [in] */ void *SrcData,
  449. /* [in] */ long LengthInBytes,
  450. /* [in] */ long Width,
  451. /* [in] */ long Height,
  452. /* [in] */ long MipLevels,
  453. /* [in] */ long Usage,
  454. /* [in] */ long PixelFormat,
  455. /* [in] */ long Pool,
  456. /* [in] */ long Filter,
  457. /* [in] */ long MipFilter,
  458. /* [in] */ long ColorKey,
  459. /* [in] */ void *SrcInfo,
  460. /* [in] */ void *Palette,
  461. /* [retval][out] */ IUnknown **ppTexture)
  462. {
  463. HRESULT hr;
  464. hr=::D3DXCreateTextureFromFileInMemoryEx(
  465. (IDirect3DDevice8*) Device,
  466. SrcData,
  467. (DWORD) LengthInBytes,
  468. (DWORD) Width,
  469. (DWORD) Height,
  470. (DWORD) MipLevels,
  471. (DWORD) Usage,
  472. (D3DFORMAT) PixelFormat,
  473. (D3DPOOL) Pool,
  474. (DWORD) Filter,
  475. (DWORD) MipFilter,
  476. (D3DCOLOR) ColorKey,
  477. (D3DXIMAGE_INFO*) SrcInfo,
  478. (PALETTEENTRY*) Palette,
  479. (IDirect3DTexture8**) ppTexture);
  480. return hr;
  481. }
  482. STDMETHODIMP C_dxj_D3DX8Object::FilterTexture(
  483. /* [in] */ IUnknown *Texture,
  484. /* [in] */ void *Palette,
  485. /* [in] */ long SrcLevel,
  486. /* [in] */ long Filter)
  487. {
  488. HRESULT hr;
  489. hr =::D3DXFilterTexture(
  490. (IDirect3DTexture8*) Texture,
  491. (PALETTEENTRY*) Palette,
  492. (UINT) SrcLevel,
  493. (DWORD) Filter);
  494. return hr;
  495. }
  496. /************************************************/
  497. STDMETHODIMP C_dxj_D3DX8Object::CheckCubeTextureRequirements(
  498. /* [out][in] */ IUnknown *Device,
  499. /* [out][in] */ long *Size,
  500. /* [out][in] */ long *NumMipLevels,
  501. long Usage,
  502. /* [out][in] */ long *pPixelFormat,
  503. long Pool)
  504. {
  505. HRESULT hr;
  506. hr=::D3DXCheckCubeTextureRequirements(
  507. (IDirect3DDevice8*) Device,
  508. (UINT*) Size,
  509. (UINT*) NumMipLevels,
  510. (DWORD) Usage,
  511. (D3DFORMAT*) pPixelFormat,
  512. (D3DPOOL)Pool);
  513. return hr;
  514. }
  515. STDMETHODIMP C_dxj_D3DX8Object::CreateCubeTexture(
  516. /* [in] */ IUnknown *Device,
  517. /* [in] */ long Size,
  518. /* [in] */ long MipLevels,
  519. /* [in] */ long Usage,
  520. /* [in] */ long PixelFormat,
  521. /* [in] */ long Pool,
  522. /* [retval][out] */ IUnknown **ppCubeTexture)
  523. {
  524. HRESULT hr;
  525. hr=::D3DXCreateCubeTexture(
  526. (IDirect3DDevice8*) Device,
  527. (DWORD) Size,
  528. (DWORD) MipLevels,
  529. (DWORD) Usage,
  530. (D3DFORMAT) PixelFormat,
  531. (D3DPOOL) Pool,
  532. (IDirect3DCubeTexture8**) ppCubeTexture);
  533. return hr;
  534. }
  535. STDMETHODIMP C_dxj_D3DX8Object::CreateCubeTextureFromFile(
  536. /* [in] */ IUnknown *Device,
  537. /* [in] */ BSTR SrcFile,
  538. /* [retval][out] */ IUnknown **ppCubeTexture)
  539. {
  540. HRESULT hr;
  541. hr=::D3DXCreateCubeTextureFromFileW(
  542. (IDirect3DDevice8*) Device,
  543. (WCHAR*) SrcFile,
  544. (IDirect3DCubeTexture8**) ppCubeTexture);
  545. return hr;
  546. }
  547. STDMETHODIMP C_dxj_D3DX8Object::CreateCubeTextureFromFileEx(
  548. /* [in] */ IUnknown *Device,
  549. /* [in] */ BSTR SrcFile,
  550. /* [in] */ long Width,
  551. /* [in] */ long MipLevels,
  552. /* [in] */ long Usage,
  553. /* [in] */ long PixelFormat,
  554. /* [in] */ long Pool,
  555. /* [in] */ long Filter,
  556. /* [in] */ long MipFilter,
  557. /* [in] */ long ColorKey,
  558. /* [in] */ void *SrcInfo,
  559. /* [in] */ void*Palette,
  560. /* [retval][out] */ IUnknown **ppCubeTexture)
  561. {
  562. HRESULT hr;
  563. hr=::D3DXCreateCubeTextureFromFileExW(
  564. (IDirect3DDevice8*) Device,
  565. (WCHAR*) SrcFile,
  566. (DWORD) Width,
  567. (DWORD) MipLevels,
  568. (DWORD) Usage,
  569. (D3DFORMAT) PixelFormat,
  570. (D3DPOOL) Pool,
  571. (DWORD) Filter,
  572. (DWORD) MipFilter,
  573. (D3DCOLOR) ColorKey,
  574. (D3DXIMAGE_INFO*) SrcInfo,
  575. (PALETTEENTRY*) Palette,
  576. (IDirect3DCubeTexture8**) ppCubeTexture);
  577. return hr;
  578. }
  579. STDMETHODIMP C_dxj_D3DX8Object::CreateCubeTextureFromFileInMemory(
  580. /* [in] */ IUnknown *Device,
  581. /* [in] */ void *SrcData,
  582. /* [in] */ long LengthInBytes,
  583. /* [retval][out] */ IUnknown **ppCubeTexture)
  584. {
  585. HRESULT hr;
  586. hr=::D3DXCreateCubeTextureFromFileInMemory(
  587. (IDirect3DDevice8*) Device,
  588. SrcData,
  589. (DWORD) LengthInBytes,
  590. (IDirect3DCubeTexture8**) ppCubeTexture);
  591. return hr;
  592. }
  593. STDMETHODIMP C_dxj_D3DX8Object::CreateCubeTextureFromFileInMemoryEx(
  594. /* [in] */ IUnknown *Device,
  595. /* [in] */ void *SrcData,
  596. /* [in] */ long LengthInBytes,
  597. /* [in] */ long Width,
  598. /* [in] */ long MipLevels,
  599. /* [in] */ long Usage,
  600. /* [in] */ long PixelFormat,
  601. /* [in] */ long Pool,
  602. /* [in] */ long Filter,
  603. /* [in] */ long MipFilter,
  604. /* [in] */ long ColorKey,
  605. /* [in] */ void *SrcInfo,
  606. /* [in] */ void *Palette,
  607. /* [retval][out] */ IUnknown **ppCubeTexture)
  608. {
  609. HRESULT hr;
  610. hr=::D3DXCreateCubeTextureFromFileInMemoryEx(
  611. (IDirect3DDevice8*) Device,
  612. SrcData,
  613. (DWORD) LengthInBytes,
  614. (DWORD) Width,
  615. (DWORD) MipLevels,
  616. (DWORD) Usage,
  617. (D3DFORMAT) PixelFormat,
  618. (D3DPOOL) Pool,
  619. (DWORD) Filter,
  620. (DWORD) MipFilter,
  621. (D3DCOLOR) ColorKey,
  622. (D3DXIMAGE_INFO*) SrcInfo,
  623. (PALETTEENTRY*) Palette,
  624. (IDirect3DCubeTexture8**) ppCubeTexture);
  625. return hr;
  626. }
  627. STDMETHODIMP C_dxj_D3DX8Object::FilterCubeTexture(
  628. /* [in] */ IUnknown *CubeTexture,
  629. /* [in] */ void *Palette,
  630. /* [in] */ long SrcLevel,
  631. /* [in] */ long Filter)
  632. {
  633. HRESULT hr;
  634. hr =::D3DXFilterCubeTexture(
  635. (IDirect3DCubeTexture8*) CubeTexture,
  636. (PALETTEENTRY*) Palette,
  637. (UINT) SrcLevel,
  638. (DWORD) Filter);
  639. return hr;
  640. }
  641. STDMETHODIMP C_dxj_D3DX8Object::CheckVolumeTextureRequirements(
  642. IUnknown *Device,
  643. long* Width,
  644. long* Height,
  645. long* Depth,
  646. long* NumMipLevels,
  647. long Usage,
  648. long* Format,
  649. long Pool)
  650. {
  651. HRESULT hr;
  652. hr=::D3DXCheckVolumeTextureRequirements(
  653. (IDirect3DDevice8*) Device,
  654. (UINT*) Width, (UINT*) Height, (UINT*) Depth,
  655. (UINT*) NumMipLevels,
  656. (DWORD) Usage,
  657. (D3DFORMAT*)Format,
  658. (D3DPOOL) Pool);
  659. return hr;
  660. }
  661. STDMETHODIMP C_dxj_D3DX8Object::CreateVolumeTexture(
  662. IUnknown *Device,
  663. long Width,
  664. long Height,
  665. long Depth,
  666. long MipLevels,
  667. long Usage,
  668. long PixelFormat,
  669. long Pool,
  670. IUnknown **ppVolumeTexture)
  671. {
  672. HRESULT hr;
  673. hr=::D3DXCreateVolumeTexture(
  674. (IDirect3DDevice8*) Device,
  675. (UINT) Width,
  676. (UINT) Height,
  677. (UINT) Depth,
  678. (UINT) MipLevels,
  679. (DWORD) Usage,
  680. (D3DFORMAT) PixelFormat,
  681. (D3DPOOL) Pool,
  682. (LPDIRECT3DVOLUMETEXTURE8*) ppVolumeTexture);
  683. return hr;
  684. }
  685. STDMETHODIMP C_dxj_D3DX8Object::FilterVolumeTexture(
  686. IUnknown *pVolumeTexture,
  687. void *pPalette,
  688. long SrcLevel,
  689. long Filter)
  690. {
  691. HRESULT hr;
  692. hr=::D3DXFilterVolumeTexture(
  693. (LPDIRECT3DVOLUMETEXTURE8) pVolumeTexture,
  694. (PALETTEENTRY*) pPalette,
  695. (UINT) SrcLevel,
  696. (DWORD) Filter);
  697. return hr;
  698. }
  699. STDMETHODIMP C_dxj_D3DX8Object::LoadVolumeFromVolume(
  700. IUnknown *pDestVolume,
  701. void *pDestPalette,
  702. void *pDestBox,
  703. IUnknown *pSrcVolume,
  704. void *pSrcPalette,
  705. void *pSrcBox,
  706. long Filter,
  707. long ColorKey)
  708. {
  709. HRESULT hr;
  710. hr=::D3DXLoadVolumeFromVolume(
  711. (LPDIRECT3DVOLUME8) pDestVolume,
  712. (PALETTEENTRY*) pDestPalette,
  713. (D3DBOX*) pDestBox,
  714. (LPDIRECT3DVOLUME8) pSrcVolume,
  715. (PALETTEENTRY*) pSrcPalette,
  716. (D3DBOX*) pSrcBox,
  717. (DWORD) Filter,
  718. (D3DCOLOR) ColorKey);
  719. return hr;
  720. }
  721. STDMETHODIMP C_dxj_D3DX8Object::LoadVolumeFromMemory(
  722. IUnknown *pDestVolume,
  723. void *pDestPalette,
  724. void *pDestRect,
  725. void *pSrcMemory,
  726. long SrcFormat,
  727. long SrcRowPitch,
  728. long SrcSlicePitch,
  729. void *pSrcPalette,
  730. void *pSrcBox,
  731. long Filter,
  732. long ColorKey)
  733. {
  734. HRESULT hr;
  735. hr=::D3DXLoadVolumeFromMemory(
  736. (LPDIRECT3DVOLUME8) pDestVolume,
  737. (PALETTEENTRY*) pDestPalette,
  738. (D3DBOX*) pDestRect,
  739. (LPVOID) pSrcMemory,
  740. (D3DFORMAT) SrcFormat,
  741. (UINT) SrcRowPitch,
  742. (UINT) SrcSlicePitch,
  743. (PALETTEENTRY*) pSrcPalette,
  744. (D3DBOX*) pSrcBox,
  745. (DWORD) Filter,
  746. (D3DCOLOR) ColorKey);
  747. return hr;
  748. }
  749. STDMETHODIMP C_dxj_D3DX8Object::CreateMesh(
  750. /* [in] */ long numFaces,
  751. /* [in] */ long numVertices,
  752. /* [in] */ long options,
  753. /* [in] */ void *Declaration,
  754. /* [in] */ IUnknown __RPC_FAR *pD3D,
  755. /* [retval][out] */ D3DXMesh __RPC_FAR *__RPC_FAR *ppMesh)
  756. {
  757. HRESULT hr;
  758. hr=::D3DXCreateMesh(
  759. (DWORD) numFaces,
  760. (DWORD) numVertices,
  761. (DWORD) options,
  762. (DWORD*) Declaration,
  763. (LPDIRECT3DDEVICE8)pD3D,
  764. (ID3DXMesh**)ppMesh);
  765. return hr;
  766. }
  767. STDMETHODIMP C_dxj_D3DX8Object::CreateMeshFVF(
  768. /* [in] */ long numFaces,
  769. /* [in] */ long numVertices,
  770. /* [in] */ long options,
  771. /* [in] */ long fvf,
  772. /* [in] */ IUnknown __RPC_FAR *pD3D,
  773. /* [retval][out] */ D3DXMesh __RPC_FAR *__RPC_FAR *ppMesh)
  774. {
  775. HRESULT hr;
  776. hr=::D3DXCreateMeshFVF(
  777. (DWORD) numFaces,
  778. (DWORD) numVertices,
  779. (DWORD) options,
  780. (DWORD) fvf,
  781. (LPDIRECT3DDEVICE8)pD3D,
  782. (ID3DXMesh**)ppMesh);
  783. return hr;
  784. }
  785. STDMETHODIMP C_dxj_D3DX8Object::CreateSPMesh(
  786. /* [in] */ D3DXMesh __RPC_FAR *pMesh,
  787. void* Adjacency,
  788. void* VertexAttributeWeights,
  789. void* VertexWeights,
  790. /* [retval][out] */ D3DXSPMesh __RPC_FAR *__RPC_FAR *ppSMesh)
  791. {
  792. HRESULT hr;
  793. hr=::D3DXCreateSPMesh(
  794. (ID3DXMesh*) pMesh,
  795. (DWORD*) Adjacency,
  796. (LPD3DXATTRIBUTEWEIGHTS) VertexAttributeWeights,
  797. (float *) VertexWeights,
  798. (ID3DXSPMesh**) ppSMesh);
  799. return hr;
  800. }
  801. STDMETHODIMP C_dxj_D3DX8Object::GeneratePMesh(
  802. /* [in] */ D3DXMesh __RPC_FAR *pMesh,
  803. /* [in] */ void* Adjacency,
  804. /* [in] */ void* VertexAttributeWeights,
  805. /* [in] */ void* VertexWeights,
  806. /* [in] */ long minValue,
  807. /* [in] */ long options,
  808. /* [retval][out] */ D3DXPMesh __RPC_FAR *__RPC_FAR *ppPMesh)
  809. {
  810. HRESULT hr;
  811. hr=::D3DXGeneratePMesh(
  812. (ID3DXMesh*) pMesh,
  813. (DWORD*) Adjacency,
  814. (LPD3DXATTRIBUTEWEIGHTS) VertexAttributeWeights,
  815. (float *) VertexWeights,
  816. (DWORD) minValue,
  817. (DWORD) options,
  818. (ID3DXPMesh**)ppPMesh);
  819. return hr;
  820. }
  821. STDMETHODIMP C_dxj_D3DX8Object::SimplifyMesh(
  822. /* [in] */ D3DXMesh __RPC_FAR *pMesh,
  823. void* Adjacency,
  824. void* VertexAttributeWeights,
  825. void* VertexWeights,
  826. long minValue,
  827. long options,
  828. D3DXMesh __RPC_FAR *__RPC_FAR *ppMesh)
  829. {
  830. HRESULT hr;
  831. hr=::D3DXSimplifyMesh(
  832. (ID3DXMesh*) pMesh,
  833. (DWORD*) Adjacency,
  834. (LPD3DXATTRIBUTEWEIGHTS) VertexAttributeWeights,
  835. (float *) VertexWeights,
  836. (DWORD) minValue,
  837. (DWORD) options,
  838. (ID3DXMesh**)ppMesh);
  839. return hr;
  840. }
  841. STDMETHODIMP C_dxj_D3DX8Object::ComputeBoundingSphere(
  842. /* [in] */ void __RPC_FAR *PointsFVF,
  843. /* [in] */ long numVertices,
  844. /* [in] */ long FVF,
  845. /* [in] */ D3DVECTOR_CDESC __RPC_FAR *Centers,
  846. /* [out][in] */ float __RPC_FAR *RadiusArray)
  847. {
  848. HRESULT hr;
  849. hr=::D3DXComputeBoundingSphere(
  850. PointsFVF,
  851. (DWORD) numVertices,
  852. (DWORD) FVF,
  853. (D3DXVECTOR3*) Centers,
  854. RadiusArray);
  855. return hr;
  856. }
  857. STDMETHODIMP C_dxj_D3DX8Object::ComputeBoundingBox(
  858. /* [in] */ void __RPC_FAR *PointsFVF,
  859. /* [in] */ long numVertices,
  860. /* [in] */ long FVF,
  861. /* [out] */ D3DVECTOR_CDESC __RPC_FAR *MinVec,
  862. /* [out] */ D3DVECTOR_CDESC __RPC_FAR *MaxVec)
  863. {
  864. HRESULT hr;
  865. hr=::D3DXComputeBoundingBox(
  866. PointsFVF,
  867. (DWORD) numVertices,
  868. (DWORD) FVF,
  869. (D3DXVECTOR3*) MinVec,
  870. (D3DXVECTOR3*) MaxVec);
  871. return hr;
  872. }
  873. STDMETHODIMP C_dxj_D3DX8Object::ComputeNormals( D3DXBaseMesh *pMesh)
  874. {
  875. HRESULT hr;
  876. hr=::D3DXComputeNormals((ID3DXBaseMesh*)pMesh, NULL);
  877. return hr;
  878. }
  879. STDMETHODIMP C_dxj_D3DX8Object::CreateBuffer(
  880. /* [in] */ long numBytes,
  881. /* [retval][out] */ D3DXBuffer __RPC_FAR *__RPC_FAR *ppBuffer)
  882. {
  883. HRESULT hr;
  884. hr=::D3DXCreateBuffer((DWORD) numBytes,(ID3DXBuffer**) ppBuffer);
  885. return hr;
  886. }
  887. STDMETHODIMP C_dxj_D3DX8Object::LoadMeshFromX(
  888. /* [in] */ BSTR Filename,
  889. /* [in] */ long options,
  890. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  891. /* [out] */ D3DXBuffer __RPC_FAR *__RPC_FAR *retAdjacency,
  892. /* [out] */ D3DXBuffer __RPC_FAR *__RPC_FAR *retMaterials,
  893. /* [out] */ long __RPC_FAR *retMaterialCount,
  894. /* [retval][out] */ D3DXMesh __RPC_FAR *__RPC_FAR *retMesh)
  895. {
  896. USES_CONVERSION;
  897. HRESULT hr;
  898. if (!D3DDevice) return E_INVALIDARG;
  899. char *szName = NULL;
  900. __try { szName=W2T(Filename); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  901. hr=::D3DXLoadMeshFromX(
  902. szName,
  903. (DWORD) options,
  904. (IDirect3DDevice8*) D3DDevice,
  905. (ID3DXBuffer**) retAdjacency,
  906. (ID3DXBuffer**) retMaterials,
  907. (DWORD*) retMaterialCount,
  908. (ID3DXMesh**) retMesh);
  909. return hr;
  910. }
  911. STDMETHODIMP C_dxj_D3DX8Object::SaveMeshToX(
  912. /* [in] */ BSTR Filename,
  913. /* [in] */ D3DXMesh __RPC_FAR *Mesh,
  914. /* [in] */ void *AdjacencyArray,
  915. /* [in] */ D3DXMATERIAL_CDESC __RPC_FAR *MaterialArray,
  916. /* [in] */ long MaterialCount,
  917. /* [in] */ long xFormat)
  918. {
  919. HRESULT hr;
  920. USES_CONVERSION;
  921. char *szName = NULL;
  922. __try { szName=W2T(Filename); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  923. D3DXMATERIAL *pMaterials=NULL;
  924. if (MaterialCount > 0) {
  925. //cleaned up when out of scope
  926. __try { pMaterials=(D3DXMATERIAL*)alloca(sizeof(D3DXMATERIAL)*MaterialCount); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  927. if (!pMaterials) return E_OUTOFMEMORY;
  928. __try
  929. {
  930. for (long i=0; i<MaterialCount; i++)
  931. {
  932. memcpy (&(pMaterials[i].MatD3D), &(MaterialArray[i].MatD3D),sizeof(D3DMATERIAL8));
  933. __try { pMaterials[i].pTextureFilename=W2T(MaterialArray[i].TextureFilename); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  934. }
  935. }
  936. __except(1,1)
  937. {
  938. return E_INVALIDARG;
  939. }
  940. }
  941. hr=::D3DXSaveMeshToX(
  942. szName,
  943. (ID3DXMesh*) Mesh,
  944. (DWORD*) AdjacencyArray,
  945. (D3DXMATERIAL*) pMaterials,
  946. (DWORD) MaterialCount,
  947. (DWORD) xFormat);
  948. return hr;
  949. }
  950. STDMETHODIMP C_dxj_D3DX8Object::SavePMeshToFile(
  951. /* [in] */ BSTR Filename,
  952. /* [in] */ D3DXPMesh __RPC_FAR *Mesh,
  953. /* [in] */ D3DXMATERIAL_CDESC __RPC_FAR *MaterialArray,
  954. /* [in] */ long MaterialCount)
  955. {
  956. HRESULT hr=S_OK;
  957. if (!Filename)
  958. return E_INVALIDARG;
  959. USES_CONVERSION;
  960. char *szName = NULL;
  961. __try { szName=W2T(Filename); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  962. if (!Mesh) return E_INVALIDARG;
  963. IStream *pStream= (IStream*) new CFileStream(szName, FALSE,TRUE,&hr);
  964. if (!pStream) return E_OUTOFMEMORY;
  965. if FAILED(hr) return hr;
  966. __try
  967. {
  968. D3DXMATERIAL *pRealMaterials=NULL;
  969. if (MaterialCount > 0)
  970. {
  971. pRealMaterials= (D3DXMATERIAL *) malloc( sizeof(D3DXMATERIAL) * MaterialCount );
  972. if (!pRealMaterials)
  973. {
  974. pStream->Release();
  975. return E_OUTOFMEMORY;
  976. }
  977. }
  978. for (long i=0;i<MaterialCount;i++)
  979. {
  980. memcpy (&(pRealMaterials[i].MatD3D), &(MaterialArray[i].MatD3D),sizeof (D3DMATERIAL8));
  981. //can be NULL - freed on return as they are allocated locally
  982. __try { pRealMaterials[i].pTextureFilename=W2T(MaterialArray[i].TextureFilename); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  983. }
  984. hr=((ID3DXPMesh*)Mesh)->Save(pStream,pRealMaterials,(DWORD)MaterialCount);
  985. free(pRealMaterials);
  986. }
  987. __except(1,1)
  988. {
  989. pStream->Release();
  990. return E_INVALIDARG;
  991. }
  992. pStream->Release();
  993. return hr;
  994. }
  995. STDMETHODIMP C_dxj_D3DX8Object::LoadPMeshFromFile(
  996. /* [in] */ BSTR Filename,
  997. /* [in] */ long options,
  998. /* [in] */ IUnknown __RPC_FAR *pD3DDevice,
  999. /* [out] */ D3DXBuffer **RetMaterials,
  1000. /* [out] */ long __RPC_FAR *RetNumMaterials,
  1001. /* [retval][out] */ D3DXPMesh __RPC_FAR *__RPC_FAR *RetPMesh)
  1002. {
  1003. HRESULT hr=S_OK;
  1004. USES_CONVERSION;
  1005. if (Filename == NULL)
  1006. return E_INVALIDARG;
  1007. char *szName = NULL;
  1008. __try { szName=W2T(Filename); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  1009. IStream *pStream= (IStream*) new CFileStream(szName, TRUE,FALSE,&hr);
  1010. if (!pStream) return E_OUTOFMEMORY;
  1011. if FAILED(hr)
  1012. {
  1013. pStream->Release();
  1014. return hr;
  1015. }
  1016. hr=D3DXCreatePMeshFromStream(
  1017. pStream,
  1018. (DWORD) options,
  1019. (LPDIRECT3DDEVICE8) pD3DDevice,
  1020. (LPD3DXBUFFER *)RetMaterials,
  1021. (DWORD*) RetNumMaterials,
  1022. (LPD3DXPMESH *) RetPMesh);
  1023. pStream->Release();
  1024. return hr;
  1025. }
  1026. STDMETHODIMP C_dxj_D3DX8Object::LoadMeshFromXof(
  1027. /* [in] */ IUnknown __RPC_FAR *xofobjMesh,
  1028. /* [in] */ long options,
  1029. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1030. /* [out] */ D3DXBuffer __RPC_FAR *__RPC_FAR *retAdjacency,
  1031. /* [out] */ D3DXBuffer __RPC_FAR *__RPC_FAR *retMaterials,
  1032. /* [out] */ long __RPC_FAR *retMaterialCount,
  1033. /* [retval][out] */ D3DXMesh __RPC_FAR *__RPC_FAR *retMesh)
  1034. {
  1035. HRESULT hr=S_OK;
  1036. IDirectXFileData *pRealXFileData=NULL;
  1037. I_dxj_DirectXFileData *pCoverXFileData=NULL;
  1038. if (!xofobjMesh) return E_INVALIDARG;
  1039. hr= xofobjMesh->QueryInterface(IID_IDirectXFileData,(void**)&pRealXFileData);
  1040. if FAILED(hr)
  1041. {
  1042. hr=xofobjMesh->QueryInterface(IID_I_dxj_DirectXFileData,(void**)&pCoverXFileData);
  1043. if FAILED(hr) return hr;
  1044. //beware does not addref but interface cant go away as long as we have
  1045. //ref count on cover object
  1046. hr=pCoverXFileData->InternalGetObject((IUnknown**)&pRealXFileData);
  1047. if (FAILED(hr) || (!pRealXFileData))
  1048. {
  1049. //We should never get here but
  1050. //Consider changing this to an assert
  1051. pCoverXFileData->Release();
  1052. return E_FAIL;
  1053. }
  1054. pRealXFileData->AddRef();
  1055. pCoverXFileData->Release();
  1056. if FAILED(hr) return hr;
  1057. }
  1058. hr=::D3DXLoadMeshFromXof(
  1059. pRealXFileData,
  1060. (DWORD) options,
  1061. (IDirect3DDevice8*) D3DDevice,
  1062. (ID3DXBuffer**) retAdjacency,
  1063. (ID3DXBuffer**) retMaterials,
  1064. (DWORD*) retMaterialCount,
  1065. (ID3DXMesh**) retMesh);
  1066. return hr;
  1067. }
  1068. STDMETHODIMP C_dxj_D3DX8Object::TessellateNPatches(
  1069. /* [in] */ D3DXMesh __RPC_FAR *MeshIn,
  1070. /* [in] */ void*Adjacency,
  1071. /* [in] */ float NumSegs,
  1072. VARIANT_BOOL QuadraticInterpNormals,
  1073. /*[in,out, optional] */ D3DXBuffer **AdjacencyOut,
  1074. /* [retval][out] */ D3DXMesh __RPC_FAR *__RPC_FAR *pptmMeshOut)
  1075. {
  1076. HRESULT hr;
  1077. BOOL bQuadraticInterpNormals=QuadraticInterpNormals ? TRUE : FALSE;
  1078. hr=::D3DXTessellateNPatches(
  1079. (ID3DXMesh*) MeshIn,
  1080. (DWORD*) Adjacency,
  1081. (float) NumSegs,
  1082. bQuadraticInterpNormals,
  1083. (ID3DXMesh**)pptmMeshOut,
  1084. (ID3DXBuffer**)AdjacencyOut);
  1085. return hr;
  1086. }
  1087. STDMETHODIMP C_dxj_D3DX8Object::DeclaratorFromFVF(
  1088. long FVF,
  1089. D3DXDECLARATOR_CDESC *Declarator)
  1090. {
  1091. HRESULT hr;
  1092. hr=::D3DXDeclaratorFromFVF(
  1093. (DWORD) FVF,
  1094. (DWORD*) Declarator);
  1095. return hr;
  1096. }
  1097. STDMETHODIMP C_dxj_D3DX8Object::FVFFromDeclarator(
  1098. D3DXDECLARATOR_CDESC *Declarator,
  1099. long *FVF)
  1100. {
  1101. HRESULT hr;
  1102. hr=::D3DXFVFFromDeclarator(
  1103. (DWORD*) Declarator,
  1104. (DWORD*) FVF);
  1105. return hr;
  1106. }
  1107. STDMETHODIMP C_dxj_D3DX8Object::BufferGetMaterial(
  1108. /* [in] */ D3DXBuffer __RPC_FAR *MaterialBuffer,
  1109. /* [in] */ long index,
  1110. /* [retval][out] */ D3DMATERIAL8_CDESC __RPC_FAR *mat)
  1111. {
  1112. if (!MaterialBuffer) return E_INVALIDARG;
  1113. D3DXMATERIAL *pMatArray=(D3DXMATERIAL*) ((ID3DXBuffer*)MaterialBuffer)->GetBufferPointer();
  1114. __try {
  1115. memcpy(mat,&(pMatArray[index].MatD3D),sizeof(D3DMATERIAL8));
  1116. }
  1117. __except(1,1){
  1118. return E_INVALIDARG;
  1119. }
  1120. return S_OK;
  1121. }
  1122. STDMETHODIMP C_dxj_D3DX8Object::BufferGetTextureName(
  1123. /* [in] */ D3DXBuffer __RPC_FAR *MaterialBuffer,
  1124. /* [in] */ long index,
  1125. /* [retval][out] */ BSTR __RPC_FAR *retName)
  1126. {
  1127. USES_CONVERSION;
  1128. WCHAR *wszName=NULL;
  1129. if (!MaterialBuffer) return E_INVALIDARG;
  1130. D3DXMATERIAL *pMatArray=(D3DXMATERIAL*)((ID3DXBuffer*)MaterialBuffer)->GetBufferPointer();
  1131. __try {
  1132. wszName=T2W(pMatArray[index].pTextureFilename);
  1133. }
  1134. __except(1,1){
  1135. return E_INVALIDARG;
  1136. }
  1137. *retName=SysAllocString(wszName);
  1138. return S_OK;
  1139. }
  1140. STDMETHODIMP C_dxj_D3DX8Object::BufferGetBoneName(
  1141. /* [in] */ D3DXBuffer __RPC_FAR *BoneNameBuffer,
  1142. /* [in] */ long index,
  1143. /* [retval][out] */ BSTR __RPC_FAR *retName)
  1144. {
  1145. USES_CONVERSION;
  1146. WCHAR *wszName=NULL;
  1147. if (!BoneNameBuffer) return E_INVALIDARG;
  1148. char **ppArray=(char**)((ID3DXBuffer*)BoneNameBuffer)->GetBufferPointer();
  1149. __try {
  1150. wszName=T2W(ppArray[index]);
  1151. }
  1152. __except(1,1){
  1153. return E_INVALIDARG;
  1154. }
  1155. *retName=SysAllocString(wszName);
  1156. return S_OK;
  1157. }
  1158. STDMETHODIMP C_dxj_D3DX8Object::BufferGetData(
  1159. /* [in] */ D3DXBuffer __RPC_FAR *Buffer,
  1160. /* [in] */ long index,
  1161. /* [in] */ long typesize,
  1162. /* [in] */ long typecount,
  1163. /* [out][in] */ void __RPC_FAR *data)
  1164. {
  1165. if (!Buffer) return E_INVALIDARG;
  1166. char *pData=(char*)((ID3DXBuffer*)Buffer)->GetBufferPointer();
  1167. DWORD dwStart= (DWORD) index*typesize;
  1168. DWORD dwCount= (DWORD) typecount*typesize;
  1169. __try {
  1170. memcpy(data,&(pData[dwStart]),dwCount);
  1171. }
  1172. __except(1,1){
  1173. return E_INVALIDARG;
  1174. }
  1175. return S_OK;
  1176. }
  1177. STDMETHODIMP C_dxj_D3DX8Object:: BufferGetBoneCombo(
  1178. D3DXBuffer *Buffer,
  1179. long index,
  1180. D3DXBONECOMBINATION_CDESC *desc)
  1181. {
  1182. if (!Buffer) return E_INVALIDARG;
  1183. D3DXBONECOMBINATION_CDESC *pData=(D3DXBONECOMBINATION_CDESC*)((ID3DXBuffer*)Buffer)->GetBufferPointer();
  1184. __try {
  1185. memcpy(desc,&(pData[index]),sizeof (D3DXBONECOMBINATION_CDESC));
  1186. }
  1187. __except(1,1){
  1188. return E_INVALIDARG;
  1189. }
  1190. return S_OK;
  1191. }
  1192. STDMETHODIMP C_dxj_D3DX8Object::BufferGetBoneComboBoneIds(
  1193. D3DXBuffer *Buffer,
  1194. long index,
  1195. long PaletteSize,
  1196. void *BoneIds)
  1197. {
  1198. if (!Buffer) return E_INVALIDARG;
  1199. if (PaletteSize <=0) return E_INVALIDARG;
  1200. D3DXBONECOMBINATION *pData=(D3DXBONECOMBINATION*)((ID3DXBuffer*)Buffer)->GetBufferPointer();
  1201. __try {
  1202. memcpy(BoneIds,pData[index].BoneId,PaletteSize*sizeof(DWORD));
  1203. }
  1204. __except(1,1){
  1205. return E_INVALIDARG;
  1206. }
  1207. return S_OK;
  1208. }
  1209. STDMETHODIMP C_dxj_D3DX8Object::BufferSetData(
  1210. /* [in] */ D3DXBuffer __RPC_FAR *Buffer,
  1211. /* [in] */ long index,
  1212. /* [in] */ long typesize,
  1213. /* [in] */ long typecount,
  1214. /* [out][in] */ void __RPC_FAR *data)
  1215. {
  1216. if (!Buffer) return E_INVALIDARG;
  1217. char *pData=(char*)((ID3DXBuffer*)Buffer)->GetBufferPointer();
  1218. DWORD dwStart= (DWORD) index*typesize;
  1219. DWORD dwCount= (DWORD) typecount*typesize;
  1220. __try {
  1221. memcpy(&(pData[dwStart]),data,dwCount);
  1222. }
  1223. __except(1,1){
  1224. return E_INVALIDARG;
  1225. }
  1226. return S_OK;
  1227. }
  1228. STDMETHODIMP C_dxj_D3DX8Object::Intersect(
  1229. /* [in] */ D3DXMesh *MeshIn,
  1230. /* [in] */ D3DVECTOR_CDESC *RayPos,
  1231. /* [in] */ D3DVECTOR_CDESC *RayDir,
  1232. /* [out] */ LONG *retHit,
  1233. /* [out] */ LONG *retFaceIndex,
  1234. /* [out] */ FLOAT *U,
  1235. /* [out] */ FLOAT *V,
  1236. /* [out] */ FLOAT *retDist,
  1237. /* [out] */ LONG *countHits,
  1238. /* [retval][out] */ D3DXBuffer **AllHits)
  1239. {
  1240. HRESULT hr;
  1241. hr=D3DXIntersect(
  1242. (LPD3DXMESH) MeshIn,
  1243. (D3DXVECTOR3*) RayPos,
  1244. (D3DXVECTOR3*) RayDir,
  1245. (BOOL *) retHit,
  1246. (DWORD*) retFaceIndex,
  1247. (float*) U,
  1248. (float*) V,
  1249. (float*) retDist,
  1250. (LPD3DXBUFFER*) AllHits,
  1251. (DWORD*)countHits);
  1252. return hr;
  1253. }
  1254. STDMETHODIMP C_dxj_D3DX8Object::SphereBoundProbe(
  1255. D3DVECTOR_CDESC *Center,
  1256. float Radius,
  1257. D3DVECTOR_CDESC *RayPosition,
  1258. D3DVECTOR_CDESC *RayDirection,
  1259. VARIANT_BOOL *retHit)
  1260. {
  1261. BOOL bRet=FALSE;
  1262. bRet=D3DXSphereBoundProbe(
  1263. (D3DXVECTOR3 *) Center,
  1264. Radius,
  1265. (D3DXVECTOR3 *) RayPosition,
  1266. (D3DXVECTOR3 *) RayDirection);
  1267. if (bRet)
  1268. {
  1269. *retHit=VARIANT_TRUE;
  1270. }
  1271. else
  1272. {
  1273. *retHit=VARIANT_FALSE;
  1274. }
  1275. return S_OK;
  1276. }
  1277. STDMETHODIMP C_dxj_D3DX8Object::ComputeBoundingSphereFromMesh(
  1278. /*[in]*/ D3DXMesh *MeshIn,
  1279. /*[in]*/ D3DVECTOR_CDESC *Centers,
  1280. /*[in,out]*/ float *RadiusArray)
  1281. {
  1282. HRESULT hr;
  1283. BYTE *pPointsFVF=NULL;
  1284. if (!MeshIn) return E_INVALIDARG;
  1285. DWORD dwFVF= ((LPD3DXMESH)MeshIn)->GetFVF();
  1286. DWORD dwVertices= ((LPD3DXMESH)MeshIn)->GetNumVertices();
  1287. hr=((LPD3DXMESH)MeshIn)->LockVertexBuffer(0,&pPointsFVF);
  1288. if FAILED(hr) return hr;
  1289. hr=::D3DXComputeBoundingSphere(
  1290. pPointsFVF,
  1291. dwVertices,
  1292. dwFVF,
  1293. (D3DXVECTOR3*) Centers,
  1294. RadiusArray);
  1295. ((LPD3DXMESH)MeshIn)->UnlockVertexBuffer();
  1296. return hr;
  1297. }
  1298. STDMETHODIMP C_dxj_D3DX8Object::ComputeBoundingBoxFromMesh(
  1299. /*[in]*/ D3DXMesh *MeshIn,
  1300. /*[in,out]*/ D3DVECTOR_CDESC *MinArray,
  1301. /*[in,out]*/ D3DVECTOR_CDESC *MaxArray)
  1302. {
  1303. HRESULT hr;
  1304. BYTE *pPointsFVF=NULL;
  1305. if (!MeshIn) return E_INVALIDARG;
  1306. DWORD dwFVF= ((LPD3DXMESH)MeshIn)->GetFVF();
  1307. DWORD dwVertices= ((LPD3DXMESH)MeshIn)->GetNumVertices();
  1308. hr=((LPD3DXMESH)MeshIn)->LockVertexBuffer(0,&pPointsFVF);
  1309. if FAILED(hr) return hr;
  1310. hr=::D3DXComputeBoundingBox(
  1311. pPointsFVF,
  1312. dwVertices,
  1313. dwFVF,
  1314. (D3DXVECTOR3*) MinArray,
  1315. (D3DXVECTOR3*) MaxArray);
  1316. ((LPD3DXMESH)MeshIn)->UnlockVertexBuffer();
  1317. return hr;
  1318. }
  1319. STDMETHODIMP C_dxj_D3DX8Object::CreateSkinMesh(
  1320. /* [in] */ long numFaces,
  1321. /* [in] */ long numVertices,
  1322. /* [in] */ long numBones,
  1323. /* [in] */ long options,
  1324. /* [in] */ void __RPC_FAR *Declaration,
  1325. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1326. /* [retval][out] */ D3DXSkinMesh __RPC_FAR *__RPC_FAR *SkinMesh)
  1327. {
  1328. HRESULT hr;
  1329. hr=::D3DXCreateSkinMesh((DWORD) numFaces,(DWORD)numVertices,
  1330. (DWORD)numBones,(DWORD)options,
  1331. (DWORD *)Declaration,(IDirect3DDevice8*) D3DDevice,
  1332. (ID3DXSkinMesh**) SkinMesh);
  1333. return hr;
  1334. }
  1335. STDMETHODIMP C_dxj_D3DX8Object::CreateSkinMeshFVF(
  1336. /* [in] */ long numFaces,
  1337. /* [in] */ long numVertices,
  1338. /* [in] */ long numBones,
  1339. /* [in] */ long options,
  1340. /* [in] */ long fvf,
  1341. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1342. D3DXSkinMesh __RPC_FAR *__RPC_FAR *SkinMeshRet)
  1343. {
  1344. HRESULT hr;
  1345. hr =::D3DXCreateSkinMeshFVF((DWORD)numFaces,(DWORD)numVertices,(DWORD)numBones,
  1346. (DWORD)options,(DWORD)fvf,(IDirect3DDevice8*)D3DDevice,
  1347. (ID3DXSkinMesh**) SkinMeshRet);
  1348. return hr;
  1349. }
  1350. STDMETHODIMP C_dxj_D3DX8Object::CreateSkinMeshFromMesh(
  1351. /* [in] */ D3DXMesh __RPC_FAR *Mesh,
  1352. /* [in] */ long numBones,
  1353. /* [retval][out] */ D3DXSkinMesh __RPC_FAR *__RPC_FAR *SkinMeshRet)
  1354. {
  1355. HRESULT hr;
  1356. if (!Mesh)
  1357. return E_INVALIDARG;
  1358. hr=::D3DXCreateSkinMeshFromMesh((ID3DXMesh*) Mesh,(DWORD)numBones,(ID3DXSkinMesh**) SkinMeshRet);
  1359. return hr;
  1360. }
  1361. STDMETHODIMP C_dxj_D3DX8Object::LoadSkinMeshFromXof(
  1362. /* [in] */ IUnknown *xofobjMesh,
  1363. /* [in] */ long options,
  1364. /* [in] */ IUnknown *D3DDevice,
  1365. /* [out][in] */ D3DXBuffer **RetAdjacency,
  1366. /* [out][in] */ D3DXBuffer **RetMaterials,
  1367. /* [out][in] */ long *RetMaterialCount,
  1368. /* [out][in] */ D3DXBuffer **RetBoneNames,
  1369. /* [out][in] */ D3DXBuffer **RetBoneTransforms,
  1370. /* [retval][out] */ D3DXSkinMesh **RetMesh)
  1371. {
  1372. HRESULT hr=S_OK;
  1373. IDirectXFileData *pRealXFileData=NULL;
  1374. I_dxj_DirectXFileData *pCoverXFileData=NULL;
  1375. if (!xofobjMesh) return E_INVALIDARG;
  1376. hr= xofobjMesh->QueryInterface(IID_IDirectXFileData,(void**)&pRealXFileData);
  1377. if FAILED(hr)
  1378. {
  1379. hr=xofobjMesh->QueryInterface(IID_I_dxj_DirectXFileData,(void**)&pCoverXFileData);
  1380. if FAILED(hr) return hr;
  1381. //beware does not addref but interface cant go away as long as we have
  1382. //ref count on cover object
  1383. hr=pCoverXFileData->InternalGetObject((IUnknown**)&pRealXFileData);
  1384. if (FAILED(hr) || (!pRealXFileData))
  1385. {
  1386. //We should never get here but
  1387. //Consider changing this to an assert
  1388. pCoverXFileData->Release();
  1389. return E_FAIL;
  1390. }
  1391. pRealXFileData->AddRef();
  1392. pCoverXFileData->Release();
  1393. if FAILED(hr) return hr;
  1394. }
  1395. hr=::D3DXLoadSkinMeshFromXof(
  1396. pRealXFileData,
  1397. (DWORD) options,
  1398. (IDirect3DDevice8*) D3DDevice,
  1399. (ID3DXBuffer**) RetAdjacency,
  1400. (ID3DXBuffer**) RetMaterials,
  1401. (DWORD*) RetMaterialCount,
  1402. (ID3DXBuffer**) RetBoneNames,
  1403. (ID3DXBuffer**) RetBoneTransforms,
  1404. (ID3DXSkinMesh**) RetMesh);
  1405. return hr;
  1406. }
  1407. STDMETHODIMP C_dxj_D3DX8Object::CreatePolygon(
  1408. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1409. /* [in] */ float Length,
  1410. /* [in] */ long Sides,
  1411. /* [out][in] */ D3DXBuffer **retAdjacency,
  1412. /* [retval][out] */ D3DXMesh **RetMesh)
  1413. {
  1414. HRESULT hr;
  1415. hr=D3DXCreatePolygon(
  1416. (IDirect3DDevice8*) D3DDevice,
  1417. Length,
  1418. (UINT) Sides,
  1419. (ID3DXMesh**)RetMesh,
  1420. (ID3DXBuffer**)retAdjacency);
  1421. return hr;
  1422. }
  1423. STDMETHODIMP C_dxj_D3DX8Object::CreateBox(
  1424. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1425. /* [in] */ float Width,
  1426. /* [in] */ float Height,
  1427. /* [in] */ float Depth,
  1428. /* [out][in] */ D3DXBuffer __RPC_FAR *__RPC_FAR *retAdjacency,
  1429. /* [retval][out] */ D3DXMesh __RPC_FAR *__RPC_FAR *RetMesh)
  1430. {
  1431. HRESULT hr;
  1432. hr=D3DXCreateBox(
  1433. (IDirect3DDevice8*) D3DDevice,
  1434. Width,
  1435. Height,
  1436. Depth,
  1437. (ID3DXMesh**)RetMesh,
  1438. (ID3DXBuffer**)retAdjacency);
  1439. return hr;
  1440. }
  1441. STDMETHODIMP C_dxj_D3DX8Object::CreateCylinder(
  1442. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1443. /* [in] */ float Radius1,
  1444. /* [in] */ float Radius2,
  1445. /* [in] */ float Length,
  1446. /* [in] */ long Slices,
  1447. /* [in] */ long Stacks,
  1448. /* [out][in] */ D3DXBuffer __RPC_FAR *__RPC_FAR *retAdjacency,
  1449. /* [retval][out] */ D3DXMesh __RPC_FAR *__RPC_FAR *RetMesh)
  1450. {
  1451. HRESULT hr;
  1452. hr=D3DXCreateCylinder(
  1453. (IDirect3DDevice8*) D3DDevice,
  1454. Radius1,
  1455. Radius2,
  1456. Length,
  1457. (UINT)Slices,
  1458. (UINT)Stacks,
  1459. (ID3DXMesh**)RetMesh,
  1460. (ID3DXBuffer**)retAdjacency);
  1461. return hr;
  1462. }
  1463. STDMETHODIMP C_dxj_D3DX8Object::CreateSphere(
  1464. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1465. /* [in] */ float Radius,
  1466. /* [in] */ long Slices,
  1467. /* [in] */ long Stacks,
  1468. /* [out][in] */ D3DXBuffer __RPC_FAR *__RPC_FAR *retAdjacency,
  1469. /* [retval][out] */ D3DXMesh __RPC_FAR *__RPC_FAR *RetMesh)
  1470. {
  1471. HRESULT hr;
  1472. hr=D3DXCreateSphere(
  1473. (IDirect3DDevice8*) D3DDevice,
  1474. Radius,
  1475. (UINT)Slices,
  1476. (UINT)Stacks,
  1477. (ID3DXMesh**)RetMesh,
  1478. (ID3DXBuffer**)retAdjacency);
  1479. return hr;
  1480. }
  1481. STDMETHODIMP C_dxj_D3DX8Object::CreateTorus(
  1482. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1483. /* [in] */ float InnerRadius,
  1484. /* [in] */ float OuterRadius,
  1485. /* [in] */ long Sides,
  1486. /* [in] */ long Rings,
  1487. /* [out][in] */ D3DXBuffer __RPC_FAR *__RPC_FAR *retAdjacency,
  1488. /* [retval][out] */ D3DXMesh __RPC_FAR *__RPC_FAR *RetMesh)
  1489. {
  1490. HRESULT hr;
  1491. hr=D3DXCreateTorus(
  1492. (IDirect3DDevice8*) D3DDevice,
  1493. InnerRadius,
  1494. OuterRadius,
  1495. (UINT)Sides,
  1496. (UINT)Rings,
  1497. (ID3DXMesh**)RetMesh,
  1498. (ID3DXBuffer**)retAdjacency);
  1499. return hr;
  1500. }
  1501. STDMETHODIMP C_dxj_D3DX8Object::CreateTeapot(
  1502. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1503. /* [out][in] */ D3DXBuffer __RPC_FAR *__RPC_FAR *retAdjacency,
  1504. /* [retval][out] */ D3DXMesh __RPC_FAR *__RPC_FAR *RetMesh)
  1505. {
  1506. HRESULT hr;
  1507. hr=D3DXCreateTeapot(
  1508. (IDirect3DDevice8*) D3DDevice,
  1509. (ID3DXMesh**)RetMesh,
  1510. (ID3DXBuffer**)retAdjacency);
  1511. return hr;
  1512. }
  1513. STDMETHODIMP C_dxj_D3DX8Object::CreateText(
  1514. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1515. /* [in] */ HDC hDC,
  1516. /* [in] */ BSTR Text,
  1517. /* [in] */ float Deviation,
  1518. /* [in] */ float Extrusion,
  1519. /* [out][in] */ D3DXMesh __RPC_FAR *__RPC_FAR *RetMesh,
  1520. /* [in,out] */ D3DXBuffer **AdjacencyOut,
  1521. /* [out][in] */ void __RPC_FAR *GlyphMetrics)
  1522. {
  1523. HRESULT hr;
  1524. hr=D3DXCreateTextW(
  1525. (IDirect3DDevice8*) D3DDevice,
  1526. hDC,
  1527. (WCHAR*)Text,
  1528. Deviation,
  1529. Extrusion,
  1530. (ID3DXMesh**)RetMesh,
  1531. (ID3DXBuffer**)AdjacencyOut,
  1532. (LPGLYPHMETRICSFLOAT) GlyphMetrics);
  1533. return hr;
  1534. }
  1535. STDMETHODIMP C_dxj_D3DX8Object::CreateSprite(
  1536. /* [in] */ IUnknown __RPC_FAR *D3DDevice,
  1537. /* [retval][out] */ D3DXSprite ** retSprite)
  1538. {
  1539. HRESULT hr;
  1540. hr=D3DXCreateSprite(
  1541. (IDirect3DDevice8*) D3DDevice,
  1542. (ID3DXSprite **)retSprite);
  1543. return hr;
  1544. }
  1545. STDMETHODIMP C_dxj_D3DX8Object::CreateRenderToSurface(
  1546. IUnknown __RPC_FAR *D3DDevice,
  1547. long Width,
  1548. long Height,
  1549. long Format,
  1550. long DepthStencil,
  1551. long DepthStencilFormat,
  1552. D3DXRenderToSurface **RetRenderToSurface)
  1553. {
  1554. HRESULT hr;
  1555. hr=D3DXCreateRenderToSurface(
  1556. (IDirect3DDevice8*) D3DDevice,
  1557. (UINT) Width, (UINT) Height, (D3DFORMAT) Format, (BOOL) DepthStencil, (D3DFORMAT) DepthStencilFormat,
  1558. (ID3DXRenderToSurface**) RetRenderToSurface);
  1559. return hr;
  1560. }
  1561. STDMETHODIMP C_dxj_D3DX8Object::CleanMesh(
  1562. D3DXMesh *MeshIn,
  1563. void *Adjacency,
  1564. /* [in][out][optional] */ BSTR *ErrLog,
  1565. /* [out] */ D3DXBuffer *AdjacencyOut,
  1566. D3DXMesh **MeshOut)
  1567. {
  1568. HRESULT hr;
  1569. LPD3DXBUFFER pBuffer = NULL;
  1570. WCHAR *wszData = NULL;
  1571. USES_CONVERSION;
  1572. hr=::D3DXCleanMesh( (ID3DXMesh*) MeshIn, (DWORD*) Adjacency, (ID3DXMesh**) MeshOut, (DWORD*)AdjacencyOut->GetBufferPointer(), &pBuffer);
  1573. if (pBuffer)
  1574. {
  1575. wszData = T2W((TCHAR*)pBuffer->GetBufferPointer());
  1576. *ErrLog = SysAllocString(wszData);
  1577. }
  1578. return hr;
  1579. }
  1580. STDMETHODIMP C_dxj_D3DX8Object::ValidMesh(
  1581. /* [in] */ D3DXMesh __RPC_FAR *MeshIn,
  1582. /* [in] */ void __RPC_FAR *Adjacency,
  1583. /* [in][out][optional] */ BSTR *ErrLog,
  1584. VARIANT_BOOL *retHit)
  1585. {
  1586. BOOL bRet;
  1587. LPD3DXBUFFER pBuffer = NULL;
  1588. WCHAR *wszData = NULL;
  1589. USES_CONVERSION;
  1590. bRet =D3DXValidMesh( (ID3DXMesh*) MeshIn, (DWORD*) Adjacency, &pBuffer);
  1591. if (bRet){
  1592. *retHit=VARIANT_TRUE;
  1593. }
  1594. else{
  1595. *retHit=VARIANT_FALSE;
  1596. }
  1597. if (pBuffer)
  1598. {
  1599. wszData = T2W((TCHAR*)pBuffer->GetBufferPointer());
  1600. *ErrLog = SysAllocString(wszData);
  1601. }
  1602. return S_OK;
  1603. }
  1604. STDMETHODIMP C_dxj_D3DX8Object::BoxBoundProbe(
  1605. /* [in] */ D3DVECTOR_CDESC __RPC_FAR *MinVert,
  1606. /* [in] */ D3DVECTOR_CDESC __RPC_FAR *MaxVert,
  1607. /* [in] */ D3DVECTOR_CDESC __RPC_FAR *RayPosition,
  1608. /* [in] */ D3DVECTOR_CDESC __RPC_FAR *RayDirection,
  1609. VARIANT_BOOL *retHit)
  1610. {
  1611. BOOL bRet;
  1612. bRet=::D3DXBoxBoundProbe( (D3DXVECTOR3*) MinVert,
  1613. (D3DXVECTOR3*) MaxVert,
  1614. (D3DXVECTOR3*) RayPosition,
  1615. (D3DXVECTOR3*) RayDirection);
  1616. if (bRet)
  1617. {
  1618. *retHit=VARIANT_TRUE;
  1619. }
  1620. else
  1621. {
  1622. *retHit=VARIANT_FALSE;
  1623. }
  1624. return S_OK;
  1625. }
  1626. STDMETHODIMP C_dxj_D3DX8Object::SaveSurfaceToFile(
  1627. /* [in] */ BSTR DestFile,
  1628. /* [in] */ LONG DestFormat,
  1629. /* [in] */ IUnknown* SrcSurface,
  1630. /* [in] */ PALETTEENTRY* SrcPalette,
  1631. /* [in] */ RECT* SrcRect)
  1632. {
  1633. HRESULT hr;
  1634. hr=::D3DXSaveSurfaceToFileW(
  1635. (WCHAR*) DestFile,
  1636. (D3DXIMAGE_FILEFORMAT)DestFormat,
  1637. (LPDIRECT3DSURFACE8) SrcSurface,
  1638. SrcPalette,
  1639. SrcRect);
  1640. return hr;
  1641. }
  1642. STDMETHODIMP C_dxj_D3DX8Object::SaveVolumeToFile(
  1643. /* [in] */ BSTR DestFile,
  1644. /* [in] */ LONG DestFormat,
  1645. /* [in] */ IUnknown* SrcVolume,
  1646. /* [in] */ PALETTEENTRY* SrcPalette,
  1647. /* [in] */ void* SrcBox)
  1648. {
  1649. HRESULT hr;
  1650. hr=::D3DXSaveVolumeToFileW(
  1651. (WCHAR*) DestFile,
  1652. (D3DXIMAGE_FILEFORMAT)DestFormat,
  1653. (LPDIRECT3DVOLUME8) SrcVolume,
  1654. SrcPalette,
  1655. (D3DBOX*)SrcBox);
  1656. return hr;
  1657. }
  1658. STDMETHODIMP C_dxj_D3DX8Object::SaveTextureToFile(
  1659. /* [in] */ BSTR DestFile,
  1660. /* [in] */ LONG DestFormat,
  1661. /* [in] */ IUnknown* SrcTexture,
  1662. /* [in] */ PALETTEENTRY* SrcPalette)
  1663. {
  1664. HRESULT hr;
  1665. hr=::D3DXSaveTextureToFileW(
  1666. (WCHAR*) DestFile,
  1667. (D3DXIMAGE_FILEFORMAT)DestFormat,
  1668. (LPDIRECT3DBASETEXTURE8) SrcTexture,
  1669. SrcPalette);
  1670. return hr;
  1671. }