Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/gl:$Id$
0002 // Author:  Timur Pocheptsov, Jun 2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, 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_TGLContext
0013 #define ROOT_TGLContext
0014 
0015 #include <list>
0016 #include <memory>
0017 #include <utility>
0018 
0019 class TGLContextIdentity;
0020 
0021 #include "TGLFormat.h"
0022 #include "Rtypes.h"
0023 
0024 class TGLContextPrivate;
0025 class TGLPaintDevice;
0026 //class TGLPBuffer;
0027 class TGLWidget;
0028 class TGLFontManager;
0029 
0030 class TGLContext
0031 {
0032    friend class TGLContextPrivate;
0033    friend class TGLWidget;
0034    //   friend class TGLPBuffer;
0035 
0036 private:
0037    TGLPaintDevice *fDevice;
0038    std::unique_ptr<TGLContextPrivate> fPimpl;
0039 
0040    Bool_t fFromCtor;//To prohibit user's calls of SetContext.
0041    Bool_t fValid;
0042 
0043    TGLContextIdentity *fIdentity;
0044 
0045    static Bool_t fgGlewInitDone;
0046 
0047 public:
0048    TGLContext(TGLWidget *glWidget, Bool_t shareDefault=kTRUE, const TGLContext *shareList=nullptr);
0049    //   TGLContext(TGLPBuffer *glPbuf, const TGLContext *shareList = 0);
0050 
0051    TGLContextIdentity *GetIdentity()const;
0052 
0053    virtual ~TGLContext();
0054 
0055    Bool_t           MakeCurrent();
0056    Bool_t           ClearCurrent();
0057    void             SwapBuffers();
0058 
0059    //This functions are public _ONLY_ for calls via
0060    //gROOT under win32. Please, DO NOT CALL IT DIRECTLY.
0061    void             SetContext(TGLWidget *widget, const TGLContext *shareList);
0062    // void          SetContextPB(TGLPBuffer *pbuff, const TGLContext *shareList);
0063    void             Release();
0064 
0065    Bool_t           IsValid() const { return fValid; }
0066 
0067    static TGLContext *GetCurrent();
0068    static void GlewInit();
0069 
0070 private:
0071    TGLContext(const TGLContext &);
0072    TGLContext &operator = (const TGLContext &);
0073 
0074    ClassDef(TGLContext, 0); // Control internal gl-context resources.
0075 };
0076 
0077 
0078 //______________________________________________________________________________
0079 
0080 class TGLContextIdentity
0081 {
0082 
0083 protected:
0084    TGLFontManager*      fFontManager;  // FreeType font manager.
0085 
0086 public:
0087    TGLContextIdentity();
0088    virtual ~TGLContextIdentity();
0089 
0090    void AddRef(TGLContext* ctx);
0091    void Release(TGLContext* ctx);
0092 
0093    void AddClientRef()  { ++fClientCnt; }
0094    void ReleaseClient() { --fClientCnt; CheckDestroy(); }
0095 
0096    Int_t GetRefCnt()       const { return fCnt; }
0097    Int_t GetClientRefCnt() const { return fClientCnt; }
0098 
0099    Bool_t IsValid() const { return fCnt > 0; }
0100 
0101    void RegisterDLNameRangeToWipe(UInt_t base, Int_t size);
0102    void DeleteGLResources();
0103 
0104    static TGLContextIdentity *GetCurrent();
0105 
0106    static TGLContextIdentity *GetDefaultIdentity();
0107    static TGLContext         *GetDefaultContextAny();
0108 
0109    TGLFontManager            *GetFontManager();
0110 
0111 private:
0112    Int_t fCnt;
0113    Int_t fClientCnt;
0114 
0115    void CheckDestroy();
0116 
0117    typedef std::pair<UInt_t, Int_t>  DLRange_t;
0118    typedef std::list<DLRange_t>      DLTrash_t;
0119    typedef DLTrash_t::const_iterator DLTrashIt_t;
0120 
0121    typedef std::list<TGLContext*>    CtxList_t;
0122 
0123    DLTrash_t fDLTrash;
0124    CtxList_t fCtxs;
0125 
0126    static TGLContextIdentity * fgDefaultIdentity;
0127 
0128    ClassDef(TGLContextIdentity, 0); // Identity of a shared GL context.
0129 };
0130 
0131 #endif