57 TGLRnrCtx::TGLRnrCtx(TGLViewerBase* viewer) :
62 fViewerLOD (kLODUndef),
63 fSceneLOD (kLODUndef),
64 fCombiLOD (kLODUndef),
65 fShapeLOD (kLODUndef),
68 fViewerStyle (kStyleUndef),
69 fSceneStyle (kStyleUndef),
79 fDrawPass (kPassUndef),
84 fHasTimedOut (kFALSE),
86 fHighlight (kFALSE), fHighlightOutline (kFALSE),
87 fSelection (kFALSE), fSecSelection (kFALSE),
88 fSelectTransparents (kIfNoOpaques),
98 fDLCaptureOpen (kFALSE),
108 fColorSetStack =
new lpTGLColorSet_t;
109 fColorSetStack->push_back(0);
111 fSelectBuffer =
new TGLSelectBuffer;
115 fViewerLOD = fSceneLOD = fCombiLOD = fShapeLOD = kLODHigh;
116 fViewerStyle = fSceneStyle = kFill;
117 fDrawPass = kPassFill;
124 TGLRnrCtx::~TGLRnrCtx()
126 gluDeleteQuadric(fQuadric);
127 delete fPickRectangle;
128 delete fSelectBuffer;
129 delete fColorSetStack;
135 TGLSceneBase * TGLRnrCtx::GetScene()
137 return fSceneInfo->GetScene();
143 TGLSceneBase & TGLRnrCtx::RefScene()
145 return *fSceneInfo->GetScene();
153 Bool_t TGLRnrCtx::IsDrawPassFilled()
const
155 return fDrawPass == kPassFill || fDrawPass == kPassOutlineFill;
166 void TGLRnrCtx:: StartStopwatch()
173 fHasTimedOut = kFALSE;
179 void TGLRnrCtx:: StopStopwatch()
181 fHasTimedOut = fStopwatch.End() > fRenderTimeOut;
188 Bool_t TGLRnrCtx::HasStopwatchTimedOut()
190 if (fHasTimedOut)
return kTRUE;
191 if (fIsRunning && fStopwatch.Lap() > fRenderTimeOut)
192 fHasTimedOut = kTRUE;
205 void TGLRnrCtx::BeginSelection(Int_t x, Int_t y, Int_t r)
208 fSecSelection = kFALSE;
210 if (!fPickRectangle) fPickRectangle =
new TGLRect;
211 fPickRectangle->Set(x, y, r, r);
213 glSelectBuffer(fSelectBuffer->GetBufSize(), fSelectBuffer->GetBuf());
219 void TGLRnrCtx::EndSelection(Int_t glResult)
222 fSecSelection = kFALSE;
224 delete fPickRectangle; fPickRectangle = 0;
228 if (fSelectBuffer->CanGrow())
230 Warning(
"TGLRnrCtx::EndSelection",
231 "Select buffer size (%d) insufficient, doubling it.",
232 fSelectBuffer->GetBufSize());
233 fSelectBuffer->Grow();
237 Warning(
"TGLRnrCtx::EndSelection",
238 "Select buffer size (%d) insufficient. This is maximum.",
239 fSelectBuffer->GetBufSize());
242 fSelectBuffer->ProcessResult(glResult);
249 TGLRect * TGLRnrCtx::GetPickRectangle()
251 return fPickRectangle;
257 Int_t TGLRnrCtx::GetPickRadius()
270 void TGLRnrCtx::PushColorSet()
272 fColorSetStack->push_back(
new TGLColorSet(*fColorSetStack->back()));
278 TGLColorSet& TGLRnrCtx::ColorSet()
280 return * fColorSetStack->back();
287 void TGLRnrCtx::PopColorSet()
289 if (fColorSetStack->size() >= 2)
291 delete fColorSetStack->back();
292 fColorSetStack->pop_back();
296 Error(
"PopColorSet()",
"Attempting to remove the last entry.");
304 TGLColorSet* TGLRnrCtx::ChangeBaseColorSet(TGLColorSet* set)
306 TGLColorSet* old = fColorSetStack->front();
307 fColorSetStack->front() = set;
314 TGLColorSet* TGLRnrCtx::GetBaseColorSet()
316 return fColorSetStack->front();
323 void TGLRnrCtx::ColorOrForeground(Color_t col)
325 if (fColorSetStack->back()->Background().GetColorIndex() == col)
326 TGLUtil::Color(fColorSetStack->back()->Foreground());
338 void TGLRnrCtx::OpenDLCapture()
340 assert(fDLCaptureOpen == kFALSE);
341 fDLCaptureOpen = kTRUE;
347 void TGLRnrCtx::CloseDLCapture()
349 assert(fDLCaptureOpen == kTRUE);
350 fDLCaptureOpen = kFALSE;
359 void TGLRnrCtx::ReleaseFont(TGLFont& font)
361 fGLCtxIdentity->GetFontManager()->ReleaseFont(font);
367 void TGLRnrCtx::RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont& out)
369 fGLCtxIdentity->GetFontManager()->RegisterFont( size, file, (TGLFont::EMode)mode, out);
375 void TGLRnrCtx::RegisterFontNoScale(Int_t size,
const char* name, Int_t mode, TGLFont& out)
377 fGLCtxIdentity->GetFontManager()->RegisterFont(size, name, (TGLFont::EMode)mode, out);
384 void TGLRnrCtx::RegisterFont(Int_t size, Int_t file, Int_t mode, TGLFont& out)
386 RegisterFontNoScale(TMath::Nint(size*fRenderScale), file, mode, out);
393 void TGLRnrCtx::RegisterFont(Int_t size,
const char* name, Int_t mode, TGLFont& out)
395 RegisterFontNoScale(TMath::Nint(size*fRenderScale), name, mode, out);
405 GLUquadric *TGLRnrCtx::GetGluQuadric()
408 if ((fQuadric = gluNewQuadric())) {
409 gluQuadricOrientation(fQuadric, (GLenum)GLU_OUTSIDE);
410 gluQuadricNormals(fQuadric, (GLenum)GLU_SMOOTH);
412 Error(
"TGLRnrCtx::GetGluQuadric",
"gluNewQuadric failed");
423 void TGLRnrCtx::ProjectionMatrixPushIdentity()
425 glMatrixMode(GL_PROJECTION);
430 TGLRect rect(*GetPickRectangle());
431 GetCamera()->WindowToViewport(rect);
432 gluPickMatrix(rect.X(), rect.Y(), rect.Width(), rect.Height(),
433 (Int_t*) GetCamera()->RefViewport().CArr());
435 glMatrixMode(GL_MODELVIEW);
438 void TGLRnrCtx::ProjectionMatrixPop()
440 glMatrixMode(GL_PROJECTION);
442 glMatrixMode(GL_MODELVIEW);
453 const char* TGLRnrCtx::StyleName(Short_t style)
457 case TGLRnrCtx::kFill:
return "Filled Polys";
458 case TGLRnrCtx::kWireFrame:
return "Wireframe";
459 case TGLRnrCtx::kOutline:
return "Outline";
460 default:
return "Oogaa-dooga style";