ROOT logo
// @(#)root/base:$Id: TVirtualGL.h 20877 2007-11-19 11:17:07Z rdm $
// Author: Valery Fine(fine@vxcern.cern.ch)   05/03/97

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TVirtualGL
#define ROOT_TVirtualGL


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TVirtualGL                                                           //
//                                                                      //
// The TVirtualGL class is an abstract base class defining the          //
// OpenGL interface protocol. All interactions with OpenGL should be    //
// done via the global pointer gVirtualGL. If the OpenGL library is     //
// available this pointer is pointing to an instance of the TGLKernel   //
// class which provides the actual interface to OpenGL. Using this      //
// scheme of ABC we can use OpenGL in other parts of the framework      //
// without having to link with the OpenGL library in case we don't      //
// use the classes using OpenGL.                                        //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
#ifndef ROOT_GuiTypes
#include "GuiTypes.h"
#endif
#ifndef ROOT_GLConstants
#include "GLConstants.h"
#endif

class TVirtualViewer3D;
class TPoints3DABC;
class TGLViewer;
class TGLCamera;
class TGLManip;
class TGLBoundingBox;
class TGLRect;

//TVirtualGLPainter is the base for histogramm painters.

class TVirtualGLPainter {
public:
   virtual ~TVirtualGLPainter(){}

   virtual void     Paint() = 0;
   virtual void     Pan(Int_t px, Int_t py) = 0;
   virtual Bool_t   PlotSelected(Int_t px, Int_t py) = 0;
   //Used by status bar in a canvas.
   virtual char    *GetPlotInfo(Int_t px, Int_t py) = 0;

   ClassDef(TVirtualGLPainter, 0); // Interface for OpenGL painter
};

//We need this class to implement TGWin32GLManager's SelectManip
class TVirtualGLManip {
public:
   virtual ~TVirtualGLManip(){}
   virtual Bool_t Select(const TGLCamera & camera, const TGLRect & rect, const TGLBoundingBox & sceneBox) = 0;

   ClassDef(TVirtualGLManip, 0); //Interface for GL manipulator
};

//This class (and its descendants) in future will replace (?)
//TVirtualGL/TGLKernel/TGWin32GL/TGX11GL

class TGLManager : public TNamed {
public:
   TGLManager();

   //index returned can be used as a result of gVirtualX->InitWindow
   virtual Int_t    InitGLWindow(Window_t winID) = 0;
   //winInd is the index, returned by InitGLWindow
   virtual Int_t    CreateGLContext(Int_t winInd) = 0;

   //[            Off-screen rendering part
   //create DIB section/pixmap to read GL buffer into it,
   //ctxInd is the index, returned by CreateGLContext
   virtual Bool_t   AttachOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) = 0;
   virtual Bool_t   ResizeOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) = 0;
   //analog of gVirtualX->SelectWindow(fPixmapID) => gVirtualGL->SelectOffScreenDevice(fPixmapID)
   virtual void     SelectOffScreenDevice(Int_t ctxInd) = 0;
   //Index of DIB/pixmap, valid for gVirtualX
   virtual Int_t    GetVirtualXInd(Int_t ctxInd) = 0;
   //copy pixmap into window directly
   virtual void     MarkForDirectCopy(Int_t ctxInd, Bool_t) = 0;
   //Off-screen device holds sizes for glViewport
   virtual void     ExtractViewport(Int_t ctxInd, Int_t *vp) = 0;
   //Read GL buffer into off-screen device
   virtual void     ReadGLBuffer(Int_t ctxInd) = 0;
   //]

   //Make the gl context current
   virtual Bool_t   MakeCurrent(Int_t ctxInd) = 0;
   //Swap buffers or copies DIB/pixmap (via BitBlt/XCopyArea)
   virtual void     Flush(Int_t ctxInd) = 0;
   //GL context and off-screen device deletion
   virtual void     DeleteGLContext(Int_t ctxInd) = 0;

   //functions to switch between threads in win32
   virtual Bool_t   SelectManip(TVirtualGLManip *manip, const TGLCamera *camera, const TGLRect *rect, const TGLBoundingBox *sceneBox) = 0;
   //
   virtual void     PaintSingleObject(TVirtualGLPainter *) = 0;
   virtual void     PanObject(TVirtualGLPainter *o, Int_t x, Int_t y) = 0;
   //EPS/PDF output
   virtual void     PrintViewer(TVirtualViewer3D *vv) = 0;

   virtual Bool_t   PlotSelected(TVirtualGLPainter *plot, Int_t px, Int_t py) = 0;
   virtual char    *GetPlotInfo(TVirtualGLPainter *plot, Int_t px, Int_t py) = 0;

   virtual Bool_t   HighColorFormat(Int_t ctxInd) = 0;

   static TGLManager *&Instance();

private:
   TGLManager(const TGLManager &);
   TGLManager &operator = (const TGLManager &);

   ClassDef(TGLManager, 0)// Interface for OpenGL manager
};

class TGLContext;
class TGLFormat;

class TGLPaintDevice {
   friend class TGLContext;
public:
   virtual ~TGLPaintDevice(){}
   virtual Bool_t MakeCurrent() = 0;
   virtual void SwapBuffers() = 0;
   virtual const TGLFormat *GetPixelFormat()const = 0;
   virtual const TGLContext *GetContext()const = 0;
   virtual void ExtractViewport(Int_t *vp)const = 0;

private:
   virtual void AddContext(TGLContext *ctx) = 0;
   virtual void RemoveContext(TGLContext *ctx) = 0;

