ROOT  6.06/09
Reference Guide
TGLWidget.cxx
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Timur Pocheptsov, Jun 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include <stdexcept>
13 #include <vector>
14 
15 #include "TVirtualX.h"
16 #include "TGClient.h"
17 #include "TError.h"
18 #include "TROOT.h"
19 #include "TVirtualMutex.h"
20 
21 #include "TGLWidget.h"
22 #include "TGLIncludes.h"
23 #include "TGLWSIncludes.h"
24 #include "TGLUtil.h"
25 #include "TGLEventHandler.h"
26 #include "RConfigure.h"
27 
28 /** \class TGLWidget
29 \ingroup opengl
30 GL window with context. _Must_ _have_ a parent window
31 (the 'parent' parameter of ctors). The current version inherits
32 TGCanvas (I'm not sure about future versions), probably, in future
33 multiple inheritance will be added - the second
34 base class will be TGLPaintDevice or something like this.
35 
36 Usage:
37  - Simply create TGLWidget as an embedded widget, and
38  connect your slots to signals you need: HandleExpose, HandleConfigureNotify, etc.
39  In your slots you can use gl API directly - under Win32 TGLWidget switches
40  between threads internally (look TGLPShapeObjEditor for such usage).
41  - You can write your own class, derived from TGLWidget, with PaintGL and InitGL
42  overriden.
43 
44 Resources (and invariants):
45  - fContainer (TGLWidgetContainer) - controlled by std::auto_ptr
46  - fWindowIndex - controlled manually (see CreateWidget and dtor)
47  - fGLContext - controlled manually (see CreateWidget and dtor)
48  - visual info for X11 version, controlled manually (see CreateGLContainer and dtor)
49 
50 Exceptions:
51  - can be thrown only during construction.
52  - under win32 class does not throw itself (but some internal operations can throw)
53  - under X11 can throw std::runtime_error (from CreateGLContext).
54  - In case of exceptions resources will be freed.
55 
56 TGLWidget object is immutable as far as it was created.
57 
58 Boolean parameter defines, if you want to grab user's input or not.
59 By default you want, but for example when not - see TGLPShapeObjEditor.
60 
61 Non-copyable.
62 */
63 
65 
66 //==============================================================================
67 // TGLWidget - system-independent methods
68 //==============================================================================
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// Static constructor for creating widget with default pixel format.
72 
74 {
76 
77  return Create(format, gClient->GetDefaultRoot(), kFALSE, kFALSE, 0, 1, 1);
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Static constructor for creating widget with default pixel format.
82 
83 TGLWidget* TGLWidget::Create(const TGWindow* parent, Bool_t selectInput,
84  Bool_t shareDefault, const TGLPaintDevice *shareDevice,
85  UInt_t width, UInt_t height)
86 {
88 
89  return Create(format, parent, selectInput, shareDefault, shareDevice,
90  width, height);
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Static constructor for creating widget with given pixel format.
95 
97  const TGWindow* parent, Bool_t selectInput,
98  Bool_t shareDefault, const TGLPaintDevice *shareDevice,
99  UInt_t width, UInt_t height)
100 {
101  // Make sure window-system dependent part of GL-util is initialized.
103 
104  std::pair<void *, void *> innerData;
105 
106  Window_t wid = CreateWindow(parent, format, width, height, innerData);
107 
108  TGLWidget* glw = new TGLWidget(wid, parent, selectInput);
109 
110 #ifdef WIN32
111  glw->fWindowIndex = (Int_t) innerData.second;
112 #elif defined(R__HAS_COCOA)
113  glw->fWindowIndex = wid;
114 #else
115  glw->fWindowIndex = gVirtualX->AddWindow(wid, width, height);
116  glw->fInnerData = innerData;
117 #endif
118  glw->fGLFormat = format;
119 
120  try
121  {
122  glw->SetFormat();
123  glw->fGLContext = new TGLContext
124  (glw, shareDefault, shareDevice && !shareDefault ? shareDevice->GetContext() : 0);
125  }
126  catch (const std::exception &)
127  {
128  delete glw;
129  throw;
130  }
131 
132  glw->fFromInit = kFALSE;
133 
134  return glw;
135 }
136 
137 ////////////////////////////////////////////////////////////////////////////////
138 /// Creates widget with default pixel format.
139 
140 TGLWidget::TGLWidget(Window_t glw, const TGWindow* p, Bool_t selectInput)
141  : TGFrame(gClient, glw, p),
142  fGLContext(0),
143  fWindowIndex(-1),
144  fGLFormat(Rgl::kNone),
145  fFromInit(kTRUE),
146  fEventHandler(0)
147 {
148  if (selectInput)
149  {
150  gVirtualX->GrabButton(GetId(), kAnyButton, kAnyModifier,
155  gVirtualX->SetInputFocus(GetId());
156  }
157 }
158 
159 ////////////////////////////////////////////////////////////////////////////////
160 ///Destructor. Deletes window ???? and XVisualInfo
161 
163 {
164 #ifndef WIN32
165 #ifndef R__HAS_COCOA
166  XFree(fInnerData.second);//free XVisualInfo
167 #endif
168 #endif
169  if (fValidContexts.size() > 1u) {
170  Warning("~TGLWidget", "There are some gl-contexts connected to this gl device"
171  "which have longer lifetime than lifetime of gl-device");
172  }
173 
174  std::set<TGLContext *>::iterator it = fValidContexts.begin();
175  for (; it != fValidContexts.end(); ++it) {
176  (*it)->Release();
177  }
178  delete fGLContext;
179 
180  gVirtualX->SelectWindow(fWindowIndex);
181  gVirtualX->CloseWindow();
182 }
183 
184 ////////////////////////////////////////////////////////////////////////////////
185 ///Call glEnable(... in overrider of InitGL.
186 
188 {
189 }
190 
191 ////////////////////////////////////////////////////////////////////////////////
192 ///Do actual drawing in overrider of PaintGL.
193 
195 {
196 }
197 
198 ////////////////////////////////////////////////////////////////////////////////
199 ///Make the gl-context current.
200 
202 {
203  return fGLContext->MakeCurrent();
204 }
205 
206 ////////////////////////////////////////////////////////////////////////////////
207 ///Clear the current gl-context.
208 
210 {
211  return fGLContext->ClearCurrent();
212 }
213 
214 ////////////////////////////////////////////////////////////////////////////////
215 ///Swap buffers.
216 
218 {
220 }
221 
222 ////////////////////////////////////////////////////////////////////////////////
223 ///Get gl context.
224 
226 {
227  return fGLContext;
228 }
229 
230 ////////////////////////////////////////////////////////////////////////////////
231 ///Pixel format.
232 
234 {
235  return &fGLFormat;
236 }
237 
238 ////////////////////////////////////////////////////////////////////////////////
239 ///Dpy*, XVisualInfo *
240 
241 std::pair<void *, void *> TGLWidget::GetInnerData()const
242 {
243  return fInnerData;
244 }
245 
246 ////////////////////////////////////////////////////////////////////////////////
247 ///Register gl-context created for this window.
248 
250 {
251  fValidContexts.insert(ctx);
252 }
253 
254 ////////////////////////////////////////////////////////////////////////////////
255 ///Remove context (no real deletion, done by TGLContex dtor).
256 
258 {
259  std::set<TGLContext *>::iterator it = fValidContexts.find(ctx);
260  if (it != fValidContexts.end())
261  fValidContexts.erase(it);
262 }
263 
264 ////////////////////////////////////////////////////////////////////////////////
265 ///For camera.
266 
268 {
269  vp[0] = 0;
270  vp[1] = 0;
271  vp[2] = GetWidth();
272  vp[3] = GetHeight();
273 }
274 
275 //==============================================================================
276 // System specific methods and helper functions
277 //==============================================================================
278 
279 //==============================================================================
280 #ifdef WIN32
281 //==============================================================================
282 
283 namespace {
284 
285  struct LayoutCompatible_t {
286  void *fDummy0;
287  void *fDummy1;
288  HWND *fPHwnd;
289  unsigned char fDummy2;
290  unsigned fDummy3;
291  unsigned short fDummy4;
292  unsigned short fDummy5;
293  void *fDummy6;
294  unsigned fDummy7:2;
295  };
296 
297  void fill_pfd(PIXELFORMATDESCRIPTOR *pfd, const TGLFormat &request)
298  {
299  pfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
300  pfd->nVersion = 1;
301  pfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
302  if (request.IsDoubleBuffered())
303  pfd->dwFlags |= PFD_DOUBLEBUFFER;
304  pfd->iPixelType = PFD_TYPE_RGBA;
305  pfd->cColorBits = 24;
306  if (UInt_t acc = request.GetAccumSize())
307  pfd->cAccumBits = acc;
308  if (UInt_t depth = request.GetDepthSize())
309  pfd->cDepthBits = depth;
310  if (UInt_t stencil = request.GetStencilSize())
311  pfd->cStencilBits = stencil;
312  }
313 
314  void check_pixel_format(Int_t pixIndex, HDC hDC, TGLFormat &request)
315  {
316  PIXELFORMATDESCRIPTOR pfd = {};
317 
318  if (!DescribePixelFormat(hDC, pixIndex, sizeof pfd, &pfd)) {
319  Warning("TGLContext::SetContext", "DescribePixelFormat failed");
320  return;
321  }
322 
323  if (pfd.cAccumBits)
324  request.SetAccumSize(pfd.cAccumBits);
325 
326  if (pfd.cDepthBits)
327  request.SetDepthSize(pfd.cDepthBits);
328 
329  if (pfd.cStencilBits)
330  request.SetStencilSize(pfd.cStencilBits);
331  }
332 
333 }
334 
335 ////////////////////////////////////////////////////////////////////////////////
336 /// CreateWidget.
337 /// Static function called prior to widget construction,
338 /// I've extracted this code from ctors to make WIN32/X11
339 /// separation simpler and because of gInterpreter usage.
340 /// new, TGLContext can throw
341 /// std::bad_alloc and std::runtime_error. Before try block, the only
342 /// resource allocated is pointed by fWindowIndex (InitWindow cannot throw).
343 /// In try block (and after successful constraction)
344 /// resources are controlled by std::auto_ptrs and dtor.
345 
346 Window_t TGLWidget::CreateWindow(const TGWindow* parent, const TGLFormat& /*format*/,
347  UInt_t width, UInt_t height,
348  std::pair<void *, void *>& innerData)
349 {
350  Int_t widx = gVirtualX->InitWindow((ULong_t)parent->GetId());
351  innerData.second = (void*) widx;
352  Window_t win = gVirtualX->GetWindowID(widx);
353  gVirtualX->ResizeWindow(win, width, height);
354  return win;
355 }
356 
357 ////////////////////////////////////////////////////////////////////////////////
358 /// Set pixel format.
359 /// Resource - hDC, owned and freed by guard object.
360 
362 {
363  if (!fFromInit) {
364  Error("TGLWidget::SetFormat", "Sorry, you should not call this function");
365  return;
366  }
367  if (!gVirtualX->IsCmdThread())
368  gROOT->ProcessLineFast(Form("((TGLWidget *)0x%lx)->SetFormat()", this));
369 
371 
372  LayoutCompatible_t *trick =
373  reinterpret_cast<LayoutCompatible_t *>(GetId());
374  HWND hWND = *trick->fPHwnd;
375  HDC hDC = GetWindowDC(hWND);
376 
377  if (!hDC) {
378  Error("TGLWidget::SetFormat", "GetWindowDC failed");
379  throw std::runtime_error("GetWindowDC failed");
380  }
381 
382  const Rgl::TGuardBase &dcGuard = Rgl::make_guard(ReleaseDC, hWND, hDC);
383  PIXELFORMATDESCRIPTOR pfd = {};
384  fill_pfd(&pfd, fGLFormat);
385 
386  if (const Int_t pixIndex = ChoosePixelFormat(hDC, &pfd)) {
387  check_pixel_format(pixIndex, hDC, fGLFormat);
388 
389  if (!SetPixelFormat(hDC, pixIndex, &pfd)) {
390  Error("TGLWidget::SetFormat", "SetPixelFormat failed");
391  throw std::runtime_error("SetPixelFormat failed");
392  }
393  } else {
394  Error("TGLWidget::SetFormat", "ChoosePixelFormat failed");
395  throw std::runtime_error("ChoosePixelFormat failed");
396  }
397 }
398 //==============================================================================
399 #elif defined(R__HAS_COCOA) //MacOSX with Cocoa enabled.
400 //==============================================================================
401 
402 ////////////////////////////////////////////////////////////////////////////////
403 /// CreateWidget - MacOSX/Cocoa version.
404 /// Static function called prior to construction.
405 
406 Window_t TGLWidget::CreateWindow(const TGWindow* parent, const TGLFormat &format,
407  UInt_t width, UInt_t height,
408  std::pair<void *, void *>& /*internalData*/)
409 {
410  typedef std::pair<UInt_t, Int_t> component_type;
411 
412  std::vector<component_type>formatComponents;
413 
414  if (format.HasDepth())
415  formatComponents.push_back(component_type(Rgl::kDepth, format.GetDepthSize()));
416  if (format.HasStencil())
417  formatComponents.push_back(component_type(Rgl::kStencil, format.GetStencilSize()));
418  if (format.HasAccumBuffer())
419  formatComponents.push_back(component_type(Rgl::kAccum, format.GetAccumSize()));
420  if (format.IsDoubleBuffered())
421  formatComponents.push_back(component_type(Rgl::kDoubleBuffer, 0));
422  if (format.IsStereo())
423  formatComponents.push_back(component_type(Rgl::kStereo, 0));
424  if (format.HasMultiSampling())
425  formatComponents.push_back(component_type(Rgl::kMultiSample, format.GetSamples()));
426 
427  return gVirtualX->CreateOpenGLWindow(parent->GetId(), width, height, formatComponents);
428 }
429 
430 ////////////////////////////////////////////////////////////////////////////////
431 /// Set pixel format.
432 /// Empty version for X11.
433 
435 {
436 }
437 
438 //==============================================================================
439 #else // X11
440 //==============================================================================
441 
442 namespace
443 {
444  void fill_format(std::vector<Int_t> &format, const TGLFormat &request)
445  {
446  format.push_back(GLX_RGBA);
447  format.push_back(GLX_RED_SIZE);
448  format.push_back(8);
449  format.push_back(GLX_GREEN_SIZE);
450  format.push_back(8);
451  format.push_back(GLX_BLUE_SIZE);
452  format.push_back(8);
453 
454  if (request.IsDoubleBuffered())
455  format.push_back(GLX_DOUBLEBUFFER);
456 
457  if (request.HasDepth()) {
458  format.push_back(GLX_DEPTH_SIZE);
459  format.push_back(request.GetDepthSize());
460  }
461 
462  if (request.HasStencil()) {
463  format.push_back(GLX_STENCIL_SIZE);
464  format.push_back(request.GetStencilSize());
465  }
466 
467  if (request.HasAccumBuffer()) {
468  format.push_back(GLX_ACCUM_RED_SIZE);
469  format.push_back(8);
470  format.push_back(GLX_ACCUM_GREEN_SIZE);
471  format.push_back(8);
472  format.push_back(GLX_ACCUM_BLUE_SIZE);
473  format.push_back(8);
474  }
475 
476  if (request.IsStereo()) {
477  format.push_back(GLX_STEREO);
478  }
479 
480  if (request.HasMultiSampling())
481  {
482  format.push_back(GLX_SAMPLE_BUFFERS_ARB);
483  format.push_back(1);
484  format.push_back(GLX_SAMPLES_ARB);
485  format.push_back(request.GetSamples());
486  }
487 
488  format.push_back(None);
489  }
490 }
491 
492 ////////////////////////////////////////////////////////////////////////////////
493 /// CreateWidget - X11 version.
494 /// Static function called prior to construction.
495 /// Can throw std::bad_alloc and std::runtime_error.
496 /// This version is bad - I do not check the results of
497 /// X11 calls.
498 
499 Window_t TGLWidget::CreateWindow(const TGWindow* parent, const TGLFormat &format,
500  UInt_t width, UInt_t height,
501  std::pair<void *, void *>& innerData)
502 {
503  std::vector<Int_t> glxfmt;
504  fill_format(glxfmt, format);
505 
506  Display *dpy = reinterpret_cast<Display *>(gVirtualX->GetDisplay());
507  if (!dpy) {
508  ::Error("TGLWidget::CreateWindow", "Display is not set!");
509  throw std::runtime_error("Display is not set!");
510  }
511  XVisualInfo *visInfo = glXChooseVisual(dpy, DefaultScreen(dpy), &glxfmt[0]);
512 
513  if (!visInfo) {
514  ::Error("TGLWidget::CreateWindow", "No good OpenGL visual found!");
515  throw std::runtime_error("No good OpenGL visual found!");
516  }
517 
518  Window_t winID = parent->GetId();
519 
520  XSetWindowAttributes attr;
521  attr.colormap = XCreateColormap(dpy, winID, visInfo->visual, AllocNone); // Can fail?
522  attr.background_pixel = 0;
523  attr.event_mask = NoEventMask;
524  attr.backing_store = Always;
525  attr.bit_gravity = NorthWestGravity;
526 
527  ULong_t mask = CWBackPixel | CWColormap | CWEventMask | CWBackingStore | CWBitGravity;
528  Window glWin = XCreateWindow(dpy, winID, 0, 0, width, height, 0,
529  visInfo->depth,
530  InputOutput, visInfo->visual, mask, &attr);
531 
532  innerData.first = dpy;
533  innerData.second = visInfo;
534 
535  return glWin;
536 }
537 
538 ////////////////////////////////////////////////////////////////////////////////
539 /// Set pixel format.
540 /// Empty version for X11.
541 
543 {
544 }
545 
546 //==============================================================================
547 #endif
548 //==============================================================================
549 
550 
551 //==============================================================================
552 // Event handling
553 //==============================================================================
554 
555 ////////////////////////////////////////////////////////////////////////////////
556 ///Set event-handler. All events are passed to this object.
557 
559 {
560  fEventHandler = eh;
561 }
562 
563 ////////////////////////////////////////////////////////////////////////////////
564 /// Handle mouse crossing event.
565 
567 {
568  if (!gVirtualX->IsCmdThread()) {
569  gROOT->ProcessLineFast(Form("((TGLWidget *)0x%lx)->HandleCrossing((Event_t *)0x%lx)", (ULong_t)this, (ULong_t)ev));
570  return kTRUE;
571  }
573 
574  if ((ev->fType == kEnterNotify) &&
575  (!gVirtualX->InheritsFrom("TGX11")) &&
576  (gVirtualX->GetInputFocus() != GetId())) {
577  gVirtualX->SetInputFocus(GetId());
578  }
579  if (fEventHandler)
580  return fEventHandler->HandleCrossing(ev);
581  return kFALSE;
582 }
583 
584 ////////////////////////////////////////////////////////////////////////////////
585 ///Delegate call to the owner.
586 
588 {
589  if (!gVirtualX->IsCmdThread()) {
590  gROOT->ProcessLineFast(Form("((TGLWidget *)0x%lx)->HandleButton((Event_t *)0x%lx)", (ULong_t)this, (ULong_t)ev));
591  return kTRUE;
592  }
594 
595  if (fEventHandler)
596  return fEventHandler->HandleButton(ev);
597  return kFALSE;
598 }
599 
600 ////////////////////////////////////////////////////////////////////////////////
601 ///Delegate call to the owner.
602 
604 {
605  if (!gVirtualX->IsCmdThread()) {
606  gROOT->ProcessLineFast(Form("((TGLWidget *)0x%lx)->HandleDoubleClick((Event_t *)0x%lx)", (ULong_t)this, (ULong_t)ev));
607  return kTRUE;
608  }
610 
611  if (fEventHandler)
612  return fEventHandler->HandleDoubleClick(ev);
613  return kFALSE;
614 }
615 
616 ////////////////////////////////////////////////////////////////////////////////
617 ///Delegate call to the owner.
618 
620 {
621  if (!gVirtualX->IsCmdThread()) {
622  gROOT->ProcessLineFast(Form("((TGLWidget *)0x%lx)->HandleConfigureNotify((Event_t *)0x%lx)", (ULong_t)this, (ULong_t)ev));
623  return kTRUE;
624  }
626 
628  {
630  return kTRUE;
631  }
632  return kFALSE;
633 }
634 
635 ////////////////////////////////////////////////////////////////////////////////
636 ///Delegate call to the owner.
637 
639 {
640  if (!gVirtualX->IsCmdThread()) {
641  gROOT->ProcessLineFast(Form("((TGLWidget *)0x%lx)->HandleFocusChange((Event_t *)0x%lx)", (ULong_t)this, (ULong_t)ev));
642  return kTRUE;
643  }
645 
646  if (fEventHandler)
647  return fEventHandler->HandleFocusChange(ev);
648  return kFALSE;
649 }
650 
651 ////////////////////////////////////////////////////////////////////////////////
652 ///Delegate call to the owner.
653 
655 {
656  if (!gVirtualX->IsCmdThread()) {
657  gROOT->ProcessLineFast(Form("((TGLWidget *)0x%lx)->HandleKey((Event_t *)0x%lx)", (ULong_t)this, (ULong_t)ev));
658  return kTRUE;
659  }
661 
662  if (fEventHandler)
663  return fEventHandler->HandleKey(ev);
664  return kFALSE;
665 }
666 
667 ////////////////////////////////////////////////////////////////////////////////
668 ///Delegate call to the owner.
669 
671 {
672  if (!gVirtualX->IsCmdThread()) {
673  gROOT->ProcessLineFast(Form("((TGLWidget *)0x%lx)->HandleMotion((Event_t *)0x%lx)", (ULong_t)this, (ULong_t)ev));
674  return kTRUE;
675  }
677 
678  if (fEventHandler)
679  return fEventHandler->HandleMotion(ev);
680  return kFALSE;
681 }
682 
683 ////////////////////////////////////////////////////////////////////////////////
684 ///Delegate call to the owner.
685 
687 {
688  if (fEventHandler)
689  return fEventHandler->Repaint();
690 }
Bool_t HandleConfigureNotify(Event_t *ev)
Delegate call to the owner.
Definition: TGLWidget.cxx:619
const Mask_t kKeyReleaseMask
Definition: GuiTypes.h:161
Bool_t HandleKey(Event_t *ev)
Delegate call to the owner.
Definition: TGLWidget.cxx:654
const TGLContext * GetContext() const
Get gl context.
Definition: TGLWidget.cxx:225
void SetFormat()
Set pixel format.
Definition: TGLWidget.cxx:542
TGLWidget(const TGLWidget &)
void AddContext(TGLContext *ctx)
Register gl-context created for this window.
Definition: TGLWidget.cxx:249
Bool_t HandleFocusChange(Event_t *)
Delegate call to the owner.
Definition: TGLWidget.cxx:638
ClassImp(TGLWidget)
UInt_t GetWidth() const
Definition: TGFrame.h:287
Bool_t HandleMotion(Event_t *ev)
Delegate call to the owner.
Definition: TGLWidget.cxx:670
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:169
void ExtractViewport(Int_t *vp) const
For camera.
Definition: TGLWidget.cxx:267
#define gROOT
Definition: TROOT.h:340
void SetStencilSize(Int_t stencil)
Set the size of stencil buffer.
Definition: TGLFormat.cxx:137
#define gClient
Definition: TGClient.h:174
virtual void Repaint()
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:63
const Bool_t kFALSE
Definition: Rtypes.h:92
TGLContext * fGLContext
Definition: TGLWidget.h:40
static std::string format(double x, double y, int digits, int width)
UInt_t GetHeight() const
Definition: TGFrame.h:288
Bool_t HasMultiSampling() const
Check, if multi-sampling is required.
Definition: TGLFormat.cxx:227
Bool_t HandleCrossing(Event_t *)
Handle mouse crossing event.
Definition: TGLWidget.cxx:566
Int_t GetDepthSize() const
Get the size of depth buffer.
Definition: TGLFormat.cxx:104
virtual Bool_t HandleConfigureNotify(Event_t *)
void DoRedraw()
Delegate call to the owner.
Definition: TGLWidget.cxx:686
virtual Bool_t HandleButton(Event_t *)
static TGLWidget * Create(const TGWindow *parent, Bool_t selectInput, Bool_t shareDefault, const TGLPaintDevice *shareDevice, UInt_t width, UInt_t height)
Static constructor for creating widget with default pixel format.
Definition: TGLWidget.cxx:83
std::pair< void *, void * > GetInnerData() const
Dpy*, XVisualInfo *.
Definition: TGLWidget.cxx:241
void RemoveContext(TGLContext *ctx)
Remove context (no real deletion, done by TGLContex dtor).
Definition: TGLWidget.cxx:257
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:164
static TGLWidget * CreateDummy()
Static constructor for creating widget with default pixel format.
Definition: TGLWidget.cxx:73
void SetAccumSize(Int_t accum)
Set the size of accum buffer.
Definition: TGLFormat.cxx:162
UChar_t mod R__LOCKGUARD2(gSrvAuthenticateMutex)
virtual Bool_t HandleDoubleClick(Event_t *)
virtual void InitGL()
Call glEnable(... in overrider of InitGL.
Definition: TGLWidget.cxx:187
void SetEventHandler(TGEventHandler *eh)
Set event-handler. All events are passed to this object.
Definition: TGLWidget.cxx:558
friend class TGLContext
Definition: TGLWidget.h:37
std::pair< void *, void * > fInnerData
Definition: TGLWidget.h:42
if(pyself &&pyself!=Py_None)
Bool_t MakeCurrent()
If context is valid (TGLPaintDevice, for which context was created still exists), make it current...
Definition: TGLContext.cxx:368
Bool_t HandleButton(Event_t *ev)
Delegate call to the owner.
Definition: TGLWidget.cxx:587
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
Bool_t HasAccumBuffer() const
Check, if this surface has accumulation buffer.
Definition: TGLFormat.cxx:171
Encapsulation of format / contents of an OpenGL buffer.
Definition: TGLFormat.h:35
Bool_t IsStereo() const
Check, if the surface is stereo buffered.
Definition: TGLFormat.cxx:195
void SwapBuffers()
Swap buffers.
Definition: TGLWidget.cxx:217
#define None
Definition: TGWin32.h:68
virtual const TGLContext * GetContext() const =0
const Mask_t kButtonPressMask
Definition: GuiTypes.h:162
Bool_t HandleDoubleClick(Event_t *ev)
Delegate call to the owner.
Definition: TGLWidget.cxx:603
Bool_t IsDoubleBuffered() const
Check, if the surface is double buffered.
Definition: TGLFormat.cxx:179
const Mask_t kKeyPressMask
Definition: GuiTypes.h:160
virtual Bool_t HandleCrossing(Event_t *)
virtual Bool_t HandleKey(Event_t *)
TGLFormat fGLFormat
Definition: TGLWidget.h:45
static void InitializeIfNeeded()
Initialize globals that require other libraries to be initialized.
Definition: TGLUtil.cxx:1543
EGEventType fType
Definition: GuiTypes.h:176
TOneArgGuard< Func, Arg > make_guard(Func f, Arg a)
Definition: TGLUtil.h:1328
virtual Bool_t HandleFocusChange(Event_t *)
const Mask_t kExposureMask
Definition: GuiTypes.h:166
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t HasStencil() const
Check, if this surface has stencil buffer.
Definition: TGLFormat.cxx:146
char * Form(const char *fmt,...)
const Handle_t kNone
Definition: GuiTypes.h:89
GL window with context.
Definition: TGLWidget.h:35
void Warning(const char *location, const char *msgfmt,...)
~TGLWidget()
Destructor. Deletes window ???? and XVisualInfo.
Definition: TGLWidget.cxx:162
#define gVirtualX
Definition: TVirtualX.h:362
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition: TGFrame.cxx:425
XID Window
Definition: TGX11.h:41
Bool_t MakeCurrent()
Make the gl-context current.
Definition: TGLWidget.cxx:201
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:168
const Mask_t kStructureNotifyMask
Definition: GuiTypes.h:167
void SwapBuffers()
If context is valid (TGLPaintDevice, for which context was created still exists), swap buffers (in ca...
Definition: TGLContext.cxx:401
This class encapsulates window-system specific information about a GL-context and alows their proper ...
Definition: TGLContext.h:33
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:163
unsigned long ULong_t
Definition: RtypesCore.h:51
Bool_t ClearCurrent()
Clear the current gl-context.
Definition: TGLWidget.cxx:209
Bool_t ClearCurrent()
Reset current context.
Definition: TGLContext.cxx:392
TGEventHandler * fEventHandler
Definition: TGLWidget.h:51
Int_t GetSamples() const
Get the number of samples for multi-sampling.
Definition: TGLFormat.cxx:211
Bool_t fFromInit
Definition: TGLWidget.h:47
Handle_t Window_t
Definition: GuiTypes.h:30
Int_t fWindowIndex
Definition: TGLWidget.h:43
const Mask_t kFocusChangeMask
Definition: GuiTypes.h:170
virtual Bool_t HandleMotion(Event_t *)
void SetDepthSize(Int_t depth)
Set the size of color buffer.
Definition: TGLFormat.cxx:112
const Bool_t kTRUE
Definition: Rtypes.h:91
const Mask_t kAnyModifier
Definition: GuiTypes.h:211
virtual void PaintGL()
Do actual drawing in overrider of PaintGL.
Definition: TGLWidget.cxx:194
Bool_t HasDepth() const
Check, if this surface has depth buffer.
Definition: TGLFormat.cxx:121
Handle_t GetId() const
Definition: TGObject.h:52
static Window_t CreateWindow(const TGWindow *parent, const TGLFormat &format, UInt_t width, UInt_t height, std::pair< void *, void * > &innerData)
CreateWidget - X11 version.
Definition: TGLWidget.cxx:499
std::set< TGLContext * > fValidContexts
Definition: TGLWidget.h:49
Int_t GetAccumSize() const
Get the size of accum buffer.
Definition: TGLFormat.cxx:154
const TGLFormat * GetPixelFormat() const
Pixel format.
Definition: TGLWidget.cxx:233
Int_t GetStencilSize() const
Get the size of stencil buffer.
Definition: TGLFormat.cxx:129
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904