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.

106 lines
3.3 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) Microsoft Corporation, 1998.
  3. //
  4. // reftnl.cpp
  5. //
  6. // Direct3D Reference Transformation and Lighting - public interface
  7. //
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #include "pch.cpp"
  10. #pragma hdrstop
  11. #define RESPATH_D3D "Software\\Microsoft\\Direct3D"
  12. //---------------------------------------------------------------------
  13. // Gets the value from DIRECT3D registry key
  14. // Returns TRUE if success
  15. // If fails value is not changed
  16. //
  17. BOOL GetD3DRegValue(DWORD type, char *valueName, LPVOID value, DWORD dwSize)
  18. {
  19. HKEY hKey = (HKEY) NULL;
  20. if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE, RESPATH_D3D, &hKey))
  21. {
  22. DWORD dwType;
  23. LONG result;
  24. result = RegQueryValueEx(hKey, valueName, NULL, &dwType,
  25. (LPBYTE)value, &dwSize);
  26. RegCloseKey(hKey);
  27. return result == ERROR_SUCCESS && dwType == type;
  28. }
  29. else
  30. return FALSE;
  31. }
  32. ///////////////////////////////////////////////////////////////////////////////
  33. // RefAlignedBuffer32
  34. ///////////////////////////////////////////////////////////////////////////////
  35. HRESULT RefAlignedBuffer32::Grow(DWORD growSize)
  36. {
  37. if (m_allocatedBuf)
  38. free(m_allocatedBuf);
  39. m_size = growSize;
  40. if ((m_allocatedBuf = malloc(m_size + 31)) == NULL)
  41. {
  42. m_allocatedBuf = 0;
  43. m_alignedBuf = 0;
  44. m_size = 0;
  45. return DDERR_OUTOFMEMORY;
  46. }
  47. m_alignedBuf = (LPVOID)(((ULONG_PTR)m_allocatedBuf + 31 ) & ~31);
  48. return S_OK;
  49. }
  50. ///////////////////////////////////////////////////////////////////////////////
  51. // RRProcessVertices::InitTL()
  52. ///////////////////////////////////////////////////////////////////////////////
  53. void
  54. RRProcessVertices::InitTLData()
  55. {
  56. m_LightVertexTable.pfnDirectional = RRLV_Directional;
  57. m_LightVertexTable.pfnParallelPoint = RRLV_Directional;
  58. m_LightVertexTable.pfnSpot = RRLV_PointAndSpot;
  59. m_LightVertexTable.pfnPoint = RRLV_PointAndSpot;
  60. //
  61. // Guardband parameters
  62. //
  63. // By default enable Guardband and set the extents equal
  64. // to the default RefRast parameters
  65. m_dwTLState |= RRPV_GUARDBAND;
  66. m_ViewData.minXgb = (REF_GB_LEFT);
  67. m_ViewData.maxXgb = REF_GB_RIGHT;
  68. m_ViewData.minYgb = (REF_GB_TOP);
  69. m_ViewData.maxYgb = REF_GB_BOTTOM;
  70. #if DBG
  71. DWORD v = 0;
  72. // Guardband parameters
  73. if (GetD3DRegValue(REG_DWORD, "DisableGB", &v, 4) &&
  74. v != 0)
  75. {
  76. m_dwTLState &= ~RRPV_GUARDBAND;
  77. }
  78. // Try to get test values for the guard band
  79. char value[80];
  80. if (GetD3DRegValue(REG_SZ, "GuardBandLeft", &value, 80) &&
  81. value[0] != 0)
  82. sscanf(value, "%f", &m_ViewData.minXgb);
  83. if (GetD3DRegValue(REG_SZ, "GuardBandRight", &value, 80) &&
  84. value[0] != 0)
  85. sscanf(value, "%f", &m_ViewData.maxXgb);
  86. if (GetD3DRegValue(REG_SZ, "GuardBandTop", &value, 80) &&
  87. value[0] != 0)
  88. sscanf(value, "%f", &m_ViewData.minYgb);
  89. if (GetD3DRegValue(REG_SZ, "GuardBandBottom", &value, 80) &&
  90. value[0] != 0)
  91. sscanf(value, "%f", &m_ViewData.maxYgb);
  92. #endif // DBG
  93. }
  94. ///////////////////////////////////////////////////////////////////////////////
  95. // end