|
From: Tupone A. <at...@us...> - 2007-02-28 23:49:07
|
Update of /cvsroot/bzflag/bzflag/src/bzflag In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9336 Modified Files: Tag: v2_0_cs_branch DisplayMenu.cxx MainWindow.cxx MainWindow.h bzflag.cxx Log Message: Fixing segfault accessing to gamma functions Index: DisplayMenu.cxx =================================================================== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/DisplayMenu.cxx,v retrieving revision 2.12.2.6 retrieving revision 2.12.2.6.2.1 diff -w -u -r2.12.2.6 -r2.12.2.6.2.1 --- DisplayMenu.cxx 26 Jan 2006 19:24:00 -0000 2.12.2.6 +++ DisplayMenu.cxx 28 Feb 2007 23:48:58 -0000 2.12.2.6.2.1 @@ -210,7 +210,7 @@ option->setFontFace(fontFace); option->setLabel("Brightness:"); option->setCallback(callback, (void*)"g"); - if (window->hasGammaControl()) { + if (getMainWindow()->hasGammaControl()) { option->createSlider(15); } else { options = &option->getList(); @@ -336,9 +336,9 @@ } // brightness - BzfWindow* window = getMainWindow()->getWindow(); - if (window->hasGammaControl()) - ((HUDuiList*)listHUD[i])->setIndex(gammaToIndex(window->getGamma())); + if (getMainWindow()->hasGammaControl()) + ((HUDuiList*)listHUD[i]) + ->setIndex(gammaToIndex(getMainWindow()->getGamma())); i++; // energy saver @@ -436,9 +436,7 @@ BZDB.setBool("saveEnergy", list->getIndex() != 0); break; case 'g': - BzfWindow* window = getMainWindow()->getWindow(); - if (window->hasGammaControl()) - window->setGamma(indexToGamma(list->getIndex())); + getMainWindow()->setGamma(indexToGamma(list->getIndex())); break; } } Index: MainWindow.cxx =================================================================== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/MainWindow.cxx,v retrieving revision 2.6.2.1.2.4 retrieving revision 2.6.2.1.2.5 diff -w -u -r2.6.2.1.2.4 -r2.6.2.1.2.5 --- MainWindow.cxx 28 Feb 2007 22:20:49 -0000 2.6.2.1.2.4 +++ MainWindow.cxx 28 Feb 2007 23:48:58 -0000 2.6.2.1.2.5 @@ -56,6 +56,15 @@ (csApplicationFramework::GetObjectRegistry()); if (!kbd) csApplicationFramework::ReportError("Failed to locate Keyboard Driver!"); + + g3d = csQueryRegistry<iGraphics3D> + (csApplicationFramework::GetObjectRegistry()); + if (!g3d) + csApplicationFramework::ReportError("Failed to locate 3D Graphic Driver!"); + + g2d = g3d->GetDriver2D(); + + hasGamma = g2d->SetGamma(g2d->GetGamma()); } MainWindow::~MainWindow() @@ -338,6 +347,18 @@ alt = (kbd->GetModifierState(CSKEY_ALT) != 0); } +bool MainWindow::hasGammaControl() { + return hasGamma; +} + +float MainWindow::getGamma() { + return g2d->GetGamma(); +} + +void MainWindow::setGamma(float gamma) { + g2d->SetGamma(gamma); +} + // Local Variables: *** // mode:C++ *** // tab-width: 8 *** Index: MainWindow.h =================================================================== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/MainWindow.h,v retrieving revision 2.4.2.1.2.3 retrieving revision 2.4.2.1.2.4 diff -w -u -r2.4.2.1.2.3 -r2.4.2.1.2.4 --- MainWindow.h 27 Feb 2007 21:13:05 -0000 2.4.2.1.2.3 +++ MainWindow.h 28 Feb 2007 23:48:58 -0000 2.4.2.1.2.4 @@ -89,6 +89,9 @@ void initJoystick(std::string &joystickName); void getModState(bool &shift, bool &ctrl, bool &alt); + bool hasGammaControl(); + float getGamma(); + void setGamma(float gamma); private: // no copying @@ -119,8 +122,15 @@ uint joystickXAxis; uint joystickYAxis; + bool hasGamma; + /// A pointer to the keyboard driver. csRef<iKeyboardDriver> kbd; + + /// A pointer to the 3D graphic driver. + csRef<iGraphics3D> g3d; + /// A pointer to the 2D graphic driver. + csRef<iGraphics2D> g2d; }; // Index: bzflag.cxx =================================================================== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/bzflag.cxx,v retrieving revision 2.62.2.8.2.15 retrieving revision 2.62.2.8.2.16 diff -w -u -r2.62.2.8.2.15 -r2.62.2.8.2.16 --- bzflag.cxx 27 Feb 2007 21:13:05 -0000 2.62.2.8.2.15 +++ bzflag.cxx 28 Feb 2007 23:48:58 -0000 2.62.2.8.2.16 @@ -472,9 +472,9 @@ BZDB.set("volume", TextUtils::format("%d", getSoundVolume())); } - if (RENDERER.getWindow().getWindow()->hasGammaControl()) { + if (RENDERER.getWindow().hasGammaControl()) { BZDB.set("gamma", - TextUtils::format("%f", RENDERER.getWindow().getWindow()->getGamma())); + TextUtils::format("%f", RENDERER.getWindow().getGamma())); } BZDB.set("quality", configQualityValues[RENDERER.useQuality()]); @@ -1097,8 +1097,7 @@ // set gamma if set in resources and we have gamma control if (BZDB.isSet("gamma")) { - if (pmainWindow->getWindow()->hasGammaControl()) - g2d->SetGamma((float)atof(BZDB.get("gamma").c_str())); + pmainWindow->setGamma((float)atof(BZDB.get("gamma").c_str())); } // set the scene renderer's window |