61 typedef std::deque<TX11GLManager::TGLContext_t> DeviceTable_t;
62 typedef DeviceTable_t::size_type SizeType_t;
63 typedef std::map<Int_t, XVisualInfo *> WinTable_t;
73 TX11PixGuard(Display *dpy, Pixmap
pix) : fDpy(dpy), fPix(
pix) {}
74 ~TX11PixGuard(){
if (fPix) XFreePixmap(fDpy, fPix);}
75 void Stop(){fPix = 0;}
78 TX11PixGuard(
const TX11PixGuard &) =
delete;
79 TX11PixGuard &
operator = (
const TX11PixGuard &) =
delete;
89 TGLXCtxGuard(Display *dpy, GLXContext ctx) : fDpy(dpy), fCtx(ctx) {}
90 ~TGLXCtxGuard(){
if (fCtx) glXDestroyContext(fDpy, fCtx);}
91 void Stop(){fCtx =
nullptr;}
94 TGLXCtxGuard(
const TGLXCtxGuard &) =
delete;
95 TGLXCtxGuard &
operator = (
const TGLXCtxGuard &) =
delete;
103 TXImageGuard(
const TXImageGuard &) =
delete;
104 TXImageGuard &
operator = (
const TXImageGuard &) =
delete;
107 explicit TXImageGuard(XImage *im) : fImage(im) {}
108 ~TXImageGuard(){
if (fImage) XDestroyImage(fImage);}
109 void Stop(){fImage =
nullptr;}
167 ::Warning(
"TX11GLManager::~TX11GLManager",
"opengl device with index %ld was not destroyed", (
Long_t)
i);
187 gROOT->GetListOfSpecials()->
Add(
this);
211 Error(
"InitGLWindow",
"No good visual found!\n");
218 XGetGeometry(
fPimpl->fDpy, winID, &root, &
x, &
y, &
w, &
h, &
b, &
d);
221 attr.colormap = XCreateColormap(
fPimpl->fDpy, root, visInfo->visual, AllocNone);
222 attr.event_mask = NoEventMask;
223 attr.backing_store = Always;
224 attr.bit_gravity = NorthWestGravity;
226 ULong_t mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWBackingStore | CWBitGravity;
229 Window glWin = XCreateWindow(
232 0, visInfo->depth, InputOutput,
237 XMapWindow(
fPimpl->fDpy, glWin);
243 fPimpl->fGLWindows[x11Ind] = visInfo;
255 GLXContext glxCtx = glXCreateContext(
fPimpl->fDpy,
fPimpl->fGLWindows[winInd], None, True);
258 Error(
"CreateContext",
"glXCreateContext failed\n");
264 Int_t ind = ctx->fWindowIndex;
265 ctx->fWindowIndex = winInd;
266 ctx->fGLXContext = glxCtx;
267 fPimpl->fNextFreeContext =
fPimpl->fNextFreeContext->fNextFreeContext;
270 TGLXCtxGuard glxCtxGuard(
fPimpl->fDpy, glxCtx);
275 fPimpl->fGLContexts.push_back(newDev);
302 glXSwapBuffers(
fPimpl->fDpy, winID);
308 Error(
"Flush",
"XCreateGC failed while copying pixmap\n");
328 Error(
"CreateGLPixmap",
"XCreatePixmap failed\n");
332 TX11PixGuard pixGuard(
fPimpl->fDpy, x11Pix);
336 XImage *testIm = XCreateImage(
fPimpl->fDpy, visInfo->visual, visInfo->depth, ZPixmap,
337 0,
nullptr, ctx.
fW, ctx.
fH,
338 visInfo->depth <= 8 ? 8 : (visInfo->depth <= 16 ? 16 : 32), 0);
341 TXImageGuard imGuard(testIm);
342 testIm->data =
static_cast<Char_t *
>(
malloc(testIm->bytes_per_line * testIm->height));
345 Error(
"CreateGLPixmap",
"Cannot malloc XImage data\n");
349 if (XInitImage(testIm)) {
351 ctx.
fBUBuffer.resize(testIm->bytes_per_line * testIm->height);
358 Error(
"CreateGLPixmap",
"XInitImage error!\n");
360 Error(
"CreateGLPixmap",
"XCreateImage error!\n");
375 newCtx.
fW =
w, newCtx.
fH =
h, newCtx.
fX =
x, newCtx.
fY =
y;
404 newCtx.
fW =
w, newCtx.
fH =
h, newCtx.
fX =
x, newCtx.
fY =
y;
419 Error(
"ResizeOffScreenDevice",
"Resize failed\n");
444 if (
fPimpl->fGLContexts[ctxInd].fPixmapIndex != -1)
445 fPimpl->fGLContexts[ctxInd].fDirect = dir;
459 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
460 glReadBuffer(GL_BACK);
477 Error(
"ReadGLBuffer",
"XCreateGC error while attempt to copy XImage\n");
509 fPimpl->fNextFreeContext = &ctx;
519 return fPimpl->fGLContexts[ctxInd].fPixmapIndex;
533 viewport[2] = ctx.
fW;
534 viewport[3] = ctx.
fH;
561 return manip->
Select(*camera, *
rect, *sceneBox);
Handle_t Window_t
Window handle.
RInterface & operator=(const RInterface &)=default
Copy-assignment operator for RInterface.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pix
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 void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
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 rect
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 src
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Viewport (pixel base) 2D rectangle 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.
virtual Bool_t Select(const TGLCamera &camera, const TGLRect &rect, const TGLBoundingBox &sceneBox)=0
virtual Bool_t PlotSelected(Int_t px, Int_t py)=0
virtual char * GetPlotInfo(Int_t px, Int_t py)=0
virtual void Pan(Int_t px, Int_t py)=0
Abstract 3D shapes viewer.
virtual void PrintObjects()
DeviceTable_t fGLContexts
TX11GLImpl(const TX11GLImpl &)=delete
TGLContext_t * fNextFreeContext
TX11GLImpl & operator=(const TX11GLImpl &)=delete
void PanObject(TVirtualGLPainter *o, Int_t x, Int_t y) override
Pan objects.
Int_t InitGLWindow(Window_t winID) override
Try to find correct visual.
~TX11GLManager() override
Destructor.
char * GetPlotInfo(TVirtualGLPainter *plot, Int_t px, Int_t py) override
Analog of TObject::GetObjectInfo.
void ReadGLBuffer(Int_t devInd) override
GL buffer is read info buffer, after that lines are reordered into XImage, XImage copied into pixmap.
void SelectOffScreenDevice(Int_t devInd) override
Selects off-screen device to make it accessible by gVirtualX.
void Flush(Int_t ctxInd) override
Swaps buffers or copy pixmap.
Bool_t AttachOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) override
Attach off screen device.
void DeleteGLContext(Int_t devInd) override
Deletes GLX context and frees pixmap and image (if any).
void MarkForDirectCopy(Int_t devInd, Bool_t) override
Selection-rotation support for TPad/TCanvas.
Bool_t MakeCurrent(Int_t devInd) override
Make GL context current.
Int_t GetVirtualXInd(Int_t devInd) override
Returns an index suitable for gVirtualX.
Bool_t ResizeOffScreenDevice(Int_t devInd, Int_t x, Int_t y, UInt_t w, UInt_t h) override
Resize off screen device.
Int_t CreateGLContext(Int_t winInd) override
Context creation requires Display * and XVisualInfo (was saved for such winInd).
Bool_t CreateGLPixmap(TGLContext_t &)
Create GL pixmap.
void PrintViewer(TVirtualViewer3D *vv) override
Print viewer.
void PaintSingleObject(TVirtualGLPainter *) override
Paint a single object.
Bool_t PlotSelected(TVirtualGLPainter *plot, Int_t px, Int_t py) override
Analog of TObject::DistancetoPrimitive.
TX11GLManager()
Constructor.
Bool_t SelectManip(TVirtualGLManip *manip, const TGLCamera *camera, const TGLRect *rect, const TGLBoundingBox *sceneBox) override
Select manipulator.
void ExtractViewport(Int_t devInd, Int_t *vp) override
Returns the current dimensions of a GL pixmap.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.
TGLContext_t * fNextFreeContext
std::vector< UChar_t > fBUBuffer