aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpaneldisplay.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpaneldisplay.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llpaneldisplay.cpp')
-rw-r--r--linden/indra/newview/llpaneldisplay.cpp716
1 files changed, 716 insertions, 0 deletions
diff --git a/linden/indra/newview/llpaneldisplay.cpp b/linden/indra/newview/llpaneldisplay.cpp
new file mode 100644
index 0000000..ea3d7e7
--- /dev/null
+++ b/linden/indra/newview/llpaneldisplay.cpp
@@ -0,0 +1,716 @@
1/**
2 * @file llpaneldisplay.cpp
3 * @brief Display preferences for the preferences floater
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30// file include
31#include "llpaneldisplay.h"
32
33// linden library includes
34#include "llerror.h"
35#include "llfontgl.h"
36#include "llrect.h"
37#include "llstring.h"
38
39// project includes
40#include "llagent.h"
41#include "llbutton.h"
42#include "llcheckboxctrl.h"
43#include "llcombobox.h"
44#include "lldrawpoolterrain.h"
45#include "llflexibleobject.h"
46#include "lllineeditor.h"
47#include "llradiogroup.h"
48#include "llresmgr.h"
49#include "llsliderctrl.h"
50#include "llspinctrl.h"
51#include "llstartup.h"
52#include "lltextbox.h"
53#include "llui.h"
54#include "llviewercamera.h"
55#include "llviewerimage.h"
56#include "llviewerimagelist.h"
57#include "llviewermessage.h"
58#include "llviewerobjectlist.h"
59#include "llviewerwindow.h"
60#include "llvoavatar.h"
61#include "llvovolume.h"
62#include "llvotree.h"
63#include "llvosky.h"
64#include "llwindow.h"
65#include "llworld.h"
66#include "pipeline.h"
67#include "llvieweruictrlfactory.h"
68#include "llfeaturemanager.h"
69
70//RN temporary includes for resolution switching
71#include "llglheaders.h"
72#include "viewer.h"
73#include "llsky.h"
74
75const F32 MAX_USER_FAR_CLIP = 512.f;
76const F32 MIN_USER_FAR_CLIP = 64.f;
77
78const S32 ASPECT_RATIO_STR_LEN = 100;
79
80
81LLPanelDisplay::LLPanelDisplay()
82{
83 gUICtrlFactory->buildPanel(this, "panel_preferences_graphics1.xml");
84}
85
86BOOL LLPanelDisplay::postBuild()
87{
88 requires("windowed mode", WIDGET_TYPE_CHECKBOX);
89 requires("fullscreen combo", WIDGET_TYPE_COMBO_BOX);
90 requires("resolution_format", WIDGET_TYPE_TEXT_BOX);
91 requires("aspect_ratio_text", WIDGET_TYPE_TEXT_BOX);
92 requires("aspect_ratio", WIDGET_TYPE_COMBO_BOX);
93 requires("aspect_auto_detect", WIDGET_TYPE_CHECKBOX);
94 requires("UI Scale", WIDGET_TYPE_SLIDER);
95 requires("ui_auto_scale", WIDGET_TYPE_CHECKBOX);
96 requires("draw_distance", WIDGET_TYPE_SPINNER);
97 requires("avfp", WIDGET_TYPE_CHECKBOX);
98
99 if (!checkRequirements())
100 {
101 return FALSE;
102 }
103
104 //============================================================================
105 // Resolution
106
107 // radio set for fullscreen size
108
109 mCtrlWindowed = LLUICtrlFactory::getCheckBoxByName(this, "windowed mode");
110 mCtrlWindowed->setCommitCallback(onCommitWindowedMode);
111 mCtrlWindowed->setCallbackUserData(this);
112
113 S32 num_resolutions = 0;
114 LLWindow::LLWindowResolution* supported_resolutions = gViewerWindow->getWindow()->getSupportedResolutions(num_resolutions);
115
116 S32 fullscreen_mode = num_resolutions - 1;
117
118 mCtrlFullScreen = LLUICtrlFactory::getComboBoxByName(this, "fullscreen combo");
119
120 LLUIString resolution_label = childGetText("resolution_format");
121
122 for (S32 i = 0; i < num_resolutions; i++)
123 {
124 resolution_label.setArg("[RES_X]", llformat("%d", supported_resolutions[i].mWidth));
125 resolution_label.setArg("[RES_Y]", llformat("%d", supported_resolutions[i].mHeight));
126 mCtrlFullScreen->add( resolution_label, ADD_BOTTOM );
127 }
128
129 {
130 BOOL targetFullscreen;
131 S32 targetWidth;
132 S32 targetHeight;
133
134 gViewerWindow->getTargetWindow(targetFullscreen, targetWidth, targetHeight);
135
136 if (targetFullscreen)
137 {
138 fullscreen_mode = 0; // default to 800x600
139 for (S32 i = 0; i < num_resolutions; i++)
140 {
141 if (targetWidth == supported_resolutions[i].mWidth
142 && targetHeight == supported_resolutions[i].mHeight)
143 {
144 fullscreen_mode = i;
145 }
146 }
147 mCtrlFullScreen->setCurrentByIndex(fullscreen_mode);
148 mCtrlWindowed->set(FALSE);
149 mCtrlFullScreen->setEnabled(TRUE);
150 }
151 else
152 {
153 // set to windowed mode
154 //fullscreen_mode = mCtrlFullScreen->getItemCount() - 1;
155 mCtrlWindowed->set(TRUE);
156 mCtrlFullScreen->setCurrentByIndex(0);
157 mCtrlFullScreen->setEnabled(FALSE);
158 }
159 }
160
161 if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio"))
162 {
163 mAspectRatio = gViewerWindow->getDisplayAspectRatio();
164 }
165 else
166 {
167 mAspectRatio = gSavedSettings.getF32("FullScreenAspectRatio");
168 }
169
170 S32 numerator = 0;
171 S32 denominator = 0;
172 fractionFromDecimal(mAspectRatio, numerator, denominator);
173
174 LLUIString aspect_ratio_text = childGetText("aspect_ratio_text");
175 if (numerator != 0)
176 {
177 aspect_ratio_text.setArg("[NUM]", llformat("%d", numerator));
178 aspect_ratio_text.setArg("[DEN]", llformat("%d", denominator));
179 }
180 else
181 {
182 aspect_ratio_text = llformat("%.3f", mAspectRatio);
183 }
184
185 mCtrlAspectRatio = LLUICtrlFactory::getComboBoxByName(this, "aspect_ratio");
186 mCtrlAspectRatio->setTextEntryCallback(onKeystrokeAspectRatio);
187 mCtrlAspectRatio->setCommitCallback(onSelectAspectRatio);
188 mCtrlAspectRatio->setCallbackUserData(this);
189 // add default aspect ratios
190 mCtrlAspectRatio->add(aspect_ratio_text, &mAspectRatio, ADD_TOP);
191 mCtrlAspectRatio->setCurrentByIndex(0);
192
193 mCtrlAutoDetectAspect = LLUICtrlFactory::getCheckBoxByName(this, "aspect_auto_detect");
194 mCtrlAutoDetectAspect->setCommitCallback(onCommitAutoDetectAspect);
195 mCtrlAutoDetectAspect->setCallbackUserData(this);
196
197 refresh();
198
199 return TRUE;
200}
201
202
203LLPanelDisplay::~LLPanelDisplay()
204{
205 // clean up user data
206 for (S32 i = 0; i < mCtrlAspectRatio->getItemCount(); i++)
207 {
208 mCtrlAspectRatio->setCurrentByIndex(i);
209 }
210}
211
212void LLPanelDisplay::refresh()
213{
214 LLPanel::refresh();
215
216 mFSAutoDetectAspect = gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio");
217
218 mUIScaleFactor = gSavedSettings.getF32("UIScaleFactor");
219 mUIAutoScale = gSavedSettings.getBOOL("UIAutoScale");
220
221 // First Person Visibility
222 mFirstPersonAvatarVisible = gSavedSettings.getBOOL("FirstPersonAvatarVisible");
223
224 // Draw distance
225 mRenderFarClip = gSavedSettings.getF32("RenderFarClip");
226
227}
228
229void LLPanelDisplay::cancel()
230{
231 gSavedSettings.setBOOL("FullScreenAutoDetectAspectRatio", mFSAutoDetectAspect);
232 gSavedSettings.setF32("UIScaleFactor", mUIScaleFactor);
233 gSavedSettings.setBOOL("UIAutoScale", mUIAutoScale);
234 gSavedSettings.setBOOL("FirstPersonAvatarVisible", mFirstPersonAvatarVisible);
235 gSavedSettings.setF32("RenderFarClip", mRenderFarClip);
236}
237
238void LLPanelDisplay::apply()
239{
240 applyResolution();
241}
242
243void LLPanelDisplay::onApplyResolution(LLUICtrl* src, void* user_data)
244{
245 ((LLPanelDisplay*) src)->applyResolution();
246}
247
248void LLPanelDisplay::applyResolution()
249{
250 char aspect_ratio_text[ASPECT_RATIO_STR_LEN];
251 if (mCtrlAspectRatio->getCurrentIndex() == -1)
252 {
253 strcpy(aspect_ratio_text, mCtrlAspectRatio->getSimple().c_str());
254
255 char *element = strtok(aspect_ratio_text, ":/\\");
256 if (!element)
257 {
258 mAspectRatio = 0.f; // will be clamped later
259 }
260 else
261 {
262 LLLocale locale(LLLocale::USER_LOCALE);
263 mAspectRatio = (F32)atof(element);
264 }
265
266 // look for denominator
267 element = strtok(NULL, ":/\\");
268 if (element)
269 {
270 LLLocale locale(LLLocale::USER_LOCALE);
271
272 F32 denominator = (F32)atof(element);
273 if (denominator != 0.f)
274 {
275 mAspectRatio /= denominator;
276 }
277 }
278 }
279 else
280 {
281 mAspectRatio = (F32)mCtrlAspectRatio->getValue().asReal();
282 }
283
284 // presumably, user entered a non-numeric value if aspect_ratio == 0.f
285 if (mAspectRatio != 0.f)
286 {
287 mAspectRatio = llclamp(mAspectRatio, 0.2f, 5.f);
288 gSavedSettings.setF32("FullScreenAspectRatio", mAspectRatio);
289 if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio"))
290 {
291 gViewerWindow->getWindow()->setNativeAspectRatio(0.f);
292 }
293 else
294 {
295 gViewerWindow->getWindow()->setNativeAspectRatio(mAspectRatio);
296 }
297 }
298 gViewerWindow->reshape(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight());
299
300 // Screen resolution
301 S32 num_resolutions;
302 LLWindow::LLWindowResolution* supported_resolutions = gViewerWindow->getWindow()->getSupportedResolutions(num_resolutions);
303
304 // switching to windowed
305 BOOL fullscreen = !mCtrlWindowed->get();
306
307 // check if resolution has changed
308 BOOL targetFullscreen;
309 S32 targetWidth;
310 S32 targetHeight;
311
312 gViewerWindow->getTargetWindow(targetFullscreen, targetWidth, targetHeight);
313
314 if ((fullscreen != targetFullscreen) ||
315 (fullscreen &&
316 (supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mWidth != targetWidth ||
317 supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mHeight != targetHeight)
318 ))
319 {
320 // change fullscreen resolution or switch in/out of windowed mode
321 BOOL result;
322
323 BOOL logged_in = (gStartupState >= STATE_STARTED);
324 if (fullscreen)
325 {
326 result = gViewerWindow->changeDisplaySettings(TRUE,
327 LLCoordScreen( supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mWidth,
328 supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mHeight),
329 gSavedSettings.getBOOL("DisableVerticalSync"),
330 logged_in);
331 }
332 else
333 {
334 result = gViewerWindow->changeDisplaySettings(FALSE,
335 LLCoordScreen(gSavedSettings.getS32("WindowWidth"), gSavedSettings.getS32("WindowHeight")),
336 TRUE,
337 logged_in);
338 }
339 if (!result)
340 {
341
342 // GL is non-existent at this point, so we can't continue.
343 llerrs << "LLPanelDisplay::apply() failed" << llendl;
344 }
345 }
346
347 // force aspect ratio
348 if (fullscreen && gCamera)
349 {
350 gCamera->setAspect( gViewerWindow->getDisplayAspectRatio() );
351 }
352
353 if (gWorldPointer)
354 {
355 send_agent_update(TRUE);
356 }
357
358 // Update enable/disable
359 refresh();
360}
361
362//static
363void LLPanelDisplay::onCommitWindowedMode(LLUICtrl* ctrl, void *data)
364{
365 LLPanelDisplay *panel = (LLPanelDisplay*)data;
366
367 BOOL windowed_mode = ((LLCheckBoxCtrl*)ctrl)->get();
368
369 if (windowed_mode)
370 {
371 panel->mCtrlFullScreen->setEnabled(FALSE);
372 }
373 else
374 {
375 panel->mCtrlFullScreen->setEnabled(TRUE);
376 }
377}
378
379//static
380void LLPanelDisplay::onCommitAutoDetectAspect(LLUICtrl *ctrl, void *data)
381{
382 LLPanelDisplay *panel = (LLPanelDisplay*)data;
383
384 BOOL auto_detect = ((LLCheckBoxCtrl*)ctrl)->get();
385
386 if (auto_detect)
387 {
388 char aspect[100];
389 S32 numerator = 0;
390 S32 denominator = 0;
391 // clear any aspect ratio override
392 gViewerWindow->mWindow->setNativeAspectRatio(0.f);
393 fractionFromDecimal(gViewerWindow->mWindow->getNativeAspectRatio(), numerator, denominator);
394
395 if (numerator != 0)
396 {
397 sprintf(aspect, "%d:%d", numerator, denominator);
398 }
399 else
400 {
401 sprintf(aspect, "%.3f", gViewerWindow->mWindow->getNativeAspectRatio());
402 }
403
404 panel->mCtrlAspectRatio->setLabel(aspect);
405 }
406}
407
408//static
409void LLPanelDisplay::onKeystrokeAspectRatio(LLLineEditor* caller, void* user_data)
410{
411 LLPanelDisplay* panel = (LLPanelDisplay*)user_data;
412
413 panel->mCtrlAutoDetectAspect->set(FALSE);
414}
415
416//static
417void LLPanelDisplay::onSelectAspectRatio(LLUICtrl*, void* user_data)
418{
419 LLPanelDisplay* panel = (LLPanelDisplay*)user_data;
420
421 panel->mCtrlAutoDetectAspect->set(FALSE);
422}
423
424//static
425void LLPanelDisplay::fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator)
426{
427 numerator = 0;
428 denominator = 0;
429 for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f)
430 {
431 if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f)
432 {
433 numerator = llround(decimal_val * test_denominator);
434 denominator = llround(test_denominator);
435 break;
436 }
437 }
438}
439
440//============================================================================
441
442LLPanelDisplay2::LLPanelDisplay2()
443{
444 gUICtrlFactory->buildPanel(this, "panel_preferences_graphics3.xml");
445}
446
447BOOL LLPanelDisplay2::postBuild()
448{
449
450 requires("ani", WIDGET_TYPE_CHECKBOX);
451 requires("gamma", WIDGET_TYPE_SPINNER);
452 requires("agp", WIDGET_TYPE_CHECKBOX);
453 requires("video card memory radio", WIDGET_TYPE_RADIO_GROUP);
454 requires("fog", WIDGET_TYPE_SPINNER);
455 requires("particles", WIDGET_TYPE_SPINNER);
456 requires("comp limit", WIDGET_TYPE_SPINNER);
457
458 if (!checkRequirements())
459 {
460 return FALSE;
461 }
462
463 //============================================================================
464 //Visual Enancements
465
466 // Anisotropic filtering checkbox
467 mCtrlAnisotropic = LLUICtrlFactory::getCheckBoxByName(this, "ani");
468
469 //============================================================================
470 // Gamma
471 mCtrlGamma = LLUICtrlFactory::getSpinnerByName(this, "gamma");
472
473 // Nighttime brigtness detail slider
474 mCtrlNighttimeBrightness = LLUICtrlFactory::getSpinnerByName(this, "nighttime_brightness");
475
476 //============================================================================
477 // Use AGP
478 mCtrlUseAGP = LLUICtrlFactory::getCheckBoxByName(this, "agp");
479
480 // Graphics Card Memory
481 mRadioVideoCardMem = LLUICtrlFactory::getRadioGroupByName(this, "video card memory radio");
482
483 // Fog ratio spin ctrl
484 mCtrlFogRatio = LLUICtrlFactory::getSpinnerByName(this, "fog");
485
486 // Particle count spin ctrl
487 mCtrlParticles = LLUICtrlFactory::getSpinnerByName(this, "particles");
488
489 // Avatar composite limit spin ctrl
490 mCtrlCompositeLimit = LLUICtrlFactory::getSpinnerByName(this, "comp limit");
491
492 refresh();
493
494 return TRUE;
495}
496
497
498LLPanelDisplay2::~LLPanelDisplay2()
499{
500 // Children all cleaned up by default view destructor.
501}
502
503void LLPanelDisplay2::refresh()
504{
505 LLPanel::refresh();
506
507 mUseAGP = gSavedSettings.getBOOL("RenderUseAGP");
508 mUseAniso = gSavedSettings.getBOOL("RenderAnisotropic");
509 mGamma = gSavedSettings.getF32("RenderGamma");
510 mBrightness = gSavedSettings.getF32("RenderNightBrightness");
511 mVideoCardMem = gSavedSettings.getS32("GraphicsCardMemorySetting");
512 mFogRatio = gSavedSettings.getF32("RenderFogRatio");
513 mParticleCount = gSavedSettings.getS32("RenderMaxPartCount");
514 mCompositeLimit = gSavedSettings.getS32("AvatarCompositeLimit");
515
516 refreshEnabledState();
517}
518
519void LLPanelDisplay2::refreshEnabledState()
520{
521 S32 max_setting = LLViewerImageList::getMaxVideoRamSetting();
522 max_setting = llclamp(max_setting, 0, 5);
523 for (S32 i=max_setting+1; i < mRadioVideoCardMem->getItemCount(); i++)
524 {
525 mRadioVideoCardMem->getRadioButton(i)->setEnabled(FALSE);
526 }
527
528 if (!gGLManager.mHasAnyAGP || !gFeatureManagerp->isFeatureAvailable("RenderAGP"))
529 {
530 mCtrlUseAGP->setEnabled(FALSE);
531 }
532}
533
534void LLPanelDisplay2::apply()
535{
536 // Anisotropic rendering
537 BOOL old_anisotropic = LLImageGL::sGlobalUseAnisotropic;
538 LLImageGL::sGlobalUseAnisotropic = mCtrlAnisotropic->get();
539 if (old_anisotropic != LLImageGL::sGlobalUseAnisotropic)
540 {
541 BOOL logged_in = (gStartupState >= STATE_STARTED);
542 gViewerWindow->restartDisplay(logged_in);
543 }
544
545
546 refresh();
547}
548
549
550void LLPanelDisplay2::cancel()
551{
552 gSavedSettings.setBOOL("RenderUseAGP", mUseAGP);
553 gSavedSettings.setBOOL("RenderAnisotropic", mUseAniso);
554 gSavedSettings.setF32("RenderGamma", mGamma);
555 gSavedSettings.setF32("RenderNightBrightness", mBrightness);
556 gSavedSettings.setS32("GraphicsCardMemorySetting", mVideoCardMem);
557 gSavedSettings.setF32("RenderFogRatio", mFogRatio);
558 gSavedSettings.setS32("RenderMaxPartCount", mParticleCount);
559 gSavedSettings.setS32("AvatarCompositeLimit", mCompositeLimit);
560}
561
562//============================================================================
563
564LLPanelDisplay3::LLPanelDisplay3()
565{
566 gUICtrlFactory->buildPanel(this, "panel_preferences_graphics2.xml");
567}
568
569BOOL LLPanelDisplay3::postBuild()
570{
571 requires("bumpshiny", WIDGET_TYPE_CHECKBOX);
572 requires("ripple", WIDGET_TYPE_CHECKBOX);
573 requires("avatarvp", WIDGET_TYPE_CHECKBOX);
574
575 requires("Avatar Appearance", WIDGET_TYPE_RADIO_GROUP);
576 requires("lighting detail radio", WIDGET_TYPE_RADIO_GROUP);
577 requires("terrain detail radio", WIDGET_TYPE_RADIO_GROUP);
578
579 requires("Prim LOD Factor", WIDGET_TYPE_SLIDER_BAR);
580 requires("Flex Factor", WIDGET_TYPE_SLIDER_BAR);
581 requires("Tree LOD Factor", WIDGET_TYPE_SLIDER_BAR);
582 requires("Avatar LOD Factor", WIDGET_TYPE_SLIDER_BAR);
583
584 if (!checkRequirements())
585 {
586 return FALSE;
587 }
588
589 //----------------------------------------------------------------------------
590 // Enable Bump/Shiny
591 mCtrlBumpShiny = LLUICtrlFactory::getCheckBoxByName(this, "bumpshiny");
592
593 //----------------------------------------------------------------------------
594 // Enable Ripple Water
595 mCtrlRippleWater = LLUICtrlFactory::getCheckBoxByName(this, "ripple");
596
597 //----------------------------------------------------------------------------
598 // Enable Avatar Shaders
599 mCtrlAvatarVP = LLUICtrlFactory::getCheckBoxByName(this, "avatarvp");
600 mCtrlAvatarVP->setCommitCallback(&LLPanelDisplay3::onVertexShaderEnable);
601 mCtrlAvatarVP->setCallbackUserData(this);
602
603 //----------------------------------------------------------------------------
604 // Avatar Render Mode
605 mCtrlAvatarMode = LLUICtrlFactory::getRadioGroupByName(this, "Avatar Appearance");
606
607 //----------------------------------------------------------------------------
608 // radio set for lighting detail
609 mRadioLightingDetail2 = LLUICtrlFactory::getRadioGroupByName(this, "lighting detail radio");
610
611 //----------------------------------------------------------------------------
612 // radio set for terrain detail mode
613 mRadioTerrainDetail = LLUICtrlFactory::getRadioGroupByName(this, "terrain detail radio");
614
615 //============================================================================
616
617 // Object detail slider
618 mCtrlLODFactor = LLUICtrlFactory::getSliderBarByName(this, "Prim LOD Factor");
619
620 // Flex object detail slider
621 mCtrlFlexFactor = LLUICtrlFactory::getSliderBarByName(this, "Flex Factor");
622
623 // Tree detail slider
624 mCtrlTreeFactor = LLUICtrlFactory::getSliderBarByName(this, "Tree LOD Factor");
625
626 // Avatar detail slider
627 mCtrlAvatarFactor = LLUICtrlFactory::getSliderBarByName(this, "Avatar LOD Factor");
628
629 refresh();
630
631 return TRUE;
632}
633
634
635LLPanelDisplay3::~LLPanelDisplay3()
636{
637}
638
639void LLPanelDisplay3::refresh()
640{
641 LLPanel::refresh();
642
643 mBumpShiny = gSavedSettings.getBOOL("RenderObjectBump");
644 mRippleWater = gSavedSettings.getBOOL("RenderRippleWater");
645 mAvatarVP = gSavedSettings.getBOOL("RenderAvatarVP");
646 mAvatarMode = gSavedSettings.getS32("RenderAvatarMode");
647 mLightingDetail = gSavedSettings.getS32("RenderLightingDetail");
648 mTerrainDetail = gSavedSettings.getS32("RenderTerrainDetail");
649 mPrimLOD = gSavedSettings.getF32("RenderVolumeLODFactor");
650 mFlexLOD = gSavedSettings.getF32("RenderFlexTimeFactor");
651 mTreeLOD = gSavedSettings.getF32("RenderTreeLODFactor");
652 mAvatarLOD = gSavedSettings.getF32("RenderAvatarLODFactor");
653
654 refreshEnabledState();
655}
656
657void LLPanelDisplay3::refreshEnabledState()
658{
659 // Ripple Water
660 if (gPipeline.getMaxVertexShaderLevel(LLPipeline::SHADER_ENVIRONMENT) < 2)
661 {
662 mCtrlRippleWater->setEnabled(FALSE);
663 }
664 // Avatar Mode
665 S32 max_avatar_shader = gPipeline.getMaxVertexShaderLevel(LLPipeline::SHADER_AVATAR);
666 if (max_avatar_shader == 0)
667 {
668 mCtrlAvatarVP->setEnabled(FALSE);
669 }
670 else
671 {
672 mCtrlAvatarVP->setEnabled(TRUE);
673 }
674
675 if (gSavedSettings.getBOOL("RenderAvatarVP") == FALSE)
676 {
677 max_avatar_shader = 1;
678 }
679
680 max_avatar_shader = llmax(max_avatar_shader, 1);
681
682 for (S32 i = 0; i < mCtrlAvatarMode->getItemCount(); i++)
683 {
684 mCtrlAvatarMode->setIndexEnabled(i, i < max_avatar_shader);
685 }
686}
687
688void LLPanelDisplay3::apply()
689{
690
691}
692
693void LLPanelDisplay3::setDefaults()
694{
695
696}
697
698void LLPanelDisplay3::cancel()
699{
700 gSavedSettings.setBOOL("RenderObjectBump", mBumpShiny);
701 gSavedSettings.setBOOL("RenderRippleWater", mRippleWater);
702 gSavedSettings.setBOOL("RenderAvatarVP", mAvatarVP);
703 gSavedSettings.setS32("RenderAvatarMode", mAvatarMode);
704 gSavedSettings.setS32("RenderLightingDetail", mLightingDetail);
705 gSavedSettings.setS32("RenderTerrainDetail", mTerrainDetail);
706 gSavedSettings.setF32("RenderVolumeLODFactor", mPrimLOD);
707 gSavedSettings.setF32("RenderFlexTimeFactor", mFlexLOD);
708 gSavedSettings.setF32("RenderTreeLODFactor", mTreeLOD);
709 gSavedSettings.setF32("RenderAvatarLODFactor", mAvatarLOD);
710}
711
712//static
713void LLPanelDisplay3::onVertexShaderEnable(LLUICtrl* self, void* data)
714{
715 ((LLPanelDisplay3*) data)->refreshEnabledState();
716}