Logo ROOT  
Reference Guide
TVirtualGL.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Valery Fine(fine@vxcern.cern.ch) 05/03/97
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 #ifndef ROOT_TVirtualGL
13 #define ROOT_TVirtualGL
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TVirtualGL //
19 // //
20 // The TVirtualGL class is an abstract base class defining the //
21 // OpenGL interface protocol. All interactions with OpenGL should be //
22 // done via the global pointer gVirtualGL. If the OpenGL library is //
23 // available this pointer is pointing to an instance of the TGLKernel //
24 // class which provides the actual interface to OpenGL. Using this //
25 // scheme of ABC we can use OpenGL in other parts of the framework //
26 // without having to link with the OpenGL library in case we don't //
27 // use the classes using OpenGL. //
28 // //
29 //////////////////////////////////////////////////////////////////////////
30 
31 #include "TNamed.h"
32 #include "GuiTypes.h"
33 #include "GLConstants.h"
34 
35 class TVirtualViewer3D;
36 class TPoints3DABC;
37 class TGLViewer;
38 class TGLCamera;
39 class TGLManip;
40 class TGLBoundingBox;
41 class TGLRect;
42 
43 //TVirtualGLPainter is the base for histogramm painters.
44 
46 public:
47  virtual ~TVirtualGLPainter(){}
48 
49  virtual void Paint() = 0;
50  virtual void Pan(Int_t px, Int_t py) = 0;
51  virtual Bool_t PlotSelected(Int_t px, Int_t py) = 0;
52  //Used by status bar in a canvas.
53  virtual char *GetPlotInfo(Int_t px, Int_t py) = 0;
54 
55  ClassDef(TVirtualGLPainter, 0); // Interface for OpenGL painter
56 };
57 
58 //We need this class to implement TGWin32GLManager's SelectManip
60 public:
61  virtual ~TVirtualGLManip(){}
62  virtual Bool_t Select(const TGLCamera & camera, const TGLRect & rect, const TGLBoundingBox & sceneBox) = 0;
63 
64  ClassDef(TVirtualGLManip, 0); //Interface for GL manipulator
65 };
66 
67 //This class (and its descendants) in future will replace (?)
68 //TVirtualGL/TGLKernel/TGWin32GL/TGX11GL
69 
70 class TGLManager : public TNamed {
71 public:
72  TGLManager();
73 
74  //index returned can be used as a result of gVirtualX->InitWindow
75  virtual Int_t InitGLWindow(Window_t winID) = 0;
76  //winInd is the index, returned by InitGLWindow
77  virtual Int_t CreateGLContext(Int_t winInd) = 0;
78 
79  //[ Off-screen rendering part
80  //create DIB section/pixmap to read GL buffer into it,
81  //ctxInd is the index, returned by CreateGLContext
84  //analog of gVirtualX->SelectWindow(fPixmapID) => gVirtualGL->SelectOffScreenDevice(fPixmapID)
85  virtual void SelectOffScreenDevice(Int_t ctxInd) = 0;
86  //Index of DIB/pixmap, valid for gVirtualX
87  virtual Int_t GetVirtualXInd(Int_t ctxInd) = 0;
88  //copy pixmap into window directly
89  virtual void MarkForDirectCopy(Int_t ctxInd, Bool_t) = 0;
90  //Off-screen device holds sizes for glViewport
91  virtual void ExtractViewport(Int_t ctxInd, Int_t *vp) = 0;
92  //Read GL buffer into off-screen device
93  virtual void ReadGLBuffer(Int_t ctxInd) = 0;
94  //]
95 
96  //Make the gl context current
97  virtual Bool_t MakeCurrent(Int_t ctxInd) = 0;
98  //Swap buffers or copies DIB/pixmap (via BitBlt/XCopyArea)
99  virtual void Flush(Int_t ctxInd) = 0;
100  //GL context and off-screen device deletion
101  virtual void DeleteGLContext(Int_t ctxInd) = 0;
102 
103  //functions to switch between threads in win32
104  virtual Bool_t SelectManip(TVirtualGLManip *manip, const TGLCamera *camera, const TGLRect *rect, const TGLBoundingBox *sceneBox) = 0;
105  //
107  virtual void PanObject(TVirtualGLPainter *o, Int_t x, Int_t y) = 0;
108  //EPS/PDF output
109  virtual void PrintViewer(TVirtualViewer3D *vv) = 0;
110 
111  virtual Bool_t PlotSelected(TVirtualGLPainter *plot, Int_t px, Int_t py) = 0;
112  virtual char *GetPlotInfo(TVirtualGLPainter *plot, Int_t px, Int_t py) = 0;
113 
114  virtual Bool_t HighColorFormat(Int_t ctxInd) = 0;
115 
116  static TGLManager *&Instance();
117 
118 private:
121 
122  ClassDef(TGLManager, 0)// Interface for OpenGL manager
123 };
124 
125 namespace Rgl {
126 
127 //I would prefer to use C++11's strong typed enums insted, but ...
129 {
130  kNone = 0,
132  kDepth = 2,
133  kAccum = 4,
134  kStencil = 8,
135  kStereo = 16,
136  kMultiSample = 32
137 };
138 
139 }
140 
141 class TGLContext;
142 class TGLFormat;
143 
145  friend class TGLContext;
146 public:
147  virtual ~TGLPaintDevice(){}
148  virtual Bool_t MakeCurrent() = 0;
149  virtual void SwapBuffers() = 0;
150  virtual const TGLFormat *GetPixelFormat()const = 0;
151  virtual const TGLContext *GetContext()const = 0;
152  virtual void ExtractViewport(Int_t *vp)const = 0;
153 
154 private:
155  virtual void AddContext(TGLContext *ctx) = 0;
156  virtual void RemoveContext(TGLContext *ctx) = 0;
157 
158  ClassDef(TGLPaintDevice, 0) // Base class for GL widgets and GL off-screen rendering
159 };
160 
161 #ifndef __CINT__
162 #define gGLManager (TGLManager::Instance())
163 R__EXTERN TGLManager *(*gPtr2GLManager)();
164 #endif
165 
166 #endif
TGLManager::ReadGLBuffer
virtual void ReadGLBuffer(Int_t ctxInd)=0
TGLManager::ResizeOffScreenDevice
virtual Bool_t ResizeOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h)=0
TGLManager::TGLManager
TGLManager(const TGLManager &)
Rgl::kDepth
@ kDepth
Definition: TVirtualGL.h:132
TGLManager::ExtractViewport
virtual void ExtractViewport(Int_t ctxInd, Int_t *vp)=0
TGLManager::AttachOffScreenDevice
virtual Bool_t AttachOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h)=0
TVirtualGLPainter
Definition: TVirtualGL.h:45
TGLManager::DeleteGLContext
virtual void DeleteGLContext(Int_t ctxInd)=0
TGLManager::Instance
static TGLManager *& Instance()
Return the global GL Manager.
Definition: TVirtualGL.cxx:43
TGLPaintDevice::SwapBuffers
virtual void SwapBuffers()=0
TNamed.h
TGLCamera
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:44
TVirtualGLManip::~TVirtualGLManip
virtual ~TVirtualGLManip()
Definition: TVirtualGL.h:61
Rgl::kStereo
@ kStereo
Definition: TVirtualGL.h:135
TGLManager::MarkForDirectCopy
virtual void MarkForDirectCopy(Int_t ctxInd, Bool_t)=0
Rgl::kStencil
@ kStencil
Definition: TVirtualGL.h:134
x
Double_t x[n]
Definition: legend1.C:17
TPoints3DABC
Abstract class to define Arrays of 3D points.
Definition: TPoints3DABC.h:25
TGLPaintDevice::~TGLPaintDevice
virtual ~TGLPaintDevice()
Definition: TVirtualGL.h:147
TGLPaintDevice::ExtractViewport
virtual void ExtractViewport(Int_t *vp) const =0
TGLBoundingBox
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Definition: TGLBoundingBox.h:33
TGLManager::SelectOffScreenDevice
virtual void SelectOffScreenDevice(Int_t ctxInd)=0
bool
TVirtualGLPainter::PlotSelected
virtual Bool_t PlotSelected(Int_t px, Int_t py)=0
TVirtualGLPainter::GetPlotInfo
virtual char * GetPlotInfo(Int_t px, Int_t py)=0
Rgl::kAccum
@ kAccum
Definition: TVirtualGL.h:133
TGLManager::GetVirtualXInd
virtual Int_t GetVirtualXInd(Int_t ctxInd)=0
TGLPaintDevice::AddContext
virtual void AddContext(TGLContext *ctx)=0
TGLViewer
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:55
TGLManager::InitGLWindow
virtual Int_t InitGLWindow(Window_t winID)=0
Rgl::kMultiSample
@ kMultiSample
Definition: TVirtualGL.h:136
TGLManager::PaintSingleObject
virtual void PaintSingleObject(TVirtualGLPainter *)=0
TGLFormat
Encapsulation of format / contents of an OpenGL buffer.
Definition: TGLFormat.h:36
TGLManager::operator=
TGLManager & operator=(const TGLManager &)
TGLManager::PlotSelected
virtual Bool_t PlotSelected(TVirtualGLPainter *plot, Int_t px, Int_t py)=0
h
#define h(i)
Definition: RSha256.hxx:106
TGLManager::PanObject
virtual void PanObject(TVirtualGLPainter *o, Int_t x, Int_t y)=0
TGLManager::SelectManip
virtual Bool_t SelectManip(TVirtualGLManip *manip, const TGLCamera *camera, const TGLRect *rect, const TGLBoundingBox *sceneBox)=0
TGLManager::CreateGLContext
virtual Int_t CreateGLContext(Int_t winInd)=0
TGLPaintDevice::GetPixelFormat
virtual const TGLFormat * GetPixelFormat() const =0
GuiTypes.h
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TVirtualGLPainter::~TVirtualGLPainter
virtual ~TVirtualGLPainter()
Definition: TVirtualGL.h:47
TGLContext
This class encapsulates window-system specific information about a GL-context and alows their proper ...
Definition: TGLContext.h:31
TGLManip
Abstract base class for viewer manipulators, which allow direct in viewer manipulation of a (TGlPhysi...
Definition: TGLManip.h:29
TGLManager
Definition: TVirtualGL.h:70
GLConstants.h
Window_t
Handle_t Window_t
Definition: GuiTypes.h:28
TVirtualGLPainter::Paint
virtual void Paint()=0
TGLManager::TGLManager
TGLManager()
Definition: TVirtualGL.cxx:36
y
Double_t y[n]
Definition: legend1.C:17
TGLManager::Flush
virtual void Flush(Int_t ctxInd)=0
TGLPaintDevice
Definition: TVirtualGL.h:144
TGLManager::PrintViewer
virtual void PrintViewer(TVirtualViewer3D *vv)=0
unsigned int
TGLManager::HighColorFormat
virtual Bool_t HighColorFormat(Int_t ctxInd)=0
TGLRect
Viewport (pixel base) 2D rectangle class.
Definition: TGLUtil.h:422
TVirtualGLPainter::Pan
virtual void Pan(Int_t px, Int_t py)=0
TGLManager::MakeCurrent
virtual Bool_t MakeCurrent(Int_t ctxInd)=0
TGLPaintDevice::MakeCurrent
virtual Bool_t MakeCurrent()=0
Rgl
Definition: TVirtualGL.h:125
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TVirtualViewer3D
Abstract 3D shapes viewer.
Definition: TVirtualViewer3D.h:34
Rgl::kDoubleBuffer
@ kDoubleBuffer
Definition: TVirtualGL.h:131
TVirtualGLManip
Definition: TVirtualGL.h:59
Rgl::EFormatOptions
EFormatOptions
Definition: TVirtualGL.h:129
R__EXTERN
#define R__EXTERN
Definition: DllImport.h:27
TGLPaintDevice::RemoveContext
virtual void RemoveContext(TGLContext *ctx)=0
TGLPaintDevice::GetContext
virtual const TGLContext * GetContext() const =0
Rgl::kNone
@ kNone
Definition: TVirtualGL.h:130
TVirtualGLManip::Select
virtual Bool_t Select(const TGLCamera &camera, const TGLRect &rect, const TGLBoundingBox &sceneBox)=0
TGLManager::GetPlotInfo
virtual char * GetPlotInfo(TVirtualGLPainter *plot, Int_t px, Int_t py)=0
int