aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterhardwaresettings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llfloaterhardwaresettings.cpp')
-rw-r--r--linden/indra/newview/llfloaterhardwaresettings.cpp207
1 files changed, 207 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterhardwaresettings.cpp b/linden/indra/newview/llfloaterhardwaresettings.cpp
new file mode 100644
index 0000000..0d92764
--- /dev/null
+++ b/linden/indra/newview/llfloaterhardwaresettings.cpp
@@ -0,0 +1,207 @@
1/**
2 * @file llfloaterhardwaresettings.cpp
3 * @brief Menu of all the different graphics hardware settings
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llviewerprecompiledheaders.h"
33
34#include "llfloaterhardwaresettings.h"
35#include "llfloaterpreference.h"
36#include "llviewerwindow.h"
37#include "llviewercontrol.h"
38#include "llviewerimagelist.h"
39#include "llfeaturemanager.h"
40#include "llstartup.h"
41
42#include "llradiogroup.h"
43#include "llvieweruictrlfactory.h"
44
45#include "llimagegl.h"
46#include "pipeline.h"
47
48LLFloaterHardwareSettings* LLFloaterHardwareSettings::sHardwareSettings = NULL;
49
50LLFloaterHardwareSettings::LLFloaterHardwareSettings() : LLFloater("Hardware Settings Floater")
51{
52 gUICtrlFactory->buildFloater(this, "floater_hardware_settings.xml");
53
54 // load it up
55 initCallbacks();
56}
57
58LLFloaterHardwareSettings::~LLFloaterHardwareSettings()
59{
60}
61
62void LLFloaterHardwareSettings::onClickHelp(void* data)
63{
64 const char* xml_alert = "HardwareSettingsHelpButton";
65 gViewerWindow->alertXml(xml_alert);
66}
67
68void LLFloaterHardwareSettings::initCallbacks(void)
69{
70}
71
72// menu maintenance functions
73
74void LLFloaterHardwareSettings::refresh()
75{
76 LLPanel::refresh();
77
78 mUseVBO = gSavedSettings.getBOOL("RenderVBOEnable");
79 mUseAniso = gSavedSettings.getBOOL("RenderAnisotropic");
80 mGamma = gSavedSettings.getF32("RenderGamma");
81 mVideoCardMem = gSavedSettings.getS32("TextureMemory");
82 mFogRatio = gSavedSettings.getF32("RenderFogRatio");
83 mProbeHardwareOnStartup = gSavedSettings.getBOOL("ProbeHardwareOnStartup");
84
85 refreshEnabledState();
86}
87
88void LLFloaterHardwareSettings::refreshEnabledState()
89{
90 S32 min_tex_mem = LLViewerImageList::getMinVideoRamSetting();
91 S32 max_tex_mem = LLViewerImageList::getMaxVideoRamSetting();
92 childSetMinValue("GrapicsCardTextureMemory", min_tex_mem);
93 childSetMaxValue("GrapicsCardTextureMemory", max_tex_mem);
94
95 if (!gFeatureManagerp->isFeatureAvailable("RenderVBOEnable") ||
96 !gGLManager.mHasVertexBufferObject)
97 {
98 childSetEnabled("vbo", FALSE);
99 }
100
101 // if no windlight shaders, turn off nighttime brightness, gamma, and fog distance
102 childSetEnabled("gamma", !gPipeline.canUseWindLightShaders());
103 childSetEnabled("(brightness, lower is brighter)", !gPipeline.canUseWindLightShaders());
104 childSetEnabled("fog", !gPipeline.canUseWindLightShaders());
105
106}
107
108// static instance of it
109LLFloaterHardwareSettings* LLFloaterHardwareSettings::instance()
110{
111 if (!sHardwareSettings)
112 {
113 sHardwareSettings = new LLFloaterHardwareSettings();
114 sHardwareSettings->close();
115 }
116 return sHardwareSettings;
117}
118void LLFloaterHardwareSettings::show()
119{
120 LLFloaterHardwareSettings* hardSettings = instance();
121 hardSettings->refresh();
122 hardSettings->center();
123
124 // comment in if you want the menu to rebuild each time
125 //gUICtrlFactory->buildFloater(hardSettings, "floater_hardware_settings.xml");
126 //hardSettings->initCallbacks();
127
128 hardSettings->open();
129}
130
131bool LLFloaterHardwareSettings::isOpen()
132{
133 if (sHardwareSettings != NULL)
134 {
135 return true;
136 }
137 return false;
138}
139
140// virtual
141void LLFloaterHardwareSettings::onClose(bool app_quitting)
142{
143 if (sHardwareSettings)
144 {
145 sHardwareSettings->setVisible(FALSE);
146 }
147}
148
149
150//============================================================================
151
152BOOL LLFloaterHardwareSettings::postBuild()
153{
154 requires("ani", WIDGET_TYPE_CHECKBOX);
155 requires("gamma", WIDGET_TYPE_SPINNER);
156 requires("vbo", WIDGET_TYPE_CHECKBOX);
157 requires("GrapicsCardTextureMemory", WIDGET_TYPE_SLIDER);
158 requires("fog", WIDGET_TYPE_SPINNER);
159
160 if (!checkRequirements())
161 {
162 return FALSE;
163 }
164
165 childSetAction("OK", onBtnOK, this);
166
167 refresh();
168
169 return TRUE;
170}
171
172
173void LLFloaterHardwareSettings::apply()
174{
175 // Anisotropic rendering
176 BOOL old_anisotropic = LLImageGL::sGlobalUseAnisotropic;
177 LLImageGL::sGlobalUseAnisotropic = childGetValue("ani");
178 if (old_anisotropic != LLImageGL::sGlobalUseAnisotropic)
179 {
180 BOOL logged_in = (LLStartUp::getStartupState() >= STATE_STARTED);
181 gViewerWindow->restartDisplay(logged_in);
182 }
183
184 refresh();
185}
186
187
188void LLFloaterHardwareSettings::cancel()
189{
190 gSavedSettings.setBOOL("RenderVBOEnable", mUseVBO);
191 gSavedSettings.setBOOL("RenderAnisotropic", mUseAniso);
192 gSavedSettings.setF32("RenderGamma", mGamma);
193 gSavedSettings.setS32("TextureMemory", mVideoCardMem);
194 gSavedSettings.setF32("RenderFogRatio", mFogRatio);
195 gSavedSettings.setBOOL("ProbeHardwareOnStartup", mProbeHardwareOnStartup );
196
197 close();
198}
199
200// static
201void LLFloaterHardwareSettings::onBtnOK( void* userdata )
202{
203 LLFloaterHardwareSettings *fp =(LLFloaterHardwareSettings *)userdata;
204 fp->apply();
205 fp->close(false);
206}
207