Logo ROOT   6.12/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 #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
82  virtual Bool_t AttachOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) = 0;
83  virtual Bool_t ResizeOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) = 0;
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  //
106  virtual void PaintSingleObject(TVirtualGLPainter *) = 0;
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:
119  TGLManager(const TGLManager &);
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,
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
Abstract base class for viewer manipulators, which allow direct in viewer manipulation of a (TGlPhysi...
Definition: TGLManip.h:28
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:25
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:320
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
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:422
Abstract 3D shapes viewer.
Encapsulation of format / contents of an OpenGL buffer.
Definition: TGLFormat.h:35
EFormatOptions
Definition: TVirtualGL.h:128
unsigned int UInt_t
Definition: RtypesCore.h:42
const Handle_t kNone
Definition: GuiTypes.h:87
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:47
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:30
virtual ~TVirtualGLManip()
Definition: TVirtualGL.h:61
virtual ~TGLPaintDevice()
Definition: TVirtualGL.h:147
Double_t y[n]
Definition: legend1.C:17
Binding & operator=(OUT(*fun)(void))
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:28