Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
30GL window with context. _Must_ _have_ a parent window
31(the 'parent' parameter of ctors). The current version inherits
32TGCanvas (I'm not sure about future versions), probably, in future
33multiple inheritance will be added - the second
34base class will be TGLPaintDevice or something like this.
35
36Usage:
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
44Resources (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
50Exceptions:
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
56TGLWidget object is immutable as far as it was created.
57
58Boolean parameter defines, if you want to grab user's input or not.
59By default you want, but for example when not - see TGLPShapeObjEditor.
60
61Non-copyable.
62*/
63
64
65//==============================================================================
66// TGLWidget - system-independent methods
67//==============================================================================
68
69////////////////////////////////////////////////////////////////////////////////
70/// Static constructor for creating widget with default pixel format.
71
73{
75
76 return Create(format, gClient->GetDefaultRoot(), kFALSE, kFALSE, nullptr, 1, 1);
77}
78
79////////////////////////////////////////////////////////////////////////////////
80/// Static constructor for creating widget with default pixel format.
81
91
92////////////////////////////////////////////////////////////////////////////////
93/// Static constructor for creating widget with given pixel format.
94
96 const TGWindow* parent, Bool_t selectInput,
99{
100 // Make sure window-system dependent part of GL-util is initialized.
102
103 std::pair<void *, void *> innerData;
104
106
107 TGLWidget* glw = new TGLWidget(wid, parent, selectInput);
108
109#ifdef WIN32
110 glw->fWindowIndex = (Int_t)(Longptr_t)innerData.second;
111#elif defined(R__HAS_COCOA)
112 glw->fWindowIndex = wid;
113#else
114 glw->fWindowIndex = gVirtualX->AddWindow(wid, width, height);
115 glw->fInnerData = innerData;
116#endif
117 glw->fGLFormat = format;
118
119 try
120 {
121 glw->SetFormat();
122 glw->fGLContext = new TGLContext
123 (glw, shareDefault, shareDevice && !shareDefault ? shareDevice->GetContext() : nullptr);
124 }
125 catch (const std::exception &)
126 {
127 delete glw;
128 throw;
129 }
130
131 glw->fFromInit = kFALSE;
132
133 return glw;
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Creates widget with default pixel format.
138
140 : TGFrame(gClient, glw, p),
141 fGLContext(nullptr),
142 fWindowIndex(-1),
143 fGLFormat(Rgl::kNone),
144 fFromInit(kTRUE),
145 fEventHandler(nullptr)
146{
147 if (selectInput)
148 {
149 gVirtualX->GrabButton(GetId(), kAnyButton, kAnyModifier,
154 gVirtualX->SetInputFocus(GetId());
155 }
156}
157
158////////////////////////////////////////////////////////////////////////////////
159///Destructor. Deletes window ???? and XVisualInfo
160
162{
163#ifndef WIN32
164#ifndef R__HAS_COCOA
165 XFree(fInnerData.second);//free XVisualInfo
166#endif
167#endif
168 if (fValidContexts.size() > 1u) {
169 Warning("~TGLWidget", "There are some gl-contexts connected to this gl device"
170 "which have longer lifetime than lifetime of gl-device");
171 }
172
173 std::set<TGLContext *>::iterator it = fValidContexts.begin();
174 for (; it != fValidContexts.end(); ++it) {
175 (*it)->Release();
176 }
177 delete fGLContext;
178
179 gVirtualX->SelectWindow(fWindowIndex);
180 gVirtualX->CloseWindow();
181}
182
183////////////////////////////////////////////////////////////////////////////////
184///Call glEnable(... in overrider of InitGL.
185
187{
188}
189
190////////////////////////////////////////////////////////////////////////////////
191///Do actual drawing in overrider of PaintGL.
192
194{
195}
196
197////////////////////////////////////////////////////////////////////////////////
198///Make the gl-context current.
199
204
205////////////////////////////////////////////////////////////////////////////////
206///Clear the current gl-context.
207
212
213////////////////////////////////////////////////////////////////////////////////
214///Swap buffers.
215
220
221////////////////////////////////////////////////////////////////////////////////
222///Get gl context.
223
225{
226 return fGLContext;
227}
228
229////////////////////////////////////////////////////////////////////////////////
230///Pixel format.
231
233{
234 return &fGLFormat;
235}
236
237////////////////////////////////////////////////////////////////////////////////
238///Dpy*, XVisualInfo *
239
240std::pair<void *, void *> TGLWidget::GetInnerData()const
241{
242 return fInnerData;
243}
244
245////////////////////////////////////////////////////////////////////////////////
246///Register gl-context created for this window.
247
249{
250 fValidContexts.insert(ctx);
251}
252
253////////////////////////////////////////////////////////////////////////////////
254///Remove context (no real deletion, done by TGLContex dtor).
255
257{
258 std::set<TGLContext *>::iterator it = fValidContexts.find(ctx);
259 if (it != fValidContexts.end())
260 fValidContexts.erase(it);
261}
262
263////////////////////////////////////////////////////////////////////////////////
264///For camera.
265
267{
268 vp[0] = 0;
269 vp[1] = 0;
270 vp[2] = GetWidth();
271 vp[3] = GetHeight();
272}
273
274//==============================================================================
275// System specific methods and helper functions
276//==============================================================================
277
278//==============================================================================
279#ifdef WIN32
280//==============================================================================
281
282namespace {
283
284 struct LayoutCompatible_t {
285 void *fDummy0;
286 void *fDummy1;
287 HWND *fPHwnd;
288 unsigned char fDummy2;
289 unsigned fDummy3;
290 unsigned short fDummy4;
291 unsigned short fDummy5;
292 void *fDummy6;
293 unsigned fDummy7:2;
294 };
295
296 void fill_pfd(PIXELFORMATDESCRIPTOR *pfd, const TGLFormat &request)
297 {
298 pfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
299 pfd->nVersion = 1;
301 if (request.IsDoubleBuffered())
302 pfd->dwFlags |= PFD_DOUBLEBUFFER;
303 pfd->iPixelType = PFD_TYPE_RGBA;
304 pfd->cColorBits = 24;
305 if (UInt_t acc = request.GetAccumSize())
306 pfd->cAccumBits = acc;
307 if (UInt_t depth = request.GetDepthSize())
308 pfd->cDepthBits = depth;
309 if (UInt_t stencil = request.GetStencilSize())
310 pfd->cStencilBits = stencil;
311 }
312
313 void check_pixel_format(Int_t pixIndex, HDC hDC, TGLFormat &request)
314 {
316
317 if (!DescribePixelFormat(hDC, pixIndex, sizeof pfd, &pfd)) {
318 Warning("TGLContext::SetContext", "DescribePixelFormat failed");
319 return;
320 }
321
322 if (pfd.cAccumBits)
323 request.SetAccumSize(pfd.cAccumBits);
324
325 if (pfd.cDepthBits)
326 request.SetDepthSize(pfd.cDepthBits);
327
328 if (pfd.cStencilBits)
329 request.SetStencilSize(pfd.cStencilBits);
330 }
331
332}
333
334////////////////////////////////////////////////////////////////////////////////
335/// CreateWidget.
336/// Static function called prior to widget construction,
337/// I've extracted this code from ctors to make WIN32/X11
338/// separation simpler and because of gInterpreter usage.
339/// new, TGLContext can throw
340/// std::bad_alloc and std::runtime_error. Before try block, the only
341/// resource allocated is pointed by fWindowIndex (InitWindow cannot throw).
342/// In try block (and after successful constraction)
343/// resources are controlled by std::auto_ptrs and dtor.
344
345Window_t TGLWidget::CreateWindow(const TGWindow* parent, const TGLFormat& /*format*/,
347 std::pair<void *, void *>& innerData)
348{
349 Int_t widx = gVirtualX->InitWindow((ULongptr_t)parent->GetId());
350 innerData.second = (void*)(Longptr_t)widx;
351 Window_t win = gVirtualX->GetWindowID(widx);
352 gVirtualX->ResizeWindow(win, width, height);
353 return win;
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Set pixel format.
358/// Resource - hDC, owned and freed by guard object.
359
361{
362 if (!fFromInit) {
363 Error("TGLWidget::SetFormat", "Sorry, you should not call this function");
364 return;
365 }
366 if (!gVirtualX->IsCmdThread())
367 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->SetFormat()", (size_t)this));
368
370
372 reinterpret_cast<LayoutCompatible_t *>(GetId());
373 HWND hWND = *trick->fPHwnd;
374 HDC hDC = GetWindowDC(hWND);
375
376 if (!hDC) {
377 Error("TGLWidget::SetFormat", "GetWindowDC failed");
378 throw std::runtime_error("GetWindowDC failed");
379 }
380
384
385 if (const Int_t pixIndex = ChoosePixelFormat(hDC, &pfd)) {
387
388 if (!SetPixelFormat(hDC, pixIndex, &pfd)) {
389 Error("TGLWidget::SetFormat", "SetPixelFormat failed");
390 throw std::runtime_error("SetPixelFormat failed");
391 }
392 } else {
393 Error("TGLWidget::SetFormat", "ChoosePixelFormat failed");
394 throw std::runtime_error("ChoosePixelFormat failed");
395 }
396}
397//==============================================================================
398#elif defined(R__HAS_COCOA) //MacOSX with Cocoa enabled.
399//==============================================================================
400
401////////////////////////////////////////////////////////////////////////////////
402/// CreateWidget - MacOSX/Cocoa version.
403/// Static function called prior to construction.
404
407 std::pair<void *, void *>& /*internalData*/)
408{
409 typedef std::pair<UInt_t, Int_t> component_type;
410
411 std::vector<component_type>formatComponents;
412
413 if (format.HasDepth())
414 formatComponents.push_back(component_type(Rgl::kDepth, format.GetDepthSize()));
415 if (format.HasStencil())
416 formatComponents.push_back(component_type(Rgl::kStencil, format.GetStencilSize()));
417 if (format.HasAccumBuffer())
418 formatComponents.push_back(component_type(Rgl::kAccum, format.GetAccumSize()));
419 if (format.IsDoubleBuffered())
421 if (format.IsStereo())
423 if (format.HasMultiSampling())
425
426 return gVirtualX->CreateOpenGLWindow(parent->GetId(), width, height, formatComponents);
427}
428
429////////////////////////////////////////////////////////////////////////////////
430/// Set pixel format.
431/// Empty version for X11.
432
434{
435}
436
437//==============================================================================
438#else // X11
439//==============================================================================
440
441namespace
442{
443 void fill_format(std::vector<Int_t> &format, const TGLFormat &request)
444 {
445 format.push_back(GLX_RGBA);
446 format.push_back(GLX_RED_SIZE);
447 format.push_back(8);
448 format.push_back(GLX_GREEN_SIZE);
449 format.push_back(8);
450 format.push_back(GLX_BLUE_SIZE);
451 format.push_back(8);
452
453 if (request.IsDoubleBuffered())
454 format.push_back(GLX_DOUBLEBUFFER);
455
456 if (request.HasDepth()) {
457 format.push_back(GLX_DEPTH_SIZE);
458 format.push_back(request.GetDepthSize());
459 }
460
461 if (request.HasStencil()) {
462 format.push_back(GLX_STENCIL_SIZE);
463 format.push_back(request.GetStencilSize());
464 }
465
466 if (request.HasAccumBuffer()) {
467 format.push_back(GLX_ACCUM_RED_SIZE);
468 format.push_back(8);
469 format.push_back(GLX_ACCUM_GREEN_SIZE);
470 format.push_back(8);
471 format.push_back(GLX_ACCUM_BLUE_SIZE);
472 format.push_back(8);
473 }
474
475 if (request.IsStereo()) {
476 format.push_back(GLX_STEREO);
477 }
478
479 if (request.HasMultiSampling())
480 {
482 format.push_back(1);
483 format.push_back(GLX_SAMPLES_ARB);
484 format.push_back(request.GetSamples());
485 }
486
487 format.push_back(None);
488 }
489}
490
491////////////////////////////////////////////////////////////////////////////////
492/// CreateWidget - X11 version.
493/// Static function called prior to construction.
494/// Can throw std::bad_alloc and std::runtime_error.
495/// This version is bad - I do not check the results of
496/// X11 calls.
497
500 std::pair<void *, void *>& innerData)
501{
502 std::vector<Int_t> glxfmt;
504
505 Display *dpy = reinterpret_cast<Display *>(gVirtualX->GetDisplay());
506 if (!dpy) {
507 ::Error("TGLWidget::CreateWindow", "Display is not set!");
508 throw std::runtime_error("Display is not set!");
509 }
511
512 if (!visInfo) {
513 ::Error("TGLWidget::CreateWindow", "No good OpenGL visual found!");
514 throw std::runtime_error("No good OpenGL visual found!");
515 }
516
517 Window_t winID = parent->GetId();
518
520 attr.colormap = XCreateColormap(dpy, winID, visInfo->visual, AllocNone); // Can fail?
521 attr.background_pixel = 0;
522 attr.event_mask = NoEventMask;
523 attr.backing_store = Always;
524 attr.bit_gravity = NorthWestGravity;
525
528 visInfo->depth,
529 InputOutput, visInfo->visual, mask, &attr);
530
531 innerData.first = dpy;
532 innerData.second = visInfo;
533
534 return glWin;
535}
536
537////////////////////////////////////////////////////////////////////////////////
538/// Set pixel format.
539/// Empty version for X11.
540
542{
543}
544
545//==============================================================================
546#endif
547//==============================================================================
548
549
550//==============================================================================
551// Event handling
552//==============================================================================
553
554////////////////////////////////////////////////////////////////////////////////
555///Set event-handler. All events are passed to this object.
556
561
562////////////////////////////////////////////////////////////////////////////////
563/// Handle mouse crossing event.
564
566{
567 if (!gVirtualX->IsCmdThread()) {
568 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleCrossing((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
569 return kTRUE;
570 }
572
573 if ((ev->fType == kEnterNotify) &&
574 (!gVirtualX->InheritsFrom("TGX11")) &&
575 (gVirtualX->GetInputFocus() != GetId())) {
576 gVirtualX->SetInputFocus(GetId());
577 }
578 if (fEventHandler)
580 return kFALSE;
581}
582
583////////////////////////////////////////////////////////////////////////////////
584///Delegate call to the owner.
585
587{
588 if (!gVirtualX->IsCmdThread()) {
589 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleButton((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
590 return kTRUE;
591 }
593
594 if (fEventHandler)
596 return kFALSE;
597}
598
599////////////////////////////////////////////////////////////////////////////////
600///Delegate call to the owner.
601
603{
604 if (!gVirtualX->IsCmdThread()) {
605 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleDoubleClick((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
606 return kTRUE;
607 }
609
610 if (fEventHandler)
612 return kFALSE;
613}
614
615////////////////////////////////////////////////////////////////////////////////
616///Delegate call to the owner.
617
619{
620 if (!gVirtualX->IsCmdThread()) {
621 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleConfigureNotify((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
622 return kTRUE;
623 }
625
627 {
629 return kTRUE;
630 }
631 return kFALSE;
632}
633
634////////////////////////////////////////////////////////////////////////////////
635///Delegate call to the owner.
636
638{
639 if (!gVirtualX->IsCmdThread()) {
640 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleFocusChange((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
641 return kTRUE;
642 }
644
645 if (fEventHandler)
647 return kFALSE;
648}
649
650////////////////////////////////////////////////////////////////////////////////
651///Delegate call to the owner.
652
654{
655 if (!gVirtualX->IsCmdThread()) {
656 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleKey((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
657 return kTRUE;
658 }
660
661 if (fEventHandler)
662 return fEventHandler->HandleKey(ev);
663 return kFALSE;
664}
665
666////////////////////////////////////////////////////////////////////////////////
667///Delegate call to the owner.
668
670{
671 if (!gVirtualX->IsCmdThread()) {
672 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleMotion((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
673 return kTRUE;
674 }
676
677 if (fEventHandler)
679 return kFALSE;
680}
681
682////////////////////////////////////////////////////////////////////////////////
683///Delegate call to the owner.
684
686{
687 if (fEventHandler)
688 return fEventHandler->Repaint();
689}
@ kEnterNotify
Definition GuiTypes.h:61
const Mask_t kFocusChangeMask
Definition GuiTypes.h:169
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kExposureMask
Definition GuiTypes.h:165
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kKeyReleaseMask
Definition GuiTypes.h:160
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Mask_t kKeyPressMask
Definition GuiTypes.h:159
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:168
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:166
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
const Mask_t kEnterWindowMask
Definition GuiTypes.h:167
@ kAnyButton
Definition GuiTypes.h:214
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
#define gClient
Definition TGClient.h:157
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
XID Window
Definition TGX11.h:36
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:411
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2495
#define R__LOCKGUARD(mutex)
#define gVirtualX
Definition TVirtualX.h:337
virtual Bool_t HandleKey(Event_t *)
virtual Bool_t HandleMotion(Event_t *)
virtual Bool_t HandleCrossing(Event_t *)
virtual Bool_t HandleButton(Event_t *)
virtual void Repaint()
virtual Bool_t HandleConfigureNotify(Event_t *)
virtual Bool_t HandleDoubleClick(Event_t *)
virtual Bool_t HandleFocusChange(Event_t *)
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition TGFrame.cxx:435
UInt_t GetHeight() const
Definition TGFrame.h:227
UInt_t GetWidth() const
Definition TGFrame.h:226
This class encapsulates window-system specific information about a GL-context and alows their proper ...
Definition TGLContext.h:31
void SwapBuffers()
If context is valid (TGLPaintDevice, for which context was created still exists), swap buffers (in ca...
Bool_t MakeCurrent()
If context is valid (TGLPaintDevice, for which context was created still exists), make it current.
Bool_t ClearCurrent()
Reset current context.
Encapsulation of format / contents of an OpenGL buffer.
Definition TGLFormat.h:36
Bool_t IsStereo() const
Check, if the surface is stereo buffered.
Int_t GetDepthSize() const
Get the size of depth buffer.
Int_t GetStencilSize() const
Get the size of stencil buffer.
void SetAccumSize(Int_t accum)
Set the size of accum buffer.
Bool_t HasMultiSampling() const
Check, if multi-sampling is required.
Int_t GetSamples() const
Get the number of samples for multi-sampling.
Bool_t HasStencil() const
Check, if this surface has stencil buffer.
void SetStencilSize(Int_t stencil)
Set the size of stencil buffer.
Bool_t HasDepth() const
Check, if this surface has depth buffer.
Bool_t IsDoubleBuffered() const
Check, if the surface is double buffered.
Int_t GetAccumSize() const
Get the size of accum buffer.
Bool_t HasAccumBuffer() const
Check, if this surface has accumulation buffer.
void SetDepthSize(Int_t depth)
Set the size of color buffer.
static void InitializeIfNeeded()
Initialize globals that require other libraries to be initialized.
Definition TGLUtil.cxx:1573
GL window with context.
Definition TGLWidget.h:28
Bool_t fFromInit
Definition TGLWidget.h:39
void AddContext(TGLContext *ctx) override
Register gl-context created for this window.
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:82
Bool_t HandleConfigureNotify(Event_t *ev) override
Delegate call to the owner.
Bool_t MakeCurrent() override
Make the gl-context current.
Bool_t HandleButton(Event_t *ev) override
Delegate call to the owner.
TGEventHandler * fEventHandler
Definition TGLWidget.h:43
Bool_t HandleDoubleClick(Event_t *ev) override
Delegate call to the owner.
virtual void InitGL()
Call glEnable(... in overrider of InitGL.
std::set< TGLContext * > fValidContexts
Definition TGLWidget.h:41
TGLFormat fGLFormat
Definition TGLWidget.h:37
static TGLWidget * CreateDummy()
Static constructor for creating widget with default pixel format.
Definition TGLWidget.cxx:72
friend class TGLContext
Definition TGLWidget.h:29
void SwapBuffers() override
Swap buffers.
virtual void PaintGL()
Do actual drawing in overrider of PaintGL.
Bool_t HandleFocusChange(Event_t *) override
Delegate call to the owner.
void RemoveContext(TGLContext *ctx) override
Remove context (no real deletion, done by TGLContex dtor).
Bool_t HandleKey(Event_t *ev) override
Delegate call to the owner.
void DoRedraw() override
Delegate call to the owner.
static Window_t CreateWindow(const TGWindow *parent, const TGLFormat &format, UInt_t width, UInt_t height, std::pair< void *, void * > &innerData)
CreateWidget - X11 version.
void SetFormat()
Set pixel format.
std::pair< void *, void * > GetInnerData() const
Dpy*, XVisualInfo *.
std::pair< void *, void * > fInnerData
Definition TGLWidget.h:34
Bool_t HandleMotion(Event_t *ev) override
Delegate call to the owner.
const TGLContext * GetContext() const override
Get gl context.
Bool_t ClearCurrent()
Clear the current gl-context.
Bool_t HandleCrossing(Event_t *) override
Handle mouse crossing event.
void SetEventHandler(TGEventHandler *eh)
Set event-handler. All events are passed to this object.
const TGLFormat * GetPixelFormat() const override
Pixel format.
TGLContext * fGLContext
Definition TGLWidget.h:32
~TGLWidget() override
Destructor. Deletes window ???? and XVisualInfo.
Int_t fWindowIndex
Definition TGLWidget.h:35
void ExtractViewport(Int_t *vp) const override
For camera.
TGLWidget(const TGLWidget &)=delete
Handle_t GetId() const
Definition TGObject.h:41
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
@ kDepth
Definition TVirtualGL.h:130
@ kMultiSample
Definition TVirtualGL.h:134
@ kStencil
Definition TVirtualGL.h:132
@ kStereo
Definition TVirtualGL.h:133
@ kDoubleBuffer
Definition TVirtualGL.h:129
@ kNone
Definition TVirtualGL.h:128
@ kAccum
Definition TVirtualGL.h:131
TOneArgGuard< Func, Arg > make_guard(Func f, Arg a)
Definition TGLUtil.h:1329
Event structure.
Definition GuiTypes.h:174