diff --git a/gl/inc/TGLViewer.h b/gl/inc/TGLViewer.h index 8f25d329d337134970a72ac044d484cfae33b133..ddb0fa59da66140795fc665dcdef4b2719ea0a1e 100644 --- a/gl/inc/TGLViewer.h +++ b/gl/inc/TGLViewer.h @@ -1,4 +1,4 @@ -// @(#)root/gl:$Name: $:$Id: TGLViewer.h,v 1.33 2006/10/11 10:26:23 rdm Exp $ +// @(#)root/gl:$Name: $:$Id: TGLViewer.h,v 1.34 2006/12/09 23:06:32 rdm Exp $ // Author: Richard Maunder 25/05/2005 /************************************************************************* @@ -91,7 +91,8 @@ public: kLightBottom = 0x00000004, kLightLeft = 0x00000008, kLightRight = 0x00000010, - kLightMask = 0x0000001f }; + kLightMask = 0x0000001f, + kLightSpecular = 0x00000100}; enum EAxesType { kAxesNone, kAxesEdge, kAxesOrigin }; @@ -164,6 +165,8 @@ protected: UInt_t fRejectedPhysicals; //! number of physicals rejected in last rebuild Bool_t fIsPrinting; + Bool_t fUseSpecular; + /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// diff --git a/gl/inc/TGLViewerEditor.h b/gl/inc/TGLViewerEditor.h index 8de5156cd9d0bb926e593ad37ba3d6ff1ee1adb8..20717bbd26b1ff310237e5841e152ae75b5701ea 100644 --- a/gl/inc/TGLViewerEditor.h +++ b/gl/inc/TGLViewerEditor.h @@ -35,6 +35,8 @@ private: TGButton *fLeftLight; TGButton *fFrontLight; + TGButton *fSpecularLight; + TGColorSelect *fClearColor; TGCheckButton *fIgnoreSizesOnUpdate; TGCheckButton *fResetCamerasOnUpdate; diff --git a/gl/src/TGLViewer.cxx b/gl/src/TGLViewer.cxx index 7a6f8aa9b3c517d0d96d97d3609fa8735cd33315..3cf08273cb888508e804b315d066edea9bab8682 100644 --- a/gl/src/TGLViewer.cxx +++ b/gl/src/TGLViewer.cxx @@ -1,4 +1,4 @@ -// @(#)root/gl:$Name: $:$Id: TGLViewer.cxx,v 1.54 2006/10/05 18:19:09 brun Exp $ +// @(#)root/gl:$Name: $:$Id: TGLViewer.cxx,v 1.55 2006/12/09 23:06:32 rdm Exp $ // Author: Richard Maunder 25/05/2005 /************************************************************************* @@ -109,6 +109,7 @@ TGLViewer::TGLViewer(TVirtualPad * pad, Int_t x, Int_t y, fAcceptedPhysicals(0), fRejectedPhysicals(0), fIsPrinting(kFALSE), + fUseSpecular(kTRUE), fGLWindow(0), fGLDevice(-1), fPadEditor(0), @@ -158,6 +159,7 @@ TGLViewer::TGLViewer(TVirtualPad * pad) : fAcceptedPhysicals(0), fRejectedPhysicals(0), fIsPrinting(kFALSE), + fUseSpecular(kTRUE), fGLWindow(0), fGLDevice(fPad->GetGLDevice()), fPadEditor(0), @@ -959,6 +961,13 @@ void TGLViewer::SetupLights() Float_t sideLightColor[] = {0.7, 0.7, 0.7, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, pos0); glLightfv(GL_LIGHT0, GL_DIFFUSE, frontLightColor); + if (fUseSpecular) { + const Float_t whiteSpec[] = {1.f, 1.f, 1.f, 1.f}; + glLightfv(GL_LIGHT0, GL_SPECULAR, whiteSpec); + } else { + const Float_t nullSpec[] = {0.f, 0.f, 0.f, 1.f}; + glLightfv(GL_LIGHT0, GL_SPECULAR, nullSpec); + } glLightfv(GL_LIGHT1, GL_POSITION, pos1); glLightfv(GL_LIGHT1, GL_DIFFUSE, sideLightColor); glLightfv(GL_LIGHT2, GL_POSITION, pos2); @@ -1464,15 +1473,17 @@ void TGLViewer::ToggleLight(ELight light) // N.B. We can't directly call glEnable here as may not be in correct gl context // adjust mask and set when drawing - if (light >= kLightMask) { + if (light == kLightSpecular) { + fUseSpecular = !fUseSpecular; + } else if (light >= kLightMask) { Error("TGLViewer::ToggleLight", "invalid light type"); return; + } else { + fLightState ^= light; + if (fGLDevice != -1) + gGLManager->MarkForDirectCopy(fGLDevice, kTRUE); } - fLightState ^= light; - if (fGLDevice != -1) - gGLManager->MarkForDirectCopy(fGLDevice, kTRUE); - RequestDraw(); } diff --git a/gl/src/TGLViewerEditor.cxx b/gl/src/TGLViewerEditor.cxx index 5b2af210385d2485809b8a073d7601eb92ae79bc..ad325552c6bd7f53869c5fefc7793703f806f99b 100644 --- a/gl/src/TGLViewerEditor.cxx +++ b/gl/src/TGLViewerEditor.cxx @@ -35,6 +35,7 @@ TGLViewerEditor::TGLViewerEditor(const TGWindow *p, Int_t width, Int_t height, fBottomLight(0), fLeftLight(0), fFrontLight(0), + fSpecularLight(0), fClearColor(0), fIgnoreSizesOnUpdate(0), fResetCamerasOnUpdate(0), @@ -90,6 +91,8 @@ void TGLViewerEditor::ConnectSignals2Slots() fLeftLight->Connect("Clicked()", "TGLViewerEditor", this, "DoButton()"); fFrontLight->Connect("Clicked()", "TGLViewerEditor", this, "DoButton()"); + fSpecularLight->Connect("Clicked()", "TGLViewerEditor", this, "DoButton()"); + fClearColor->Connect("ColorSelected(Pixel_t)", "TGLViewerEditor", this, "DoClearColor(Pixel_t)"); fIgnoreSizesOnUpdate->Connect("Toggled(Bool_t)", "TGLViewerEditor", this, "DoIgnoreSizesOnUpdate()"); fResetCamerasOnUpdate->Connect("Toggled(Bool_t)", "TGLViewerEditor", this, "DoResetCamerasOnUpdate()"); @@ -279,6 +282,11 @@ void TGLViewerEditor::CreateLightsTab() { TGHorizontalFrame* hf = new TGHorizontalFrame(this); + fSpecularLight = new TGCheckButton(hf, "Specular light", TGLViewer::kLightSpecular); + fSpecularLight->SetState(kButtonDown); + hf->AddFrame(fSpecularLight, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 1, 1, 1)); + AddFrame(hf, new TGLayoutHints(kLHintsLeft, 2, 1, 1, 1)); + hf = new TGHorizontalFrame(this); TGLabel* lab = new TGLabel(hf, "Clear color"); hf->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 12, 1, 3)); fClearColor = new TGColorSelect(hf, 0, -1);