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.

101 lines
3.4 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: halstate.c
  6. * Content: Direct3D HAL pipeline state management
  7. *@@BEGIN_MSINTERNAL
  8. *
  9. * History:
  10. * Date By Reason
  11. * ==== == ======
  12. * 18/12/95 stevela Initial rev.
  13. *@@END_MSINTERNAL
  14. *
  15. ***************************************************************************/
  16. #include "pch.cpp"
  17. #pragma hdrstop
  18. HRESULT
  19. D3DHAL_GetState(LPDIRECT3DDEVICEI lpDevI, DWORD dwWhich, LPD3DSTATE lpState)
  20. {
  21. LPD3DHAL_GLOBALDRIVERDATA gdd = lpDevI->lpD3DHALGlobalDriverData;
  22. D3DHAL_GETSTATEDATA data;
  23. HRESULT ret;
  24. D3D_INFO(6, "GetState, getting state dwhContext = %d", lpDevI->dwhContext);
  25. memset(&data, 0, sizeof(D3DHAL_GETSTATEDATA));
  26. data.dwhContext = lpDevI->dwhContext;
  27. data.dwWhich = dwWhich;
  28. data.ddState = *lpState;
  29. if (dwWhich == D3DHALSTATE_GET_RENDER ||
  30. (dwWhich == D3DHALSTATE_GET_TRANSFORM
  31. && (gdd->hwCaps.dwFlags & D3DDD_TRANSFORMCAPS)) ||
  32. (dwWhich == D3DHALSTATE_GET_LIGHT
  33. && (gdd->hwCaps.dwFlags & D3DDD_LIGHTINGCAPS)))
  34. {
  35. CALL_HALONLY(ret, lpDevI, GetState, &data);
  36. if (ret != DDHAL_DRIVER_HANDLED || data.ddrval != DD_OK)
  37. {
  38. D3D_ERR("HAL failed to handle GetState");
  39. return (DDERR_GENERIC);
  40. }
  41. }
  42. else
  43. {
  44. switch (data.dwWhich)
  45. {
  46. case D3DHALSTATE_GET_RENDER:
  47. D3D_ERR("HEL called for D3DHALSTATE_GET_RENDER");
  48. return (DDERR_INVALIDPARAMS);
  49. case D3DHALSTATE_GET_TRANSFORM:
  50. D3D_INFO(3, "GetState called for transform");
  51. switch (data.ddState.dtstTransformStateType)
  52. {
  53. case D3DTRANSFORMSTATE_WORLD:
  54. data.ddState.dwArg[0] = lpDevI->transform.hWorld;
  55. break;
  56. case D3DTRANSFORMSTATE_VIEW:
  57. data.ddState.dwArg[0] = lpDevI->transform.hView;
  58. break;
  59. case D3DTRANSFORMSTATE_PROJECTION:
  60. data.ddState.dwArg[0] = lpDevI->transform.hProj;
  61. break;
  62. default:
  63. D3D_ERR("Unknown GetState found");
  64. return (DDERR_GENERIC);
  65. }
  66. break;
  67. case D3DHALSTATE_GET_LIGHT:
  68. D3D_INFO(3, "GetState called for lighting");
  69. switch (data.ddState.dlstLightStateType)
  70. {
  71. case D3DLIGHTSTATE_MATERIAL:
  72. data.ddState.dwArg[0] = lpDevI->lighting.hMat;
  73. break;
  74. case D3DLIGHTSTATE_AMBIENT:
  75. data.ddState.dwArg[0] =
  76. RGB_MAKE((int)lpDevI->lighting.ambient_red,
  77. (int)lpDevI->lighting.ambient_green,
  78. (int)lpDevI->lighting.ambient_blue);
  79. break;
  80. case D3DLIGHTSTATE_COLORMODEL:
  81. #pragma message("XXX - D3DLIGHTSTATE_COLORMODEL in HEL GetState not implemented.")
  82. break;
  83. default:
  84. D3D_ERR("Unknown GetState found");
  85. return (DDERR_GENERIC);
  86. }
  87. default:
  88. D3D_ERR("Unknown GetState found");
  89. return (DDERR_GENERIC);
  90. }
  91. }
  92. *lpState = data.ddState;
  93. return (D3D_OK);
  94. }