Logo ROOT   6.08/07
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 #ifndef ROOT_TNamed
32 #include "TNamed.h"
33 #endif
34 #ifndef ROOT_GuiTypes
35 #include "GuiTypes.h"
36 #endif
37 #ifndef ROOT_GLConstants
38 #include "GLConstants.h"
39 #endif
40 
41 class TVirtualViewer3D;
42 class TPoints3DABC;
43 class TGLViewer;
44 class TGLCamera;
45 class TGLManip;
46 class TGLBoundingBox;
47 class TGLRect;
48 
49 //TVirtualGLPainter is the base for histogramm painters.
50 
52 public:
53  virtual ~TVirtualGLPainter(){}
54 
55  virtual void Paint() = 0;
56  virtual void Pan(Int_t px, Int_t py) = 0;
57  virtual Bool_t PlotSelected(Int_t px, Int_t py) = 0;
58  //Used by status bar in a canvas.
59  virtual char *GetPlotInfo(Int_t px, Int_t py) = 0;
60 
61  ClassDef(TVirtualGLPainter, 0); // Interface for OpenGL painter
62 };
63 
64 //We need this class to implement TGWin32GLManager's SelectManip
66 public:
67  virtual ~TVirtualGLManip(){}
68  virtual Bool_t Select(const TGLCamera & camera, const TGLRect & rect, const TGLBoundingBox & sceneBox) = 0;
69 
70  ClassDef(TVirtualGLManip, 0); //Interface for GL manipulator
71 };
72 
73 //This class (and its descendants) in future will replace (?)
74 //TVirtualGL/TGLKernel/TGWin32GL/TGX11GL
75 
76 class TGLManager : public TNamed {
77 public:
78  TGLManager();
79 
80  //index returned can be used as a result of gVirtualX->InitWindow
81  virtual Int_t InitGLWindow(Window_t winID) = 0;
82  //winInd is the index, returned by InitGLWindow
83  virtual Int_t CreateGLContext(Int_t winInd) = 0;
84 
85  //[ Off-screen rendering part
86  //create DIB section/pixmap to read GL buffer into it,
87  //ctxInd is the index, returned by CreateGLContext
88  virtual Bool_t AttachOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) = 0;
89  virtual Bool_t ResizeOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) = 0;
90  //analog of gVirtualX->SelectWindow(fPixmapID) => gVirtualGL->SelectOffScreenDevice(fPixmapID)
91  virtual void SelectOffScreenDevice(Int_t ctxInd) = 0;
92  //Index of DIB/pixmap, valid for gVirtualX
93  virtual Int_t GetVirtualXInd(Int_t ctxInd) = 0;
94  //copy pixmap into window directly
95  virtual void MarkForDirectCopy(Int_t ctxInd, Bool_t) = 0;
96  //Off-screen device holds sizes for glViewport
97  virtual void ExtractViewport(Int_t ctxInd, Int_t *vp) = 0;
98  //Read GL buffer into off-screen device
99  virtual void ReadGLBuffer(Int_t ctxInd) = 0;
100  //]
101 
102  //Make the gl context current
103  virtual Bool_t MakeCurrent(Int_t ctxInd) = 0;
104  //Swap buffers or copies DIB/pixmap (via BitBlt/XCopyArea)
105  virtual void Flush(Int_t ctxInd) = 0;
106  //GL context and off-screen device deletion
107  virtual void DeleteGLContext(Int_t ctxInd) = 0;
108 
109  //functions to switch between threads in win32
110  virtual Bool_t SelectManip(TVirtualGLManip *manip, const TGLCamera *camera, const TGLRect *rect, const TGLBoundingBox *sceneBox) = 0;
111  //
112  virtual void PaintSingleObject(TVirtualGLPainter *) = 0;
113  virtual void PanObject(TVirtualGLPainter *o, Int_t x, Int_t y) = 0;
114  //EPS/PDF output
115  virtual void PrintViewer(TVirtualViewer3D *vv) = 0;
116 
117  virtual Bool_t PlotSelected(TVirtualGLPainter *plot, Int_t px, Int_t py) = 0;
118  virtual char *GetPlotInfo(TVirtualGLPainter *plot, Int_t px, Int_t py) = 0;
119 
120  virtual Bool_t HighColorFormat(Int_t ctxInd) = 0;
121 
122  static TGLManager *&Instance();
123 
124 private:
125  TGLManager(const TGLManager &);
126  TGLManager &operator = (const TGLManager &);
127 
128  ClassDef(TGLManager, 0)// Interface for OpenGL manager
129 };
130 
131 namespace Rgl {
132 
133 //I would prefer to use C++11's strong typed enums insted, but ...
135 {
136  kNone = 0,
138  kDepth = 2,
139  kAccum = 4,
140  kStencil = 8,
141  kStereo = 16,
143 };
144 
145 }
146 
147 class TGLContext;
148 class TGLFormat;
149 
151  friend class TGLContext;
152 public:
153  virtual ~TGLPaintDevice(){}
154  virtual Bool_t MakeCurrent() = 0;
155  virtual void SwapBuffers() = 0;
156  virtual const TGLFormat *GetPixelFormat()const = 0;
157  virtual const TGLContext *GetContext()const = 0;
158  virtual void ExtractViewport(Int_t *vp)const = 0;
159 
160 private:
161  virtual void AddContext(TGLContext *ctx) = 0;
162  virtual void RemoveContext(TGLContext *ctx) = 0;
163 
164  ClassDef(TGLPaintDevice, 0) // Base class for GL widgets and GL off-screen rendering
165 };
166 
167 #ifndef __CINT__
168 #define gGLManager (TGLManager::Instance())
169 R__EXTERN TGLManager *(*gPtr2GLManager)();
170 #endif
171 
172 #endif
Abstract base class for viewer manipulators, which allow direct in viewer manipulation of a (TGlPhysi...
Definition: TGLManip.h:36
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:43
TH1 * h
Definition: legend2.C:5
Abstract class to define Arrays of 3D points.
Definition: TPoints3DABC.h:27
virtual char * GetPlotInfo(Int_t px, Int_t py)=0
int Int_t
Definition: RtypesCore.h:41
virtual Bool_t PlotSelected(Int_t px, Int_t py)=0
bool Bool_t
Definition: RtypesCore.h:59
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
Bool_t MakeCurrent()
If context is valid (TGLPaintDevice, for which context was created still exists), make it current...
Definition: TGLContext.cxx:362
Viewport (pixel base) 2D rectangle class.
Definition: TGLUtil.h:426
Abstract 3D shapes viewer.
Encapsulation of format / contents of an OpenGL buffer.
Definition: TGLFormat.h:35
EFormatOptions
Definition: TVirtualGL.h:134
unsigned int UInt_t
Definition: RtypesCore.h:42
const Handle_t kNone
Definition: GuiTypes.h:89
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
virtual void Paint()=0
virtual void Pan(Int_t px, Int_t py)=0
virtual ~TVirtualGLPainter()
Definition: TVirtualGL.h:53
void SwapBuffers()
If context is valid (TGLPaintDevice, for which context was created still exists), swap buffers (in ca...
Definition: TGLContext.cxx:395
This class encapsulates window-system specific information about a GL-context and alows their proper ...
Definition: TGLContext.h:35
virtual ~TVirtualGLManip()
Definition: TVirtualGL.h:67
virtual ~TGLPaintDevice()
Definition: TVirtualGL.h:153
Double_t y[n]
Definition: legend1.C:17
Concrete class describing an orientated (free) or axis aligned box of 8 vertices. ...
#define R__EXTERN
Definition: DllImport.h:27
Handle_t Window_t
Definition: GuiTypes.h:30