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.

102 lines
2.8 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: halmat.c
  6. * Content: Direct3D HAL material handler
  7. *@@BEGIN_MSINTERNAL
  8. *
  9. * $Id: halmat.c,v 1.1 1995/11/21 15:12:40 sjl Exp $
  10. *
  11. * History:
  12. * Date By Reason
  13. * ==== == ======
  14. * 07/11/95 stevela Initial rev.
  15. *@@END_MSINTERNAL
  16. *
  17. ***************************************************************************/
  18. #include "pch.cpp"
  19. #pragma hdrstop
  20. extern HRESULT SetMaterial(LPDIRECT3DDEVICEI lpDevI, D3DMATERIALHANDLE hMat);
  21. HRESULT
  22. D3DHAL_MaterialCreate(LPDIRECT3DDEVICEI lpDevI,
  23. LPD3DMATERIALHANDLE lphMat,
  24. LPD3DMATERIAL lpMat)
  25. {
  26. LPD3DFE_MATERIAL lpNewMat;
  27. D3DMalloc((void**)&lpNewMat, sizeof(D3DFE_MATERIAL));
  28. if (!lpNewMat)
  29. return D3DERR_MATERIAL_CREATE_FAILED;
  30. lpNewMat->mat = *lpMat;
  31. LIST_INSERT_ROOT(&lpDevI->materials, lpNewMat, link);
  32. *lphMat = (DWORD)((ULONG_PTR)lpNewMat);
  33. // continue for ramp only - need to munge ramp handles and call ramp
  34. // service with material info
  35. return CallRampService(lpDevI, RAMP_SERVICE_CREATEMAT,
  36. (ULONG_PTR) lpNewMat, 0);
  37. }
  38. HRESULT
  39. D3DHAL_MaterialDestroy(LPDIRECT3DDEVICEI lpDevI, D3DMATERIALHANDLE hMat)
  40. {
  41. HRESULT hr;
  42. if(hMat==0)
  43. {
  44. return D3DERR_MATERIAL_DESTROY_FAILED;
  45. }
  46. if (lpDevI->lighting.hMat == hMat)
  47. lpDevI->lighting.hMat = 0;
  48. hr = CallRampService(lpDevI, RAMP_SERVICE_DESTORYMAT, (DWORD) hMat, 0);
  49. LPD3DFE_MATERIAL lpMat = (LPD3DFE_MATERIAL)ULongToPtr(hMat);
  50. LIST_DELETE(lpMat, link);
  51. D3DFree(lpMat);
  52. return (hr);
  53. }
  54. HRESULT
  55. D3DHAL_MaterialSetData(LPDIRECT3DDEVICEI lpDevI,
  56. D3DMATERIALHANDLE hMat,
  57. LPD3DMATERIAL lpMat)
  58. {
  59. if(hMat==0)
  60. return D3DERR_MATERIAL_SETDATA_FAILED;
  61. LPD3DFE_MATERIAL mat = (LPD3DFE_MATERIAL)ULongToPtr(hMat);
  62. mat->mat = *lpMat;
  63. if (hMat == lpDevI->lighting.hMat)
  64. SetMaterial(lpDevI, hMat);
  65. // continue for ramp only - need to munge ramp handles and call ramp
  66. // service with material info
  67. if(lpDevI->pfnRampService != NULL)
  68. return CallRampService(lpDevI, RAMP_SERVICE_SETMATDATA,
  69. (ULONG_PTR) hMat, 0, TRUE);
  70. else
  71. return D3D_OK;
  72. }
  73. HRESULT
  74. D3DHAL_MaterialGetData(LPDIRECT3DDEVICEI lpDevI,
  75. D3DMATERIALHANDLE hMat,
  76. LPD3DMATERIAL lpMat)
  77. {
  78. if(hMat==0)
  79. {
  80. memset(lpMat,0,sizeof(D3DMATERIAL));
  81. return D3DERR_MATERIAL_GETDATA_FAILED;
  82. }
  83. LPD3DFE_MATERIAL mat = (LPD3DFE_MATERIAL)ULongToPtr(hMat);
  84. *lpMat = mat->mat;
  85. return (D3D_OK);
  86. }