llpaneldisplay.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 // file include
00035 #include "llpaneldisplay.h"
00036 
00037 // linden library includes
00038 #include "llerror.h"
00039 #include "llfontgl.h"
00040 #include "llrect.h"
00041 #include "llstring.h"
00042 
00043 // project includes
00044 #include "llagent.h"
00045 #include "llbutton.h"
00046 #include "llcheckboxctrl.h"
00047 #include "llcombobox.h"
00048 #include "lldrawpoolterrain.h"
00049 #include "llflexibleobject.h"
00050 #include "lllineeditor.h"
00051 #include "llradiogroup.h"
00052 #include "llresmgr.h"
00053 #include "llsliderctrl.h"
00054 #include "llspinctrl.h"
00055 #include "llstartup.h"
00056 #include "lltextbox.h"
00057 #include "llui.h"
00058 #include "llviewercamera.h"
00059 #include "llviewerimage.h"
00060 #include "llviewerimagelist.h"
00061 #include "llviewermessage.h"
00062 #include "llviewerobjectlist.h"
00063 #include "llviewerwindow.h"
00064 #include "llvoavatar.h"
00065 #include "llvovolume.h"
00066 #include "llvotree.h"
00067 #include "llvosky.h"
00068 #include "llwindow.h"
00069 #include "llworld.h"
00070 #include "pipeline.h"
00071 #include "llvieweruictrlfactory.h"
00072 #include "llfeaturemanager.h"
00073 #include "llglslshader.h"
00074 
00075 //RN temporary includes for resolution switching
00076 #include "llglheaders.h"
00077 #include "viewer.h"
00078 #include "llsky.h"
00079 
00080 const F32 MAX_USER_FAR_CLIP = 512.f;
00081 const F32 MIN_USER_FAR_CLIP = 64.f;
00082 
00083 const S32 ASPECT_RATIO_STR_LEN = 100;
00084 
00085 
00086 LLPanelDisplay::LLPanelDisplay()
00087 {
00088         gUICtrlFactory->buildPanel(this, "panel_preferences_graphics1.xml");
00089 }
00090 
00091 BOOL LLPanelDisplay::postBuild()
00092 {
00093         requires("windowed mode", WIDGET_TYPE_CHECKBOX);
00094         requires("fullscreen combo", WIDGET_TYPE_COMBO_BOX);
00095         requires("resolution_format", WIDGET_TYPE_TEXT_BOX);
00096         requires("aspect_ratio_text", WIDGET_TYPE_TEXT_BOX);
00097         requires("aspect_ratio", WIDGET_TYPE_COMBO_BOX);
00098         requires("aspect_auto_detect", WIDGET_TYPE_CHECKBOX);
00099         requires("UI Scale", WIDGET_TYPE_SLIDER);
00100         requires("ui_auto_scale", WIDGET_TYPE_CHECKBOX);
00101         requires("draw_distance", WIDGET_TYPE_SPINNER);
00102         requires("avfp", WIDGET_TYPE_CHECKBOX);
00103 
00104         if (!checkRequirements())
00105         {
00106                 return FALSE;
00107         }
00108 
00109         //============================================================================
00110         // Resolution
00111         
00112         // radio set for fullscreen size
00113         
00114         mCtrlWindowed = LLUICtrlFactory::getCheckBoxByName(this, "windowed mode");
00115         mCtrlWindowed->setCommitCallback(onCommitWindowedMode);
00116         mCtrlWindowed->setCallbackUserData(this);
00117 
00118         S32 num_resolutions = 0;
00119         LLWindow::LLWindowResolution* supported_resolutions = gViewerWindow->getWindow()->getSupportedResolutions(num_resolutions);
00120 
00121         S32 fullscreen_mode = num_resolutions - 1;
00122 
00123         mCtrlFullScreen = LLUICtrlFactory::getComboBoxByName(this, "fullscreen combo");
00124         
00125         LLUIString resolution_label = childGetText("resolution_format");
00126 
00127         for (S32 i = 0; i < num_resolutions; i++)
00128         {
00129                 resolution_label.setArg("[RES_X]", llformat("%d", supported_resolutions[i].mWidth));
00130                 resolution_label.setArg("[RES_Y]", llformat("%d", supported_resolutions[i].mHeight));
00131                 mCtrlFullScreen->add( resolution_label, ADD_BOTTOM );
00132         }
00133 
00134         {
00135                 BOOL targetFullscreen;
00136                 S32 targetWidth;
00137                 S32 targetHeight;
00138                 
00139                 gViewerWindow->getTargetWindow(targetFullscreen, targetWidth, targetHeight);
00140                 
00141                 if (targetFullscreen)
00142                 {
00143                         fullscreen_mode = 0; // default to 800x600
00144                         for (S32 i = 0; i < num_resolutions; i++)
00145                         {
00146                                 if (targetWidth == supported_resolutions[i].mWidth
00147                                 &&  targetHeight == supported_resolutions[i].mHeight)
00148                                 {
00149                                         fullscreen_mode = i;
00150                                 }
00151                         }
00152                         mCtrlFullScreen->setCurrentByIndex(fullscreen_mode);
00153                         mCtrlWindowed->set(FALSE);
00154                         mCtrlFullScreen->setEnabled(TRUE);
00155                 }
00156                 else
00157                 {
00158                         // set to windowed mode
00159                         //fullscreen_mode = mCtrlFullScreen->getItemCount() - 1;
00160                         mCtrlWindowed->set(TRUE);
00161                         mCtrlFullScreen->setCurrentByIndex(0);
00162                         mCtrlFullScreen->setEnabled(FALSE);
00163                 }
00164         }
00165 
00166         if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio"))
00167         {
00168                 mAspectRatio = gViewerWindow->getDisplayAspectRatio();
00169         }
00170         else
00171         {
00172                 mAspectRatio = gSavedSettings.getF32("FullScreenAspectRatio");
00173         }
00174 
00175         S32 numerator = 0;
00176         S32 denominator = 0;
00177         fractionFromDecimal(mAspectRatio, numerator, denominator);
00178 
00179         LLUIString aspect_ratio_text = childGetText("aspect_ratio_text");
00180         if (numerator != 0)
00181         {
00182                 aspect_ratio_text.setArg("[NUM]", llformat("%d",  numerator));
00183                 aspect_ratio_text.setArg("[DEN]", llformat("%d",  denominator));
00184         }
00185         else
00186         {
00187                 aspect_ratio_text = llformat("%.3f", mAspectRatio);
00188         }
00189 
00190         mCtrlAspectRatio = LLUICtrlFactory::getComboBoxByName(this, "aspect_ratio");
00191         mCtrlAspectRatio->setTextEntryCallback(onKeystrokeAspectRatio);
00192         mCtrlAspectRatio->setCommitCallback(onSelectAspectRatio);
00193         mCtrlAspectRatio->setCallbackUserData(this);
00194         // add default aspect ratios
00195         mCtrlAspectRatio->add(aspect_ratio_text, &mAspectRatio, ADD_TOP);
00196         mCtrlAspectRatio->setCurrentByIndex(0);
00197 
00198         mCtrlAutoDetectAspect = LLUICtrlFactory::getCheckBoxByName(this, "aspect_auto_detect");
00199         mCtrlAutoDetectAspect->setCommitCallback(onCommitAutoDetectAspect);
00200         mCtrlAutoDetectAspect->setCallbackUserData(this);
00201 
00202         refresh();
00203 
00204         return TRUE;
00205 }
00206 
00207 
00208 LLPanelDisplay::~LLPanelDisplay()
00209 {
00210         // clean up user data
00211         for (S32 i = 0; i < mCtrlAspectRatio->getItemCount(); i++)
00212         {
00213                 mCtrlAspectRatio->setCurrentByIndex(i);
00214         }
00215 }
00216 
00217 void LLPanelDisplay::refresh()
00218 {
00219         LLPanel::refresh();
00220         
00221         mFSAutoDetectAspect = gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio");
00222 
00223         mUIScaleFactor = gSavedSettings.getF32("UIScaleFactor");
00224         mUIAutoScale = gSavedSettings.getBOOL("UIAutoScale");
00225         
00226         // First Person Visibility
00227         mFirstPersonAvatarVisible = gSavedSettings.getBOOL("FirstPersonAvatarVisible");
00228 
00229         // Draw distance
00230         mRenderFarClip = gSavedSettings.getF32("RenderFarClip");
00231         
00232 }
00233 
00234 void LLPanelDisplay::cancel()
00235 {
00236         gSavedSettings.setBOOL("FullScreenAutoDetectAspectRatio", mFSAutoDetectAspect);
00237         gSavedSettings.setF32("UIScaleFactor", mUIScaleFactor);
00238         gSavedSettings.setBOOL("UIAutoScale", mUIAutoScale);
00239         gSavedSettings.setBOOL("FirstPersonAvatarVisible", mFirstPersonAvatarVisible);
00240         gSavedSettings.setF32("RenderFarClip", mRenderFarClip);
00241 }
00242 
00243 void LLPanelDisplay::apply()
00244 {
00245         applyResolution();
00246 }
00247 
00248 void LLPanelDisplay::onApplyResolution(LLUICtrl* src, void* user_data)
00249 {
00250         ((LLPanelDisplay*) src)->applyResolution();
00251 }
00252 
00253 void LLPanelDisplay::applyResolution()
00254 {
00255         char aspect_ratio_text[ASPECT_RATIO_STR_LEN];           /*Flawfinder: ignore*/
00256         if (mCtrlAspectRatio->getCurrentIndex() == -1)
00257         {
00258                 strncpy(aspect_ratio_text, mCtrlAspectRatio->getSimple().c_str(), sizeof(aspect_ratio_text) -1);        /*Flawfinder: ignore*/
00259                 aspect_ratio_text[sizeof(aspect_ratio_text) -1] = '\0';
00260                 char *element = strtok(aspect_ratio_text, ":/\\");
00261                 if (!element)
00262                 {
00263                         mAspectRatio = 0.f; // will be clamped later
00264                 }
00265                 else
00266                 {
00267                         LLLocale locale(LLLocale::USER_LOCALE);
00268                         mAspectRatio = (F32)atof(element);
00269                 }
00270 
00271                 // look for denominator
00272                 element = strtok(NULL, ":/\\");
00273                 if (element)
00274                 {
00275                         LLLocale locale(LLLocale::USER_LOCALE);
00276 
00277                         F32 denominator = (F32)atof(element);
00278                         if (denominator != 0.f)
00279                         {
00280                                 mAspectRatio /= denominator;
00281                         }
00282                 }
00283         }
00284         else
00285         {
00286                 mAspectRatio = (F32)mCtrlAspectRatio->getValue().asReal();
00287         }
00288 
00289         // presumably, user entered a non-numeric value if aspect_ratio == 0.f
00290         if (mAspectRatio != 0.f)
00291         {
00292                 mAspectRatio = llclamp(mAspectRatio, 0.2f, 5.f);
00293                 gSavedSettings.setF32("FullScreenAspectRatio", mAspectRatio);
00294                 if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio"))
00295                 {
00296                         gViewerWindow->getWindow()->setNativeAspectRatio(0.f);
00297                 }
00298                 else
00299                 {
00300                         gViewerWindow->getWindow()->setNativeAspectRatio(mAspectRatio);
00301                 }
00302         }
00303         gViewerWindow->reshape(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight());
00304 
00305         // Screen resolution
00306         S32 num_resolutions;
00307         LLWindow::LLWindowResolution* supported_resolutions = gViewerWindow->getWindow()->getSupportedResolutions(num_resolutions);
00308 
00309         // switching to windowed
00310         BOOL fullscreen = !mCtrlWindowed->get();
00311 
00312         // check if resolution has changed
00313         BOOL targetFullscreen;
00314         S32 targetWidth;
00315         S32 targetHeight;
00316         
00317         gViewerWindow->getTargetWindow(targetFullscreen, targetWidth, targetHeight);
00318 
00319         if ((fullscreen != targetFullscreen) ||
00320                 (fullscreen &&
00321                  (supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mWidth != targetWidth ||
00322                   supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mHeight != targetHeight)
00323                  ))
00324         {
00325                 // change fullscreen resolution or switch in/out of windowed mode
00326                 BOOL result;
00327 
00328                 BOOL logged_in = (LLStartUp::getStartupState() >= STATE_STARTED);
00329                 if (fullscreen)
00330                 {
00331                         result = gViewerWindow->changeDisplaySettings(TRUE, 
00332                                 LLCoordScreen(  supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mWidth, 
00333                                                                 supported_resolutions[mCtrlFullScreen->getCurrentIndex()].mHeight), 
00334                                 gSavedSettings.getBOOL("DisableVerticalSync"),
00335                                 logged_in);
00336                 }
00337                 else
00338                 {
00339                         result = gViewerWindow->changeDisplaySettings(FALSE, 
00340                                 LLCoordScreen(gSavedSettings.getS32("WindowWidth"), gSavedSettings.getS32("WindowHeight")), 
00341                                 TRUE,
00342                                 logged_in);
00343                 }
00344                 if (!result)
00345                 {
00346 
00347                         // GL is non-existent at this point, so we can't continue.
00348                         llerrs << "LLPanelDisplay::apply() failed" << llendl;
00349                 }
00350         }
00351 
00352         // force aspect ratio
00353         if (fullscreen && gCamera)
00354         {
00355                 gCamera->setAspect( gViewerWindow->getDisplayAspectRatio() );
00356         }
00357 
00358         if (gWorldPointer)
00359         {
00360                 send_agent_update(TRUE);
00361         }
00362 
00363         // Update enable/disable
00364         refresh();
00365 }
00366 
00367 //static 
00368 void LLPanelDisplay::onCommitWindowedMode(LLUICtrl* ctrl, void *data)
00369 {
00370         LLPanelDisplay *panel = (LLPanelDisplay*)data;
00371 
00372         BOOL windowed_mode = ((LLCheckBoxCtrl*)ctrl)->get();
00373 
00374         if (windowed_mode)
00375         {
00376                 panel->mCtrlFullScreen->setEnabled(FALSE);
00377         }
00378         else
00379         {
00380                 panel->mCtrlFullScreen->setEnabled(TRUE);
00381         }
00382 }
00383 
00384 //static
00385 void LLPanelDisplay::onCommitAutoDetectAspect(LLUICtrl *ctrl, void *data)
00386 {
00387         LLPanelDisplay *panel = (LLPanelDisplay*)data;
00388 
00389         BOOL auto_detect = ((LLCheckBoxCtrl*)ctrl)->get();
00390 
00391         if (auto_detect)
00392         {
00393                 S32 numerator = 0;
00394                 S32 denominator = 0;
00395                 // clear any aspect ratio override
00396                 gViewerWindow->mWindow->setNativeAspectRatio(0.f);
00397                 fractionFromDecimal(gViewerWindow->mWindow->getNativeAspectRatio(), numerator, denominator);
00398 
00399                 LLString aspect;
00400                 if (numerator != 0)
00401                 {
00402                         aspect = llformat("%d:%d", numerator, denominator);
00403                 }
00404                 else
00405                 {
00406                         aspect = llformat("%.3f", gViewerWindow->mWindow->getNativeAspectRatio());
00407                 }
00408 
00409                 panel->mCtrlAspectRatio->setLabel(aspect);
00410         }
00411 }
00412 
00413 //static 
00414 void LLPanelDisplay::onKeystrokeAspectRatio(LLLineEditor* caller, void* user_data)
00415 {
00416         LLPanelDisplay* panel = (LLPanelDisplay*)user_data;
00417 
00418         panel->mCtrlAutoDetectAspect->set(FALSE);
00419 }
00420 
00421 //static
00422 void LLPanelDisplay::onSelectAspectRatio(LLUICtrl*, void* user_data)
00423 {
00424         LLPanelDisplay* panel = (LLPanelDisplay*)user_data;
00425 
00426         panel->mCtrlAutoDetectAspect->set(FALSE);
00427 }
00428 
00429 //static
00430 void LLPanelDisplay::fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator)
00431 {
00432         numerator = 0;
00433         denominator = 0;
00434         for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f)
00435         {
00436                 if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f)
00437                 {
00438                         numerator = llround(decimal_val * test_denominator);
00439                         denominator = llround(test_denominator);
00440                         break;
00441                 }
00442         }
00443 }
00444 
00445 //============================================================================
00446 
00447 LLPanelDisplay2::LLPanelDisplay2()
00448 {
00449         gUICtrlFactory->buildPanel(this, "panel_preferences_graphics3.xml");
00450 }
00451 
00452 BOOL LLPanelDisplay2::postBuild()
00453 {
00454         requires("ani", WIDGET_TYPE_CHECKBOX);
00455         requires("gamma", WIDGET_TYPE_SPINNER);
00456         requires("vbo", WIDGET_TYPE_CHECKBOX);
00457         requires("video card memory radio", WIDGET_TYPE_RADIO_GROUP);
00458         requires("fog", WIDGET_TYPE_SPINNER);
00459         requires("particles", WIDGET_TYPE_SPINNER);
00460         requires("comp limit", WIDGET_TYPE_SPINNER);
00461         requires("debug beacon line width", WIDGET_TYPE_SPINNER);
00462 
00463         if (!checkRequirements())
00464         {
00465                 return FALSE;
00466         }
00467 
00468         // Graphics Card Memory
00469         mRadioVideoCardMem = LLUICtrlFactory::getRadioGroupByName(this, "video card memory radio");
00470         mCtrlStereoMode = LLUICtrlFactory::getRadioGroupByName(this, "stereo mode");
00471 
00472 #if !LL_WINDOWS
00473         // The probe_hardware_checkbox setting is only used in the Windows build
00474         // (It apparently controls a time-consuming DX9 hardware probe.)
00475         // Disable the checkbox everywhere else
00476         gSavedSettings.setBOOL("ProbeHardwareOnStartup", FALSE );
00477         childSetEnabled("probe_hardware_checkbox", false);
00478 #endif // !LL_WINDOWS
00479 
00480         refresh();
00481 
00482         return TRUE;
00483 }
00484 
00485 
00486 LLPanelDisplay2::~LLPanelDisplay2()
00487 {
00488         // Children all cleaned up by default view destructor.
00489 }
00490 
00491 void LLPanelDisplay2::refresh()
00492 {
00493         LLPanel::refresh();
00494 
00495         mUseVBO = gSavedSettings.getBOOL("RenderVBOEnable");
00496         mUseAniso = gSavedSettings.getBOOL("RenderAnisotropic");
00497         mGamma = gSavedSettings.getF32("RenderGamma");
00498         mBrightness = gSavedSettings.getF32("RenderNightBrightness");
00499         mVideoCardMem = gSavedSettings.getS32("GraphicsCardMemorySetting");
00500         mFogRatio = gSavedSettings.getF32("RenderFogRatio");
00501         mParticleCount = gSavedSettings.getS32("RenderMaxPartCount");
00502         mCompositeLimit = gSavedSettings.getS32("AvatarCompositeLimit");
00503         mDebugBeaconLineWidth = gSavedSettings.getS32("DebugBeaconLineWidth");
00504         mStereoMode = gSavedSettings.getS32("StereoMode");
00505         mStereoFocalDistance = gSavedSettings.getF32("StereoFocalDistance");
00506         mStereoEyeSeparation = gSavedSettings.getF32("StereoEyeSeparation");
00507         mProbeHardwareOnStartup = gSavedSettings.getBOOL("ProbeHardwareOnStartup");
00508 
00509         refreshEnabledState();
00510 }
00511 
00512 void LLPanelDisplay2::refreshEnabledState()
00513 {
00514         S32 max_setting = LLViewerImageList::getMaxVideoRamSetting();
00515         max_setting = llclamp(max_setting, 0, 5);
00516         for (S32 i=max_setting+1; i < mRadioVideoCardMem->getItemCount(); i++)
00517         {
00518                 mRadioVideoCardMem->getRadioButton(i)->setEnabled(FALSE);
00519         }
00520 
00521         if (!gFeatureManagerp->isFeatureAvailable("RenderVBO") ||
00522                 !gGLManager.mHasVertexBufferObject)
00523         {
00524                 childSetEnabled("vbo", FALSE);
00525         }
00526 }
00527 
00528 void LLPanelDisplay2::apply()
00529 {
00530 
00531         // Anisotropic rendering
00532         BOOL old_anisotropic = LLImageGL::sGlobalUseAnisotropic;
00533         LLImageGL::sGlobalUseAnisotropic = childGetValue("ani");
00534         if (old_anisotropic != LLImageGL::sGlobalUseAnisotropic)
00535         {
00536                 BOOL logged_in = (LLStartUp::getStartupState() >= STATE_STARTED);
00537                 gViewerWindow->restartDisplay(logged_in);
00538         }
00539 
00540         mStereoMode = (S32)mCtrlStereoMode->getValue().asInteger();
00541 
00542         refresh();
00543 }
00544 
00545 
00546 void LLPanelDisplay2::cancel()
00547 {
00548         gSavedSettings.setBOOL("RenderVBOEnable", mUseVBO);
00549         gSavedSettings.setBOOL("RenderAnisotropic", mUseAniso);
00550         gSavedSettings.setF32("RenderGamma", mGamma);
00551         gSavedSettings.setF32("RenderNightBrightness", mBrightness);
00552         gSavedSettings.setS32("GraphicsCardMemorySetting", mVideoCardMem);
00553         gSavedSettings.setF32("RenderFogRatio", mFogRatio);
00554         gSavedSettings.setS32("RenderMaxPartCount", mParticleCount);
00555         gSavedSettings.setS32("AvatarCompositeLimit", mCompositeLimit);
00556         gSavedSettings.setS32("DebugBeaconLineWidth", mDebugBeaconLineWidth);
00557         gSavedSettings.setS32("StereoMode", mStereoMode);
00558         gSavedSettings.setF32("StereoEyeSeparation", mStereoEyeSeparation);
00559         gSavedSettings.setF32("StereoFocalDistance", mStereoFocalDistance);
00560         gSavedSettings.setBOOL("ProbeHardwareOnStartup", mProbeHardwareOnStartup );
00561 }
00562 
00563 //============================================================================
00564 
00565 LLPanelDisplay3::LLPanelDisplay3()
00566 {
00567         gUICtrlFactory->buildPanel(this, "panel_preferences_graphics2.xml");
00568 }
00569 
00570 BOOL LLPanelDisplay3::postBuild()
00571 {
00572         requires("bumpshiny", WIDGET_TYPE_CHECKBOX);
00573         requires("ripple", WIDGET_TYPE_CHECKBOX);
00574         requires("avatarvp", WIDGET_TYPE_CHECKBOX);
00575         requires("shaders", WIDGET_TYPE_CHECKBOX);
00576         
00577         requires("Avatar Appearance", WIDGET_TYPE_RADIO_GROUP);
00578         requires("lighting detail radio", WIDGET_TYPE_RADIO_GROUP);
00579         requires("terrain detail radio", WIDGET_TYPE_RADIO_GROUP);
00580 
00581         requires("Prim LOD Factor", WIDGET_TYPE_SLIDER_BAR);
00582         requires("Flex Factor", WIDGET_TYPE_SLIDER_BAR);
00583         requires("Tree LOD Factor", WIDGET_TYPE_SLIDER_BAR);
00584         requires("Avatar LOD Factor", WIDGET_TYPE_SLIDER_BAR);
00585         
00586         if (!checkRequirements())
00587         {
00588                 return FALSE;
00589         }
00590 
00591         //----------------------------------------------------------------------------
00592         // Enable Bump/Shiny
00593         mCtrlBumpShiny = LLUICtrlFactory::getCheckBoxByName(this, "bumpshiny");
00594         
00595         //----------------------------------------------------------------------------
00596         // Enable Ripple Water
00597         mCtrlRippleWater = LLUICtrlFactory::getCheckBoxByName(this, "ripple");
00598         
00599         //----------------------------------------------------------------------------
00600         // Enable Avatar Shaders
00601         mCtrlAvatarVP = LLUICtrlFactory::getCheckBoxByName(this, "avatarvp");
00602         mCtrlAvatarVP->setCommitCallback(&LLPanelDisplay3::onVertexShaderEnable);
00603         mCtrlAvatarVP->setCallbackUserData(this);
00604 
00605         //----------------------------------------------------------------------------
00606         // Avatar Render Mode
00607         mCtrlAvatarMode = LLUICtrlFactory::getRadioGroupByName(this, "Avatar Appearance");
00608         
00609         //----------------------------------------------------------------------------
00610         // radio set for lighting detail
00611         mRadioLightingDetail2 = LLUICtrlFactory::getRadioGroupByName(this, "lighting detail radio");
00612 
00613         //----------------------------------------------------------------------------
00614         // radio set for terrain detail mode
00615         mRadioTerrainDetail = LLUICtrlFactory::getRadioGroupByName(this, "terrain detail radio");
00616 
00617         //----------------------------------------------------------------------------
00618         // Global Shader Enable
00619         mCtrlShaderEnable = LLUICtrlFactory::getCheckBoxByName(this, "shaders");
00620         mCtrlShaderEnable->setCommitCallback(&LLPanelDisplay3::onVertexShaderEnable);
00621         mCtrlShaderEnable->setCallbackUserData(this);
00622 
00623         
00624         //============================================================================
00625 
00626         // Object detail slider
00627         mCtrlLODFactor = LLUICtrlFactory::getSliderBarByName(this, "Prim LOD Factor");
00628         
00629         // Flex object detail slider
00630         mCtrlFlexFactor = LLUICtrlFactory::getSliderBarByName(this, "Flex Factor");
00631         
00632         // Tree detail slider
00633         mCtrlTreeFactor = LLUICtrlFactory::getSliderBarByName(this, "Tree LOD Factor");
00634         
00635         // Avatar detail slider
00636         mCtrlAvatarFactor = LLUICtrlFactory::getSliderBarByName(this, "Avatar LOD Factor");
00637         
00638         refresh();
00639         
00640         return TRUE;
00641 }
00642 
00643 
00644 LLPanelDisplay3::~LLPanelDisplay3()
00645 {
00646 }
00647 
00648 void LLPanelDisplay3::refresh()
00649 {
00650         LLPanel::refresh();
00651         
00652         mBumpShiny = gSavedSettings.getBOOL("RenderObjectBump");
00653         mRippleWater = gSavedSettings.getBOOL("RenderRippleWater");
00654         mAvatarVP = gSavedSettings.getBOOL("RenderAvatarVP");
00655         mShaderEnable = gSavedSettings.getBOOL("VertexShaderEnable");
00656         mAvatarMode = gSavedSettings.getS32("RenderAvatarMode");
00657         mLightingDetail = gSavedSettings.getS32("RenderLightingDetail");
00658         mTerrainDetail =  gSavedSettings.getS32("RenderTerrainDetail");
00659         mPrimLOD = gSavedSettings.getF32("RenderVolumeLODFactor");
00660         mFlexLOD = gSavedSettings.getF32("RenderFlexTimeFactor");
00661         mTreeLOD = gSavedSettings.getF32("RenderTreeLODFactor");
00662         mAvatarLOD = gSavedSettings.getF32("RenderAvatarLODFactor");
00663 
00664         refreshEnabledState();
00665 }
00666 
00667 void LLPanelDisplay3::refreshEnabledState()
00668 {
00669         // Ripple Water
00670         bool ripple = (LLShaderMgr::getMaxVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT) >= 2) && gGLManager.mHasCubeMap && gFeatureManagerp->isFeatureAvailable("RenderCubeMap");
00671         mCtrlRippleWater->setEnabled(ripple ? TRUE : FALSE);
00672 
00673         // Bump & Shiny
00674         bool bumpshiny = gGLManager.mHasCubeMap && gFeatureManagerp->isFeatureAvailable("RenderCubeMap") && gFeatureManagerp->isFeatureAvailable("RenderObjectBump");
00675         mCtrlBumpShiny->setEnabled(bumpshiny ? TRUE : FALSE);
00676 
00677         // Avatar Mode
00678         S32 max_avatar_shader = LLShaderMgr::getMaxVertexShaderLevel(LLShaderMgr::SHADER_AVATAR);
00679         mCtrlAvatarVP->setEnabled((max_avatar_shader > 0) ? TRUE : FALSE);
00680         
00681         if (gSavedSettings.getBOOL("RenderAvatarVP") == FALSE)
00682         {
00683                 max_avatar_shader = 1;
00684         }
00685         max_avatar_shader = llmax(max_avatar_shader, 1);
00686         for (S32 i = 0; i < mCtrlAvatarMode->getItemCount(); i++)
00687         {
00688                 mCtrlAvatarMode->setIndexEnabled(i, i < max_avatar_shader);
00689         }
00690         if (mCtrlAvatarMode->getSelectedIndex() >= max_avatar_shader)
00691         {
00692                 mCtrlAvatarMode->setSelectedIndex(llmax(max_avatar_shader-1,0));
00693         }
00694         // Vertex Shaders
00695         mCtrlShaderEnable->setEnabled(gPipeline.canUseVertexShaders());
00696 }
00697 
00698 void LLPanelDisplay3::apply()
00699 {
00700         
00701 }
00702 
00703 void LLPanelDisplay3::setDefaults()
00704 {
00705 
00706 }
00707 
00708 void LLPanelDisplay3::cancel()
00709 {
00710         gSavedSettings.setBOOL("RenderObjectBump", mBumpShiny);
00711         gSavedSettings.setBOOL("RenderRippleWater", mRippleWater);
00712         gSavedSettings.setBOOL("RenderAvatarVP", mAvatarVP);
00713         gSavedSettings.setS32("RenderAvatarMode", mAvatarMode);
00714         gSavedSettings.setS32("RenderLightingDetail", mLightingDetail);
00715         gSavedSettings.setS32("RenderTerrainDetail", mTerrainDetail);
00716         gSavedSettings.setF32("RenderVolumeLODFactor", mPrimLOD);
00717         gSavedSettings.setF32("RenderFlexTimeFactor", mFlexLOD);
00718         gSavedSettings.setF32("RenderTreeLODFactor", mTreeLOD);
00719         gSavedSettings.setF32("RenderAvatarLODFactor", mAvatarLOD);
00720 }
00721 
00722 //static
00723 void LLPanelDisplay3::onVertexShaderEnable(LLUICtrl* self, void* data)
00724 {
00725         ((LLPanelDisplay3*) data)->refreshEnabledState();
00726 }

Generated on Thu Jul 1 06:08:56 2010 for Second Life Viewer by  doxygen 1.4.7