Source code of Windows XP (NT5)
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.

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