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 &);
79 TX11PixGuard &
operator = (
const TX11PixGuard &);
89 TGLXCtxGuard(Display *dpy, GLXContext ctx) : fDpy(dpy), fCtx(ctx) {}
90 ~TGLXCtxGuard(){
if (fCtx) glXDestroyContext(fDpy, fCtx);}
91 void Stop(){fCtx = 0;}
94 TGLXCtxGuard(
const TGLXCtxGuard &);
95 TGLXCtxGuard &
operator = (
const TGLXCtxGuard &);
103 TXImageGuard(
const TXImageGuard &);
104 TXImageGuard &
operator = (
const TXImageGuard &);
107 explicit TXImageGuard(
XImage *im) : fImage(im) {}
108 ~TXImageGuard(){
if (fImage) XDestroyImage(fImage);}
109 void Stop(){fImage = 0;}
163 for (SizeType_t i = 0,
e = fGLContexts.size(); i <
e; ++i) {
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");
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,
258 Error(
"CreateContext",
"glXCreateContext failed\n");
264 Int_t ind = ctx->fWindowIndex;
265 ctx->fWindowIndex =
winInd;
266 ctx->fGLXContext = glxCtx;
270 TGLXCtxGuard glxCtxGuard(
fPimpl->
fDpy, glxCtx);
308 Error(
"Flush",
"XCreateGC failed while copying pixmap\n");
328 Error(
"CreateGLPixmap",
"XCreatePixmap failed\n");
336 XImage *testIm = XCreateImage(
fPimpl->
fDpy, visInfo->visual, visInfo->depth, ZPixmap,
337 0, 0, 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");
459 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
460 glReadBuffer(GL_BACK);
477 Error(
"ReadGLBuffer",
"XCreateGC error while attempt to copy XImage\n");
533 viewport[2] = ctx.
fW;
534 viewport[3] = ctx.
fH;
561 return manip->
Select(*camera, *
rect, *sceneBox);
578 return plot->PlotSelected(px, py);
586 return plot->GetPlotInfo(px, py);
Handle_t Window_t
Window handle.
winID h TVirtualViewer3D TVirtualGLPainter p
winID h TVirtualViewer3D vv
winID h TVirtualViewer3D TVirtualGLPainter char TVirtualGLPainter plot
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 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
Binding & operator=(OUT(*fun)(void))
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 void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
virtual Bool_t Select(const TGLCamera &camera, const TGLRect &rect, const TGLBoundingBox &sceneBox)=0
virtual void Pan(Int_t px, Int_t py)=0
Abstract 3D shapes viewer.
virtual void PrintObjects()
DeviceTable_t fGLContexts
TX11GLImpl(const TX11GLImpl &)
TGLContext_t * fNextFreeContext
TX11GLImpl & operator=(const TX11GLImpl &)
The TX11GLManager is X11 implementation of TGLManager.
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.
TGLContext_t * fNextFreeContext
std::vector< UChar_t > fBUBuffer
#define dest(otri, vertexptr)