5 #include <Foundation/Foundation.h>
16 ClassImp(TGOSXGLManager)
19 TGOSXGLManager::TGOSXGLManager()
27 assert(gGLManager == 0 &&
"TGOSXGLManager, gGLManager is initialized");
30 if (gROOT && gROOT->GetListOfSpecials())
31 gROOT->GetListOfSpecials()->Add(
this);
36 TGOSXGLManager::~TGOSXGLManager()
40 if (gROOT && gROOT->GetListOfSpecials())
41 gROOT->GetListOfSpecials()->Remove(
this);
46 Int_t TGOSXGLManager::InitGLWindow(Window_t parentID)
48 typedef std::pair<UInt_t, Int_t> component_type;
50 std::vector<component_type> format;
52 format.push_back(component_type(Rgl::kDoubleBuffer, 1));
53 format.push_back(component_type(Rgl::kStencil, 8));
54 format.push_back(component_type(Rgl::kDepth, 32));
57 const Int_t nSamples = gEnv->GetValue(
"OpenGL.Framebuffer.Multisample", 0);
58 if (nSamples > 0 && nSamples <= 8)
59 format.push_back(component_type(Rgl::kMultiSample, nSamples));
64 UInt_t width = 0, height = 0;
65 gVirtualX->GetWindowSize(parentID, x, y, width, height);
67 const Window_t glWin = gVirtualX->CreateOpenGLWindow(parentID, width, height, format);
71 gVirtualX->MapWindow(glWin);
81 Int_t TGOSXGLManager::CreateGLContext(Int_t winID)
86 const Handle_t ctx = gVirtualX->CreateOpenGLContext(winID, kNone);
87 fCtxToWin[ctx] = Window_t(winID);
93 void TGOSXGLManager::DeleteGLContext(Int_t ctxInd)
96 gVirtualX->DeleteOpenGLContext(ctxInd);
100 Bool_t TGOSXGLManager::MakeCurrent(Int_t ctxInd)
102 assert(fCtxToWin.find(Handle_t(ctxInd)) != fCtxToWin.end() &&
103 "MakeCurrent, window not found for a given context");
105 return gVirtualX->MakeOpenGLContextCurrent(Handle_t(ctxInd), fCtxToWin[Handle_t(ctxInd)]);
109 void TGOSXGLManager::Flush(Int_t ctxInd)
111 gVirtualX->FlushOpenGLBuffer(ctxInd);
116 Int_t TGOSXGLManager::GetVirtualXInd(Int_t ctxInd)
125 Bool_t TGOSXGLManager::AttachOffScreenDevice(Int_t, Int_t, Int_t, UInt_t, UInt_t)
133 Bool_t TGOSXGLManager::ResizeOffScreenDevice(Int_t, Int_t, Int_t, UInt_t, UInt_t)
141 void TGOSXGLManager::SelectOffScreenDevice(Int_t)
148 void TGOSXGLManager::MarkForDirectCopy(Int_t, Bool_t)
154 void TGOSXGLManager::ExtractViewport(Int_t, Int_t *)
160 void TGOSXGLManager::ReadGLBuffer(Int_t)
168 Bool_t TGOSXGLManager::SelectManip(TVirtualGLManip *manip,
const TGLCamera *camera,
const TGLRect *rect,
const TGLBoundingBox *sceneBox)
172 assert(manip != 0 &&
"SelectManip, parameter 'manip' is null");
173 assert(camera != 0 &&
"SelectManip, parameter 'camera' is null");
174 assert(rect != 0 &&
"SelectManip, parameter 'rect' is null");
175 assert(sceneBox != 0 &&
"SelectManip, parameter 'sceneBox' is null");
178 return manip->Select(*camera, *rect, *sceneBox);
182 Bool_t TGOSXGLManager::PlotSelected(TVirtualGLPainter *plot, Int_t px, Int_t py)
185 assert(plot != 0 &&
"PlotSelected, parameter 'plot' is null");
187 return plot->PlotSelected(px, py);
191 char *TGOSXGLManager::GetPlotInfo(TVirtualGLPainter *plot, Int_t px, Int_t py)
194 assert(plot != 0 &&
"GetPlotInfo, parameter 'plot' is null");
196 return plot->GetPlotInfo(px, py);
200 void TGOSXGLManager::PaintSingleObject(TVirtualGLPainter *p)
203 assert(p != 0 &&
"PaintSingleObject, parameter 'p' is null");
209 void TGOSXGLManager::PanObject(TVirtualGLPainter *
object, Int_t x, Int_t y)
212 assert(
object != 0 &&
"PanObject, parameter 'object' is null");
214 return object->Pan(x, y);
218 void TGOSXGLManager::PrintViewer(TVirtualViewer3D *vv)
221 assert(vv != 0 &&
"PrintViewer, parameter 'vv' is null");