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 return;
369 }
370
372
374 reinterpret_cast<LayoutCompatible_t *>(GetId());
375 HWND hWND = *trick->fPHwnd;
376 HDC hDC = GetWindowDC(hWND);
377
378 if (!hDC) {
379 Error("TGLWidget::SetFormat", "GetWindowDC failed");
380 throw std::runtime_error("GetWindowDC failed");
381 }
382
383 static bool wgl_init = false;
384 if ( ! wgl_init) {
385 wgl_init = true;
387 if (version == 0)
388 Warning("TGLWidget::SetFormat", "WGL initalization failed.");
389 else if (gDebug > 0)
390 Info("TGLWidget::SetFormat", "WGL initalization successful.");
391 }
392
396
397 if (const Int_t pixIndex = ChoosePixelFormat(hDC, &pfd)) {
399
400 if (!SetPixelFormat(hDC, pixIndex, &pfd)) {
401 Error("TGLWidget::SetFormat", "SetPixelFormat failed");
402 throw std::runtime_error("SetPixelFormat failed");
403 }
404 } else {
405 Error("TGLWidget::SetFormat", "ChoosePixelFormat failed");
406 throw std::runtime_error("ChoosePixelFormat failed");
407 }
408}
409//==============================================================================
410#elif defined(R__HAS_COCOA) //MacOSX with Cocoa enabled.
411//==============================================================================
412
413////////////////////////////////////////////////////////////////////////////////
414/// CreateWidget - MacOSX/Cocoa version.
415/// Static function called prior to construction.
416
419 std::pair<void *, void *>& /*internalData*/)
420{
421 typedef std::pair<UInt_t, Int_t> component_type;
422
423 std::vector<component_type>formatComponents;
424
425 if (format.HasDepth())
426 formatComponents.push_back(component_type(Rgl::kDepth, format.GetDepthSize()));
427 if (format.HasStencil())
428 formatComponents.push_back(component_type(Rgl::kStencil, format.GetStencilSize()));
429 if (format.HasAccumBuffer())
430 formatComponents.push_back(component_type(Rgl::kAccum, format.GetAccumSize()));
431 if (format.IsDoubleBuffered())
433 if (format.IsStereo())
435 if (format.HasMultiSampling())
437
438 return gVirtualX->CreateOpenGLWindow(parent->GetId(), width, height, formatComponents);
439}
440
441////////////////////////////////////////////////////////////////////////////////
442/// Set pixel format.
443/// Empty version for X11.
444
446{
447}
448
449//==============================================================================
450#else // X11
451//==============================================================================
452
453namespace
454{
455 void fill_format(std::vector<Int_t> &format, const TGLFormat &request)
456 {
457 format.push_back(GLX_RGBA);
458 format.push_back(GLX_RED_SIZE);
459 format.push_back(8);
460 format.push_back(GLX_GREEN_SIZE);
461 format.push_back(8);
462 format.push_back(GLX_BLUE_SIZE);
463 format.push_back(8);
464
465 if (request.IsDoubleBuffered())
466 format.push_back(GLX_DOUBLEBUFFER);
467
468 if (request.HasDepth()) {
469 format.push_back(GLX_DEPTH_SIZE);
470 format.push_back(request.GetDepthSize());
471 }
472
473 if (request.HasStencil()) {
474 format.push_back(GLX_STENCIL_SIZE);
475 format.push_back(request.GetStencilSize());
476 }
477
478 if (request.HasAccumBuffer()) {
479 format.push_back(GLX_ACCUM_RED_SIZE);
480 format.push_back(8);
481 format.push_back(GLX_ACCUM_GREEN_SIZE);
482 format.push_back(8);
483 format.push_back(GLX_ACCUM_BLUE_SIZE);
484 format.push_back(8);
485 }
486
487 if (request.IsStereo()) {
488 format.push_back(GLX_STEREO);
489 }
490
491 if (request.HasMultiSampling())
492 {
494 format.push_back(1);
495 format.push_back(GLX_SAMPLES_ARB);
496 format.push_back(request.GetSamples());
497 }
498
499 format.push_back(None);
500 }
501}
502
503////////////////////////////////////////////////////////////////////////////////
504/// CreateWidget - X11 version.
505/// Static function called prior to construction.
506/// Can throw std::bad_alloc and std::runtime_error.
507/// This version is bad - I do not check the results of
508/// X11 calls.
509
512 std::pair<void *, void *>& innerData)
513{
514 std::vector<Int_t> glxfmt;
516
517 Display *dpy = reinterpret_cast<Display *>(gVirtualX->GetDisplay());
518 if (!dpy) {
519 ::Error("TGLWidget::CreateWindow", "Display is not set!");
520 throw std::runtime_error("Display is not set!");
521 }
522
523 static std::atomic<bool> s_glx_init_done = false;
524 bool glx_init = false;
525 if (s_glx_init_done.compare_exchange_strong(glx_init, true)) {
527 if (version == 0)
528 ::Warning("TGLWidget::CreateWindow", "GLX initalization failed.");
529 else if (gDebug > 0)
530 ::Info("TGLWidget::CreateWindow", "GLX initalization successful.");
531 }
532
534
535 if (!visInfo) {
536 ::Error("TGLWidget::CreateWindow", "No good OpenGL visual found!");
537 throw std::runtime_error("No good OpenGL visual found!");
538 }
539
540 Window_t winID = parent->GetId();
541
543 attr.colormap = XCreateColormap(dpy, winID, visInfo->visual, AllocNone); // Can fail?
544 attr.background_pixel = 0;
545 attr.event_mask = NoEventMask;
546 attr.backing_store = Always;
547 attr.bit_gravity = NorthWestGravity;
548
551 visInfo->depth,
552 InputOutput, visInfo->visual, mask, &attr);
553
554 innerData.first = dpy;
555 innerData.second = visInfo;
556
557 return glWin;
558}
559
560////////////////////////////////////////////////////////////////////////////////
561/// Set pixel format.
562/// Empty version for X11.
563
565{
566}
567
568//==============================================================================
569#endif
570//==============================================================================
571
572
573//==============================================================================
574// Event handling
575//==============================================================================
576
577////////////////////////////////////////////////////////////////////////////////
578///Set event-handler. All events are passed to this object.
579
584
585////////////////////////////////////////////////////////////////////////////////
586/// Handle mouse crossing event.
587
589{
590 if (!gVirtualX->IsCmdThread()) {
591 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleCrossing((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
592 return kTRUE;
593 }
595
596 if ((ev->fType == kEnterNotify) &&
597 (!gVirtualX->InheritsFrom("TGX11")) &&
598 (gVirtualX->GetInputFocus() != GetId())) {
599 gVirtualX->SetInputFocus(GetId());
600 }
601 if (fEventHandler)
603 return kFALSE;
604}
605
606////////////////////////////////////////////////////////////////////////////////
607///Delegate call to the owner.
608
610{
611 if (!gVirtualX->IsCmdThread()) {
612 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleButton((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
613 return kTRUE;
614 }
616
617 if (fEventHandler)
619 return kFALSE;
620}
621
622////////////////////////////////////////////////////////////////////////////////
623///Delegate call to the owner.
624
626{
627 if (!gVirtualX->IsCmdThread()) {
628 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleDoubleClick((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
629 return kTRUE;
630 }
632
633 if (fEventHandler)
635 return kFALSE;
636}
637
638////////////////////////////////////////////////////////////////////////////////
639///Delegate call to the owner.
640
642{
643 if (!gVirtualX->IsCmdThread()) {
644 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleConfigureNotify((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
645 return kTRUE;
646 }
648
650 {
652 return kTRUE;
653 }
654 return kFALSE;
655}
656
657////////////////////////////////////////////////////////////////////////////////
658///Delegate call to the owner.
659
661{
662 if (!gVirtualX->IsCmdThread()) {
663 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleFocusChange((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
664 return kTRUE;
665 }
667
668 if (fEventHandler)
670 return kFALSE;
671}
672
673////////////////////////////////////////////////////////////////////////////////
674///Delegate call to the owner.
675
677{
678 if (!gVirtualX->IsCmdThread()) {
679 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleKey((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
680 return kTRUE;
681 }
683
684 if (fEventHandler)
685 return fEventHandler->HandleKey(ev);
686 return kFALSE;
687}
688
689////////////////////////////////////////////////////////////////////////////////
690///Delegate call to the owner.
691
693{
694 if (!gVirtualX->IsCmdThread()) {
695 gROOT->ProcessLineFast(Form("((TGLWidget *)0x%zx)->HandleMotion((Event_t *)0x%zx)", (size_t)this, (size_t)ev));
696 return kTRUE;
697 }
699
700 if (fEventHandler)
702 return kFALSE;
703}
704
705////////////////////////////////////////////////////////////////////////////////
706///Delegate call to the owner.
707
709{
710 if (fEventHandler)
711 return fEventHandler->Repaint();
712}
@ 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
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:627
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:414
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:338
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:1075
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1089
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1063
@ 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