PageRenderTime 1029ms CodeModel.GetById 1010ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llfloaterhardwaresettings.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 181 lines | 108 code | 34 blank | 39 comment | 2 complexity | ae2642a159b73672cadd6b9f9d84f7a5 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llfloaterhardwaresettings.cpp
  3. * @brief Menu of all the different graphics hardware settings
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llfloaterhardwaresettings.h"
  28. // Viewer includes
  29. #include "llfloaterpreference.h"
  30. #include "llviewerwindow.h"
  31. #include "llviewercontrol.h"
  32. #include "llviewertexturelist.h"
  33. #include "llfeaturemanager.h"
  34. #include "llspinctrl.h"
  35. #include "llstartup.h"
  36. #include "lltextbox.h"
  37. #include "pipeline.h"
  38. // Linden library includes
  39. #include "llradiogroup.h"
  40. #include "lluictrlfactory.h"
  41. #include "llwindow.h"
  42. #include "llsliderctrl.h"
  43. LLFloaterHardwareSettings::LLFloaterHardwareSettings(const LLSD& key)
  44. : LLFloater(key),
  45. // these should be set on imminent refresh() call,
  46. // but init them anyway
  47. mUseVBO(0),
  48. mUseAniso(0),
  49. mFSAASamples(0),
  50. mGamma(0.0),
  51. mVideoCardMem(0),
  52. mFogRatio(0.0),
  53. mProbeHardwareOnStartup(FALSE)
  54. {
  55. }
  56. LLFloaterHardwareSettings::~LLFloaterHardwareSettings()
  57. {
  58. }
  59. void LLFloaterHardwareSettings::initCallbacks(void)
  60. {
  61. }
  62. // menu maintenance functions
  63. void LLFloaterHardwareSettings::refresh()
  64. {
  65. LLPanel::refresh();
  66. mUseVBO = gSavedSettings.getBOOL("RenderVBOEnable");
  67. mUseAniso = gSavedSettings.getBOOL("RenderAnisotropic");
  68. mFSAASamples = gSavedSettings.getU32("RenderFSAASamples");
  69. mGamma = gSavedSettings.getF32("RenderGamma");
  70. mVideoCardMem = gSavedSettings.getS32("TextureMemory");
  71. mFogRatio = gSavedSettings.getF32("RenderFogRatio");
  72. mProbeHardwareOnStartup = gSavedSettings.getBOOL("ProbeHardwareOnStartup");
  73. getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer) mFSAASamples);
  74. refreshEnabledState();
  75. }
  76. void LLFloaterHardwareSettings::refreshEnabledState()
  77. {
  78. S32 min_tex_mem = LLViewerTextureList::getMinVideoRamSetting();
  79. S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting();
  80. getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem);
  81. getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem);
  82. if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
  83. !gGLManager.mHasVertexBufferObject)
  84. {
  85. getChildView("vbo")->setEnabled(FALSE);
  86. }
  87. // if no windlight shaders, turn off nighttime brightness, gamma, and fog distance
  88. LLSpinCtrl* gamma_ctrl = getChild<LLSpinCtrl>("gamma");
  89. gamma_ctrl->setEnabled(!gPipeline.canUseWindLightShaders());
  90. getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders());
  91. getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders());
  92. // anti-aliasing
  93. {
  94. LLUICtrl* fsaa_ctrl = getChild<LLUICtrl>("fsaa");
  95. LLTextBox* fsaa_text = getChild<LLTextBox>("antialiasing label");
  96. LLView* fsaa_restart = getChildView("antialiasing restart");
  97. // Enable or disable the control, the "Antialiasing:" label and the restart warning
  98. // based on code support for the feature on the current hardware.
  99. if (gPipeline.canUseAntiAliasing())
  100. {
  101. fsaa_ctrl->setEnabled(TRUE);
  102. // borrow the text color from the gamma control for consistency
  103. fsaa_text->setColor(gamma_ctrl->getEnabledTextColor());
  104. fsaa_restart->setVisible(!gSavedSettings.getBOOL("RenderDeferred"));
  105. }
  106. else
  107. {
  108. fsaa_ctrl->setEnabled(FALSE);
  109. fsaa_ctrl->setValue((LLSD::Integer) 0);
  110. // borrow the text color from the gamma control for consistency
  111. fsaa_text->setColor(gamma_ctrl->getDisabledTextColor());
  112. fsaa_restart->setVisible(FALSE);
  113. }
  114. }
  115. }
  116. //============================================================================
  117. BOOL LLFloaterHardwareSettings::postBuild()
  118. {
  119. childSetAction("OK", onBtnOK, this);
  120. refresh();
  121. center();
  122. // load it up
  123. initCallbacks();
  124. return TRUE;
  125. }
  126. void LLFloaterHardwareSettings::apply()
  127. {
  128. refresh();
  129. }
  130. void LLFloaterHardwareSettings::cancel()
  131. {
  132. gSavedSettings.setBOOL("RenderVBOEnable", mUseVBO);
  133. gSavedSettings.setBOOL("RenderAnisotropic", mUseAniso);
  134. gSavedSettings.setU32("RenderFSAASamples", mFSAASamples);
  135. gSavedSettings.setF32("RenderGamma", mGamma);
  136. gSavedSettings.setS32("TextureMemory", mVideoCardMem);
  137. gSavedSettings.setF32("RenderFogRatio", mFogRatio);
  138. gSavedSettings.setBOOL("ProbeHardwareOnStartup", mProbeHardwareOnStartup );
  139. closeFloater();
  140. }
  141. // static
  142. void LLFloaterHardwareSettings::onBtnOK( void* userdata )
  143. {
  144. LLFloaterHardwareSettings *fp =(LLFloaterHardwareSettings *)userdata;
  145. fp->apply();
  146. fp->closeFloater(false);
  147. }