TVirtualGL.h

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TVirtualGL.h 20877 2007-11-19 11:17:07Z rdm $
00002 // Author: Valery Fine(fine@vxcern.cern.ch)   05/03/97
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TVirtualGL
00013 #define ROOT_TVirtualGL
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TVirtualGL                                                           //
00019 //                                                                      //
00020 // The TVirtualGL class is an abstract base class defining the          //
00021 // OpenGL interface protocol. All interactions with OpenGL should be    //
00022 // done via the global pointer gVirtualGL. If the OpenGL library is     //
00023 // available this pointer is pointing to an instance of the TGLKernel   //
00024 // class which provides the actual interface to OpenGL. Using this      //
00025 // scheme of ABC we can use OpenGL in other parts of the framework      //
00026 // without having to link with the OpenGL library in case we don't      //
00027 // use the classes using OpenGL.                                        //
00028 //                                                                      //
00029 //////////////////////////////////////////////////////////////////////////
00030 
00031 #ifndef ROOT_TNamed
00032 #include "TNamed.h"
00033 #endif
00034 #ifndef ROOT_GuiTypes
00035 #include "GuiTypes.h"
00036 #endif
00037 #ifndef ROOT_GLConstants
00038 #include "GLConstants.h"
00039 #endif
00040 
00041 class TVirtualViewer3D;
00042 class TPoints3DABC;
00043 class TGLViewer;
00044 class TGLCamera;
00045 class TGLManip;
00046 class TGLBoundingBox;
00047 class TGLRect;
00048 
00049 //TVirtualGLPainter is the base for histogramm painters.
00050 
00051 class TVirtualGLPainter {
00052 public:
00053    virtual ~TVirtualGLPainter(){}
00054 
00055    virtual void     Paint() = 0;
00056    virtual void     Pan(Int_t px, Int_t py) = 0;
00057    virtual Bool_t   PlotSelected(Int_t px, Int_t py) = 0;
00058    //Used by status bar in a canvas.
00059    virtual char    *GetPlotInfo(Int_t px, Int_t py) = 0;
00060 
00061    ClassDef(TVirtualGLPainter, 0); // Interface for OpenGL painter
00062 };
00063 
00064 //We need this class to implement TGWin32GLManager's SelectManip
00065 class TVirtualGLManip {
00066 public:
00067    virtual ~TVirtualGLManip(){}
00068    virtual Bool_t Select(const TGLCamera & camera, const TGLRect & rect, const TGLBoundingBox & sceneBox) = 0;
00069 
00070    ClassDef(TVirtualGLManip, 0); //Interface for GL manipulator
00071 };
00072 
00073 //This class (and its descendants) in future will replace (?)
00074 //TVirtualGL/TGLKernel/TGWin32GL/TGX11GL
00075 
00076 class TGLManager : public TNamed {
00077 public:
00078    TGLManager();
00079 
00080    //index returned can be used as a result of gVirtualX->InitWindow
00081    virtual Int_t    InitGLWindow(Window_t winID) = 0;
00082    //winInd is the index, returned by InitGLWindow
00083    virtual Int_t    CreateGLContext(Int_t winInd) = 0;
00084 
00085    //[            Off-screen rendering part
00086    //create DIB section/pixmap to read GL buffer into it,
00087    //ctxInd is the index, returned by CreateGLContext
00088    virtual Bool_t   AttachOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) = 0;
00089    virtual Bool_t   ResizeOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h) = 0;
00090    //analog of gVirtualX->SelectWindow(fPixmapID) => gVirtualGL->SelectOffScreenDevice(fPixmapID)
00091    virtual void     SelectOffScreenDevice(Int_t ctxInd) = 0;
00092    //Index of DIB/pixmap, valid for gVirtualX
00093    virtual Int_t    GetVirtualXInd(Int_t ctxInd) = 0;
00094    //copy pixmap into window directly
00095    virtual void     MarkForDirectCopy(Int_t ctxInd, Bool_t) = 0;
00096    //Off-screen device holds sizes for glViewport
00097    virtual void     ExtractViewport(Int_t ctxInd, Int_t *vp) = 0;
00098    //Read GL buffer into off-screen device
00099    virtual void     ReadGLBuffer(Int_t ctxInd) = 0;
00100    //]
00101 
00102    //Make the gl context current
00103    virtual Bool_t   MakeCurrent(Int_t ctxInd) = 0;
00104    //Swap buffers or copies DIB/pixmap (via BitBlt/XCopyArea)
00105    virtual void     Flush(Int_t ctxInd) = 0;
00106    //GL context and off-screen device deletion
00107    virtual void     DeleteGLContext(Int_t ctxInd) = 0;
00108 
00109    //functions to switch between threads in win32
00110    virtual Bool_t   SelectManip(TVirtualGLManip *manip, const TGLCamera *camera, const TGLRect *rect, const TGLBoundingBox *sceneBox) = 0;
00111    //
00112    virtual void     PaintSingleObject(TVirtualGLPainter *) = 0;
00113    virtual void     PanObject(TVirtualGLPainter *o, Int_t x, Int_t y) = 0;
00114    //EPS/PDF output
00115    virtual void     PrintViewer(TVirtualViewer3D *vv) = 0;
00116 
00117    virtual Bool_t   PlotSelected(TVirtualGLPainter *plot, Int_t px, Int_t py) = 0;
00118    virtual char    *GetPlotInfo(TVirtualGLPainter *plot, Int_t px, Int_t py) = 0;
00119 
00120    virtual Bool_t   HighColorFormat(Int_t ctxInd) = 0;
00121 
00122    static TGLManager *&Instance();
00123 
00124 private:
00125    TGLManager(const TGLManager &);
00126    TGLManager &operator = (const TGLManager &);
00127 
00128    ClassDef(TGLManager, 0)// Interface for OpenGL manager
00129 };
00130 
00131 class TGLContext;
00132 class TGLFormat;
00133 
00134 class TGLPaintDevice {
00135    friend class TGLContext;
00136 public:
00137    virtual ~TGLPaintDevice(){}
00138    virtual Bool_t MakeCurrent() = 0;
00139    virtual void SwapBuffers() = 0;
00140    virtual const TGLFormat *GetPixelFormat()const = 0;
00141    virtual const TGLContext *GetContext()const = 0;
00142    virtual void ExtractViewport(Int_t *vp)const = 0;
00143 
00144 private:
00145    virtual void AddContext(TGLContext *ctx) = 0;
00146    virtual void RemoveContext(TGLContext *ctx) = 0;
00147 
00148    ClassDef(TGLPaintDevice, 0) // Base class for GL widgets and GL off-screen rendering
00149 };
00150 
00151 #ifndef __CINT__
00152 #define gGLManager (TGLManager::Instance())
00153 R__EXTERN TGLManager *(*gPtr2GLManager)();
00154 #endif
00155 
00156 #endif

Generated on Tue Jul 5 14:10:33 2011 for ROOT_528-00b_version by  doxygen 1.5.1