   ClassDef(TGLPaintDevice, 0) // Base class for GL widgets and GL off-screen rendering
};

#ifndef __CINT__
#define gGLManager (TGLManager::Instance())
R__EXTERN TGLManager *(*gPtr2GLManager)();
#endif

#endif
 TVirtualGL.h:1
 TVirtualGL.h:2
 TVirtualGL.h:3
 TVirtualGL.h:4
 TVirtualGL.h:5
 TVirtualGL.h:6
 TVirtualGL.h:7
 TVirtualGL.h:8
 TVirtualGL.h:9
 TVirtualGL.h:10
 TVirtualGL.h:11
 TVirtualGL.h:12
 TVirtualGL.h:13
 TVirtualGL.h:14
 TVirtualGL.h:15
 TVirtualGL.h:16
 TVirtualGL.h:17
 TVirtualGL.h:18
 TVirtualGL.h:19
 TVirtualGL.h:20
 TVirtualGL.h:21
 TVirtualGL.h:22
 TVirtualGL.h:23
 TVirtualGL.h:24
 TVirtualGL.h:25
 TVirtualGL.h:26
 TVirtualGL.h:27
 TVirtualGL.h:28
 TVirtualGL.h:29
 TVirtualGL.h:30
 TVirtualGL.h:31
 TVirtualGL.h:32
 TVirtualGL.h:33
 TVirtualGL.h:34
 TVirtualGL.h:35
 TVirtualGL.h:36
 TVirtualGL.h:37
 TVirtualGL.h:38
 TVirtualGL.h:39
 TVirtualGL.h:40
 TVirtualGL.h:41
 TVirtualGL.h:42
 TVirtualGL.h:43
 TVirtualGL.h:44
 TVirtualGL.h:45
 TVirtualGL.h:46
 TVirtualGL.h:47
 TVirtualGL.h:48
 TVirtualGL.h:49
 TVirtualGL.h:50
 TVirtualGL.h:51
 TVirtualGL.h:52
 TVirtualGL.h:53
 TVirtualGL.h:54
 TVirtualGL.h:55
 TVirtualGL.h:56
 TVirtualGL.h:57
 TVirtualGL.h:58
 TVirtualGL.h:59
 TVirtualGL.h:60
 TVirtualGL.h:61
 TVirtualGL.h:62
 TVirtualGL.h:63
 TVirtualGL.h:64
 TVirtualGL.h:65
 TVirtualGL.h:66
 TVirtualGL.h:67
 TVirtualGL.h:68
 TVirtualGL.h:69
 TVirtualGL.h:70
 TVirtualGL.h:71
 TVirtualGL.h:72
 TVirtualGL.h:73
 TVirtualGL.h:74
 TVirtualGL.h:75
 TVirtualGL.h:76
 TVirtualGL.h:77
 TVirtualGL.h:78
 TVirtualGL.h:79
 TVirtualGL.h:80
 TVirtualGL.h:81
 TVirtualGL.h:82
 TVirtualGL.h:83
 TVirtualGL.h:84
 TVirtualGL.h:85
 TVirtualGL.h:86
 TVirtualGL.h:87
 TVirtualGL.h:88
 TVirtualGL.h:89
 TVirtualGL.h:90
 TVirtualGL.h:91
 TVirtualGL.h:92
 TVirtualGL.h:93
 TVirtualGL.h:94
 TVirtualGL.h:95
 TVirtualGL.h:96
 TVirtualGL.h:97
 TVirtualGL.h:98
 TVirtualGL.h:99
 TVirtualGL.h:100
 TVirtualGL.h:101
 TVirtualGL.h:102
 TVirtualGL.h:103
 TVirtualGL.h:104
 TVirtualGL.h:105
 TVirtualGL.h:106
 TVirtualGL.h:107
 TVirtualGL.h:108
 TVirtualGL.h:109
 TVirtualGL.h:110
 TVirtualGL.h:111
 TVirtualGL.h:112
 TVirtualGL.h:113
 TVirtualGL.h:114
 TVirtualGL.h:115
 TVirtualGL.h:116
 TVirtualGL.h:117
 TVirtualGL.h:118
 TVirtualGL.h:119
 TVirtualGL.h:120
 TVirtualGL.h:121
 TVirtualGL.h:122
 TVirtualGL.h:123
 TVirtualGL.h:124
 TVirtualGL.h:125
 TVirtualGL.h:126
 TVirtualGL.h:127
 TVirtualGL.h:128
 TVirtualGL.h:129
 TVirtualGL.h:130
 TVirtualGL.h:131
 TVirtualGL.h:132
 TVirtualGL.h:133
 TVirtualGL.h:134
 TVirtualGL.h:135
 TVirtualGL.h:136
 TVirtualGL.h:137
 TVirtualGL.h:138
 TVirtualGL.h:139
 TVirtualGL.h:140
 TVirtualGL.h:141
 TVirtualGL.h:142
 TVirtualGL.h:143
 TVirtualGL.h:144
 TVirtualGL.h:145
 TVirtualGL.h:146
 TVirtualGL.h:147
 TVirtualGL.h:148
 TVirtualGL.h:149
 TVirtualGL.h:150
 TVirtualGL.h:151
 TVirtualGL.h:152
 TVirtualGL.h:153
 TVirtualGL.h:154
 TVirtualGL.h:155
 TVirtualGL.h:156