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
0002
0003
0004
0005
0006
0007
0008
0009
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
0027 class TGLWidget;
0028 class TGLFontManager;
0029
0030 class TGLContext
0031 {
0032 friend class TGLContextPrivate;
0033 friend class TGLWidget;
0034
0035
0036 private:
0037 TGLPaintDevice *fDevice;
0038 std::unique_ptr<TGLContextPrivate> fPimpl;
0039
0040 Bool_t fFromCtor;
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
0050
0051 TGLContextIdentity *GetIdentity()const;
0052
0053 virtual ~TGLContext();
0054
0055 Bool_t MakeCurrent();
0056 Bool_t ClearCurrent();
0057 void SwapBuffers();
0058
0059
0060
0061 void SetContext(TGLWidget *widget, const TGLContext *shareList);
0062
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);
0075 };
0076
0077
0078
0079
0080 class TGLContextIdentity
0081 {
0082
0083 protected:
0084 TGLFontManager* fFontManager;
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);
0129 };
0130
0131 #endif