PageRenderTime 332ms CodeModel.GetById 120ms app.highlight 16ms RepoModel.GetById 115ms 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
  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
 27#include "llviewerprecompiledheaders.h"
 28
 29#include "llfloaterhardwaresettings.h"
 30
 31// Viewer includes
 32#include "llfloaterpreference.h"
 33#include "llviewerwindow.h"
 34#include "llviewercontrol.h"
 35#include "llviewertexturelist.h"
 36#include "llfeaturemanager.h"
 37#include "llspinctrl.h"
 38#include "llstartup.h"
 39#include "lltextbox.h"
 40#include "pipeline.h"
 41
 42// Linden library includes
 43#include "llradiogroup.h"
 44#include "lluictrlfactory.h"
 45#include "llwindow.h"
 46#include "llsliderctrl.h"
 47
 48LLFloaterHardwareSettings::LLFloaterHardwareSettings(const LLSD& key)
 49	: LLFloater(key),
 50
 51	  // these should be set on imminent refresh() call,
 52	  // but init them anyway
 53	  mUseVBO(0),
 54	  mUseAniso(0),
 55	  mFSAASamples(0),
 56	  mGamma(0.0),
 57	  mVideoCardMem(0),
 58	  mFogRatio(0.0),
 59	  mProbeHardwareOnStartup(FALSE)
 60{
 61}
 62
 63LLFloaterHardwareSettings::~LLFloaterHardwareSettings()
 64{
 65}
 66
 67void LLFloaterHardwareSettings::initCallbacks(void) 
 68{
 69}
 70
 71// menu maintenance functions
 72
 73void LLFloaterHardwareSettings::refresh()
 74{
 75	LLPanel::refresh();
 76
 77	mUseVBO = gSavedSettings.getBOOL("RenderVBOEnable");
 78	mUseAniso = gSavedSettings.getBOOL("RenderAnisotropic");
 79	mFSAASamples = gSavedSettings.getU32("RenderFSAASamples");
 80	mGamma = gSavedSettings.getF32("RenderGamma");
 81	mVideoCardMem = gSavedSettings.getS32("TextureMemory");
 82	mFogRatio = gSavedSettings.getF32("RenderFogRatio");
 83	mProbeHardwareOnStartup = gSavedSettings.getBOOL("ProbeHardwareOnStartup");
 84
 85	getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer) mFSAASamples);
 86	refreshEnabledState();
 87}
 88
 89void LLFloaterHardwareSettings::refreshEnabledState()
 90{
 91	S32 min_tex_mem = LLViewerTextureList::getMinVideoRamSetting();
 92	S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting();
 93	getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem);
 94	getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem);
 95
 96	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
 97		!gGLManager.mHasVertexBufferObject)
 98	{
 99		getChildView("vbo")->setEnabled(FALSE);
100	}
101
102	// if no windlight shaders, turn off nighttime brightness, gamma, and fog distance
103	LLSpinCtrl* gamma_ctrl = getChild<LLSpinCtrl>("gamma");
104	gamma_ctrl->setEnabled(!gPipeline.canUseWindLightShaders());
105	getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders());
106	getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders());
107
108	// anti-aliasing
109	{
110		LLUICtrl* fsaa_ctrl = getChild<LLUICtrl>("fsaa");
111		LLTextBox* fsaa_text = getChild<LLTextBox>("antialiasing label");
112		LLView* fsaa_restart = getChildView("antialiasing restart");
113		
114		// Enable or disable the control, the "Antialiasing:" label and the restart warning
115		// based on code support for the feature on the current hardware.
116
117		if (gPipeline.canUseAntiAliasing())
118		{
119			fsaa_ctrl->setEnabled(TRUE);
120			
121			// borrow the text color from the gamma control for consistency
122			fsaa_text->setColor(gamma_ctrl->getEnabledTextColor());
123
124			fsaa_restart->setVisible(!gSavedSettings.getBOOL("RenderDeferred"));
125		}
126		else
127		{
128			fsaa_ctrl->setEnabled(FALSE);
129			fsaa_ctrl->setValue((LLSD::Integer) 0);
130			
131			// borrow the text color from the gamma control for consistency
132			fsaa_text->setColor(gamma_ctrl->getDisabledTextColor());
133			
134			fsaa_restart->setVisible(FALSE);
135		}
136	}
137}
138
139//============================================================================
140
141BOOL LLFloaterHardwareSettings::postBuild()
142{
143	childSetAction("OK", onBtnOK, this);
144
145	refresh();
146	center();
147
148	// load it up
149	initCallbacks();
150	return TRUE;
151}
152
153
154void LLFloaterHardwareSettings::apply()
155{
156	refresh();
157}
158
159
160void LLFloaterHardwareSettings::cancel()
161{
162	gSavedSettings.setBOOL("RenderVBOEnable", mUseVBO);
163	gSavedSettings.setBOOL("RenderAnisotropic", mUseAniso);
164	gSavedSettings.setU32("RenderFSAASamples", mFSAASamples);
165	gSavedSettings.setF32("RenderGamma", mGamma);
166	gSavedSettings.setS32("TextureMemory", mVideoCardMem);
167	gSavedSettings.setF32("RenderFogRatio", mFogRatio);
168	gSavedSettings.setBOOL("ProbeHardwareOnStartup", mProbeHardwareOnStartup );
169
170	closeFloater();
171}
172
173// static 
174void LLFloaterHardwareSettings::onBtnOK( void* userdata )
175{
176	LLFloaterHardwareSettings *fp =(LLFloaterHardwareSettings *)userdata;
177	fp->apply();
178	fp->closeFloater(false);
179}
180
181