Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TVirtualGL.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/base:$Id$
0002 // Author: Valery Fine(fine@vxcern.cern.ch)   05/03/97
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TVirtualGL
0013 #define ROOT_TVirtualGL
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TVirtualGL                                                           //
0019 //                                                                      //
0020 // The TVirtualGL class is an abstract base class defining the          //
0021 // OpenGL interface protocol. All interactions with OpenGL should be    //
0022 // done via the global pointer gVirtualGL. If the OpenGL library is     //
0023 // available this pointer is pointing to an instance of the TGLKernel   //
0024 // class which provides the actual interface to OpenGL. Using this      //
0025 // scheme of ABC we can use OpenGL in other parts of the framework      //
0026 // without having to link with the OpenGL library in case we don't      //
0027 // use the classes using OpenGL.                                        //
0028 //                                                                      //
0029 //////////////////////////////////////////////////////////////////////////
0030 
0031 #include "TNamed.h"
0032 #include "GuiTypes.h"
0033 #include "GLConstants.h"
0034 
0035 class TVirtualViewer3D;
0036 class TPoints3DABC;
0037 class TGLViewer;
0038 class TGLCamera;
0039 class TGLManip;
0040 class TGLBoundingBox;
0041 class TGLRect;
0042 
0043 //TVirtualGLPainter is the base for histogramm painters.
0044 
0045 class TVirtualGLPainter {
0046 public:
0047    virtual ~TVirtualGLPainter(){}
0048 
0049    virtual void     Paint() = 0;
0050    virtual void     Pan(Int_t px, Int_t py) = 0;
0051    virtual Bool_t   PlotSelected(Int_t px, Int_t py) = 0;
0052    //Used by status bar in a canvas.
0053    virtual char    *GetPlotInfo(Int_t px, Int_t py) = 0;
0054 
0055    ClassDef(TVirtualGLPainter, 0); // Interface for OpenGL painter
0056 };
0057 
0058 //We need this class to implement TGWin32GLManager's SelectManip
0059 class TVirtualGLManip {
0060 public:
0061    virtual ~TVirtualGLManip(){}
0062    virtual Bool_t Select(const TGLCamera & camera, const TGLRect & rect, const TGLBoundingBox & sceneBox) = 0;
0063 
0064    ClassDef(TVirtualGLManip, 0); //Interface for GL manipulator
0065 };
0066 
0067 //This class (and its descendants) in future will replace (?)
0068 //TVirtualGL/TGLKernel/TGWin32GL/TGX11GL
0069 
0070 class TGLManager : public TNamed {
0071 public:
0072    TGLManager();
0073    TGLManager(const TGLManager &) = delete;
0074    TGLManager &operator = (const TGLManager &) = delete;
0075 
0076    //index returned can be used as a result of gVirtualX->InitWindow
0077    virtual Int_t    InitGLWindow(Window_t winID) = 0;
0078    //winInd is the index, returned by InitGLWindow
0079    virtual Int_t    CreateGLContext(Int_t winInd) = 0;
0080 
0081    //[            Off-screen rendering part
0082    //create DIB section/pixmap to read GL buffer into it,
0083    //ctxInd is the index, returned by CreateGLContext
0084    virtual Bool_t   AttachOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) = 0;
0085    virtual Bool_t   ResizeOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) = 0;
0086    //analog of gVirtualX->SelectWindow(fPixmapID) => gVirtualGL->SelectOffScreenDevice(fPixmapID)
0087    virtual void     SelectOffScreenDevice(Int_t ctxInd) = 0;
0088    //Index of DIB/pixmap, valid for gVirtualX
0089    virtual Int_t    GetVirtualXInd(Int_t ctxInd) = 0;
0090    //copy pixmap into window directly
0091    virtual void     MarkForDirectCopy(Int_t ctxInd, Bool_t) = 0;
0092    //Off-screen device holds sizes for glViewport
0093    virtual void     ExtractViewport(Int_t ctxInd, Int_t *vp) = 0;
0094    //Read GL buffer into off-screen device
0095    virtual void     ReadGLBuffer(Int_t ctxInd) = 0;
0096    //]
0097 
0098    //Make the gl context current
0099    virtual Bool_t   MakeCurrent(Int_t ctxInd) = 0;
0100    //Swap buffers or copies DIB/pixmap (via BitBlt/XCopyArea)
0101    virtual void     Flush(Int_t ctxInd) = 0;
0102    //GL context and off-screen device deletion
0103    virtual void     DeleteGLContext(Int_t ctxInd) = 0;
0104 
0105    //functions to switch between threads in win32
0106    virtual Bool_t   SelectManip(TVirtualGLManip *manip, const TGLCamera *camera, const TGLRect *rect, const TGLBoundingBox *sceneBox) = 0;
0107    //
0108    virtual void     PaintSingleObject(TVirtualGLPainter *) = 0;
0109    virtual void     PanObject(TVirtualGLPainter *o, Int_t x, Int_t y) = 0;
0110    //EPS/PDF output
0111    virtual void     PrintViewer(TVirtualViewer3D *vv) = 0;
0112 
0113    virtual Bool_t   PlotSelected(TVirtualGLPainter *plot, Int_t px, Int_t py) = 0;
0114    virtual char    *GetPlotInfo(TVirtualGLPainter *plot, Int_t px, Int_t py) = 0;
0115 
0116    virtual Bool_t   HighColorFormat(Int_t ctxInd) = 0;
0117 
0118    static TGLManager *&Instance();
0119 
0120    ClassDefOverride(TGLManager, 0)// Interface for OpenGL manager
0121 };
0122 
0123 namespace Rgl {
0124 
0125 //I would prefer to use C++11's strong typed enums insted, but ...
0126 enum EFormatOptions
0127 {
0128    kNone         = 0,
0129    kDoubleBuffer = 1,
0130    kDepth        = 2,
0131    kAccum        = 4,
0132    kStencil      = 8,
0133    kStereo       = 16,
0134    kMultiSample  = 32
0135 };
0136 
0137 }
0138 
0139 class TGLContext;
0140 class TGLFormat;
0141 
0142 class TGLPaintDevice {
0143    friend class TGLContext;
0144 public:
0145    virtual ~TGLPaintDevice(){}
0146    virtual Bool_t MakeCurrent() = 0;
0147    virtual void SwapBuffers() = 0;
0148    virtual const TGLFormat *GetPixelFormat()const = 0;
0149    virtual const TGLContext *GetContext()const = 0;
0150    virtual void ExtractViewport(Int_t *vp)const = 0;
0151 
0152 private:
0153    virtual void AddContext(TGLContext *ctx) = 0;
0154    virtual void RemoveContext(TGLContext *ctx) = 0;
0155 
0156    ClassDef(TGLPaintDevice, 0) // Base class for GL widgets and GL off-screen rendering
0157 };
0158 
0159 #define gGLManager (TGLManager::Instance())
0160 R__EXTERN TGLManager *(*gPtr2GLManager)();
0161 
0162 #endif