22#include "TGLIncludes.h"
26#include "RConfigure.h"
89 return Create(
format, parent, selectInput, shareDefault, shareDevice,
104 std::pair<void *, void *> innerData;
112#elif defined(R__HAS_COCOA)
124 (glw, shareDefault, shareDevice && !shareDefault ? shareDevice->
GetContext() : 0);
126 catch (
const std::exception &)
170 Warning(
"~TGLWidget",
"There are some gl-contexts connected to this gl device"
171 "which have longer lifetime than lifetime of gl-device");
285 struct LayoutCompatible_t {
289 unsigned char fDummy2;
291 unsigned short fDummy4;
292 unsigned short fDummy5;
297 void fill_pfd(PIXELFORMATDESCRIPTOR *pfd,
const TGLFormat &request)
299 pfd->nSize =
sizeof(PIXELFORMATDESCRIPTOR);
301 pfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
303 pfd->dwFlags |= PFD_DOUBLEBUFFER;
304 pfd->iPixelType = PFD_TYPE_RGBA;
305 pfd->cColorBits = 24;
307 pfd->cAccumBits = acc;
309 pfd->cDepthBits = depth;
311 pfd->cStencilBits = stencil;
314 void check_pixel_format(
Int_t pixIndex, HDC hDC,
TGLFormat &request)
316 PIXELFORMATDESCRIPTOR pfd = {};
318 if (!DescribePixelFormat(hDC, pixIndex,
sizeof pfd, &pfd)) {
319 Warning(
"TGLContext::SetContext",
"DescribePixelFormat failed");
329 if (pfd.cStencilBits)
348 std::pair<void *, void *>& innerData)
351 innerData.second = (
void*)(
Longptr_t)widx;
364 Error(
"TGLWidget::SetFormat",
"Sorry, you should not call this function");
368 gROOT->ProcessLineFast(
Form(
"((TGLWidget *)0x%zx)->SetFormat()", (
size_t)
this));
372 LayoutCompatible_t *trick =
373 reinterpret_cast<LayoutCompatible_t *
>(
GetId());
374 HWND hWND = *trick->fPHwnd;
375 HDC hDC = GetWindowDC(hWND);
378 Error(
"TGLWidget::SetFormat",
"GetWindowDC failed");
379 throw std::runtime_error(
"GetWindowDC failed");
383 PIXELFORMATDESCRIPTOR pfd = {};
386 if (
const Int_t pixIndex = ChoosePixelFormat(hDC, &pfd)) {
387 check_pixel_format(pixIndex, hDC,
fGLFormat);
389 if (!SetPixelFormat(hDC, pixIndex, &pfd)) {
390 Error(
"TGLWidget::SetFormat",
"SetPixelFormat failed");
391 throw std::runtime_error(
"SetPixelFormat failed");
394 Error(
"TGLWidget::SetFormat",
"ChoosePixelFormat failed");
395 throw std::runtime_error(
"ChoosePixelFormat failed");
399#elif defined(R__HAS_COCOA)
408 std::pair<void *, void *>& )
410 typedef std::pair<UInt_t, Int_t> component_type;
412 std::vector<component_type>formatComponents;
418 if (
format.HasAccumBuffer())
420 if (
format.IsDoubleBuffered())
423 formatComponents.push_back(component_type(
Rgl::kStereo, 0));
424 if (
format.HasMultiSampling())
446 format.push_back(GLX_RGBA);
447 format.push_back(GLX_RED_SIZE);
449 format.push_back(GLX_GREEN_SIZE);
451 format.push_back(GLX_BLUE_SIZE);
455 format.push_back(GLX_DOUBLEBUFFER);
458 format.push_back(GLX_DEPTH_SIZE);
463 format.push_back(GLX_STENCIL_SIZE);
468 format.push_back(GLX_ACCUM_RED_SIZE);
470 format.push_back(GLX_ACCUM_GREEN_SIZE);
472 format.push_back(GLX_ACCUM_BLUE_SIZE);
477 format.push_back(GLX_STEREO);
482 format.push_back(GLX_SAMPLE_BUFFERS_ARB);
484 format.push_back(GLX_SAMPLES_ARB);
501 std::pair<void *, void *>& innerData)
503 std::vector<Int_t> glxfmt;
504 fill_format(glxfmt,
format);
506 Display *dpy =
reinterpret_cast<Display *
>(
gVirtualX->GetDisplay());
508 ::Error(
"TGLWidget::CreateWindow",
"Display is not set!");
509 throw std::runtime_error(
"Display is not set!");
511 XVisualInfo *visInfo = glXChooseVisual(dpy, DefaultScreen(dpy), &glxfmt[0]);
514 ::Error(
"TGLWidget::CreateWindow",
"No good OpenGL visual found!");
515 throw std::runtime_error(
"No good OpenGL visual found!");
521 attr.colormap = XCreateColormap(dpy, winID, visInfo->visual, AllocNone);
522 attr.background_pixel = 0;
523 attr.event_mask = NoEventMask;
524 attr.backing_store = Always;
525 attr.bit_gravity = NorthWestGravity;
527 ULong_t mask = CWBackPixel | CWColormap | CWEventMask | CWBackingStore | CWBitGravity;
530 InputOutput, visInfo->visual,
mask, &
attr);
532 innerData.first = dpy;
533 innerData.second = visInfo;
569 gROOT->ProcessLineFast(
Form(
"((TGLWidget *)0x%zx)->HandleCrossing((Event_t *)0x%zx)", (
size_t)
this, (
size_t)ev));
590 gROOT->ProcessLineFast(
Form(
"((TGLWidget *)0x%zx)->HandleButton((Event_t *)0x%zx)", (
size_t)
this, (
size_t)ev));
606 gROOT->ProcessLineFast(
Form(
"((TGLWidget *)0x%zx)->HandleDoubleClick((Event_t *)0x%zx)", (
size_t)
this, (
size_t)ev));
622 gROOT->ProcessLineFast(
Form(
"((TGLWidget *)0x%zx)->HandleConfigureNotify((Event_t *)0x%zx)", (
size_t)
this, (
size_t)ev));
641 gROOT->ProcessLineFast(
Form(
"((TGLWidget *)0x%zx)->HandleFocusChange((Event_t *)0x%zx)", (
size_t)
this, (
size_t)ev));
657 gROOT->ProcessLineFast(
Form(
"((TGLWidget *)0x%zx)->HandleKey((Event_t *)0x%zx)", (
size_t)
this, (
size_t)ev));
673 gROOT->ProcessLineFast(
Form(
"((TGLWidget *)0x%zx)->HandleMotion((Event_t *)0x%zx)", (
size_t)
this, (
size_t)ev));
const Mask_t kFocusChangeMask
const Mask_t kButtonPressMask
const Mask_t kExposureMask
Handle_t Window_t
Window handle.
const Mask_t kKeyReleaseMask
const Mask_t kAnyModifier
const Mask_t kKeyPressMask
const Mask_t kPointerMotionMask
const Mask_t kLeaveWindowMask
const Mask_t kStructureNotifyMask
const Mask_t kButtonReleaseMask
const Mask_t kEnterWindowMask
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
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 TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
R__EXTERN TVirtualMutex * gROOTMutex
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
#define R__LOCKGUARD(mutex)
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 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,...
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
This class encapsulates window-system specific information about a GL-context and alows their proper ...
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.
virtual const TGLContext * GetContext() const =0
static void InitializeIfNeeded()
Initialize globals that require other libraries to be initialized.
ROOT GUI Window base class.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TOneArgGuard< Func, Arg > make_guard(Func f, Arg a)
EGEventType fType
of event (see EGEventType)