Logo ROOT  
Reference Guide
TGLContext.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Timur Pocheptsov, Jun 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGLContext
13 #define ROOT_TGLContext
14 
15 #include <list>
16 #include <memory>
17 #include <utility>
18 
19 class TGLContextIdentity;
20 
21 #include "TGLFormat.h"
22 #include "Rtypes.h"
23 
24 class TGLContextPrivate;
25 class TGLPaintDevice;
26 //class TGLPBuffer;
27 class TGLWidget;
28 class TGLFontManager;
29 
31 {
32  friend class TGLContextPrivate;
33  friend class TGLWidget;
34  // friend class TGLPBuffer;
35 
36 private:
38  std::unique_ptr<TGLContextPrivate> fPimpl;
39 
40  Bool_t fFromCtor;//To prohibit user's calls of SetContext.
42 
44 
46 
47 public:
48  TGLContext(TGLWidget *glWidget, Bool_t shareDefault=kTRUE, const TGLContext *shareList=0);
49  // TGLContext(TGLPBuffer *glPbuf, const TGLContext *shareList = 0);
50 
52 
53  virtual ~TGLContext();
54 
57  void SwapBuffers();
58 
59  //This functions are public _ONLY_ for calls via
60  //gROOT under win32. Please, DO NOT CALL IT DIRECTLY.
61  void SetContext(TGLWidget *widget, const TGLContext *shareList);
62  // void SetContextPB(TGLPBuffer *pbuff, const TGLContext *shareList);
63  void Release();
64 
65  Bool_t IsValid() const { return fValid; }
66 
67  static TGLContext *GetCurrent();
68  static void GlewInit();
69 
70 private:
73 
74  ClassDef(TGLContext, 0); // Control internal gl-context resources.
75 };
76 
77 
78 //______________________________________________________________________________
79 
81 {
82 
83 protected:
84  TGLFontManager* fFontManager; // FreeType font manager.
85 
86 public:
88  virtual ~TGLContextIdentity();
89 
90  void AddRef(TGLContext* ctx);
91  void Release(TGLContext* ctx);
92 
93  void AddClientRef() { ++fClientCnt; }
95 
96  Int_t GetRefCnt() const { return fCnt; }
97  Int_t GetClientRefCnt() const { return fClientCnt; }
98 
99  Bool_t IsValid() const { return fCnt > 0; }
100 
101  void RegisterDLNameRangeToWipe(UInt_t base, Int_t size);
102  void DeleteGLResources();
103 
104  static TGLContextIdentity *GetCurrent();
105 
108 
110 
111 private:
114 
115  void CheckDestroy();
116 
117  typedef std::pair<UInt_t, Int_t> DLRange_t;
118  typedef std::list<DLRange_t> DLTrash_t;
119  typedef DLTrash_t::const_iterator DLTrashIt_t;
120 
121  typedef std::list<TGLContext*> CtxList_t;
122 
125 
127 
128  ClassDef(TGLContextIdentity, 0); // Identity of a shared GL context.
129 };
130 
131 #endif
TGLContext::GetCurrent
static TGLContext * GetCurrent()
Ask TGLContextPrivate to lookup context in its internal map.
Definition: TGLContext.cxx:451
TGLFontManager
A FreeType GL font manager.
Definition: TGLFontManager.h:120
TGLContext::fValid
Bool_t fValid
Definition: TGLContext.h:41
TGLContextIdentity::fClientCnt
Int_t fClientCnt
Definition: TGLContext.h:113
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGLContext::IsValid
Bool_t IsValid() const
Definition: TGLContext.h:65
TGLContextIdentity::GetFontManager
TGLFontManager * GetFontManager()
Get the free-type font-manager associated with this context-identity.
Definition: TGLContext.cxx:568
TGLContextIdentity::GetClientRefCnt
Int_t GetClientRefCnt() const
Definition: TGLContext.h:97
TGLContext::MakeCurrent
Bool_t MakeCurrent()
If context is valid (TGLPaintDevice, for which context was created still exists), make it current.
Definition: TGLContext.cxx:362
TGLContextIdentity::GetDefaultIdentity
static TGLContextIdentity * GetDefaultIdentity()
Get identity of a default Gl context. Static.
Definition: TGLContext.cxx:547
TGLContext::operator=
TGLContext & operator=(const TGLContext &)
TGLContextIdentity::AddRef
void AddRef(TGLContext *ctx)
Add context ctx to the list of references.
Definition: TGLContext.cxx:487
TGLContext::fIdentity
TGLContextIdentity * fIdentity
Definition: TGLContext.h:43
TGLContextIdentity::fCnt
Int_t fCnt
Definition: TGLContext.h:112
TGLContext::GetIdentity
TGLContextIdentity * GetIdentity() const
We can have several shared contexts, and gl-scene wants to know, if some context (defined by its iden...
Definition: TGLContext.cxx:443
Int_t
int Int_t
Definition: RtypesCore.h:45
TGLFormat.h
TGLContextIdentity::TGLContextIdentity
TGLContextIdentity()
Constructor.
Definition: TGLContext.cxx:471
TGLContextIdentity::CheckDestroy
void CheckDestroy()
Private function called when reference count is reduced.
Definition: TGLContext.cxx:577
TGLContextIdentity::fCtxs
CtxList_t fCtxs
Definition: TGLContext.h:124
TGLContextIdentity::DLTrash_t
std::list< DLRange_t > DLTrash_t
Definition: TGLContext.h:118
bool
TGLContextIdentity::DLTrashIt_t
DLTrash_t::const_iterator DLTrashIt_t
Definition: TGLContext.h:119
TGLContext::GlewInit
static void GlewInit()
Initialize GLEW - static private function.
Definition: TGLContext.cxx:85
TGLContextIdentity::CtxList_t
std::list< TGLContext * > CtxList_t
Definition: TGLContext.h:121
TGLContextIdentity::GetDefaultContextAny
static TGLContext * GetDefaultContextAny()
Get the first GL context with the default identity.
Definition: TGLContext.cxx:558
TGLContext::fPimpl
std::unique_ptr< TGLContextPrivate > fPimpl
Definition: TGLContext.h:38
TGLContextIdentity::DLRange_t
std::pair< UInt_t, Int_t > DLRange_t
Definition: TGLContext.h:117
TGLContext
This class encapsulates window-system specific information about a GL-context and alows their proper ...
Definition: TGLContext.h:31
TGLContextIdentity::~TGLContextIdentity
virtual ~TGLContextIdentity()
Destructor.
Definition: TGLContext.cxx:479
TGLContextIdentity::GetCurrent
static TGLContextIdentity * GetCurrent()
Find identitfy of current context. Static.
Definition: TGLContext.cxx:538
TGLContext::SwapBuffers
void SwapBuffers()
If context is valid (TGLPaintDevice, for which context was created still exists), swap buffers (in ca...
Definition: TGLContext.cxx:395
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TGLPaintDevice
Definition: TVirtualGL.h:144
TGLContextIdentity::AddClientRef
void AddClientRef()
Definition: TGLContext.h:93
TGLContextIdentity::GetRefCnt
Int_t GetRefCnt() const
Definition: TGLContext.h:96
TGLContextIdentity::fDLTrash
DLTrash_t fDLTrash
Definition: TGLContext.h:123
TGLContext::fFromCtor
Bool_t fFromCtor
Definition: TGLContext.h:40
TGLContext::Release
void Release()
Make the context invalid and (do thread switch, if needed) free resources.
Definition: TGLContext.cxx:412
TGLContext::TGLContext
TGLContext(const TGLContext &)
TGLContextIdentity::ReleaseClient
void ReleaseClient()
Definition: TGLContext.h:94
TGLContextIdentity::Release
void Release(TGLContext *ctx)
Remove context ctx from the list of references.
Definition: TGLContext.cxx:496
TGLContext::SetContext
void SetContext(TGLWidget *widget, const TGLContext *shareList)
X11 gl-context creation.
Definition: TGLContext.cxx:329
TGLContextIdentity::fgDefaultIdentity
static TGLContextIdentity * fgDefaultIdentity
Definition: TGLContext.h:126
TGLWidget
GL window with context.
Definition: TGLWidget.h:28
TGLContext::ClearCurrent
Bool_t ClearCurrent()
Reset current context.
Definition: TGLContext.cxx:386
TGLContextIdentity::DeleteGLResources
void DeleteGLResources()
Delete GL resources registered for destruction.
Definition: TGLContext.cxx:522
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGLContext::fgGlewInitDone
static Bool_t fgGlewInitDone
Definition: TGLContext.h:45
TGLContext::TGLContext
TGLContext(TGLWidget *glWidget, Bool_t shareDefault=kTRUE, const TGLContext *shareList=0)
TGLContext ctor "from" TGLWidget.
Definition: TGLContext.cxx:51
TGLContextPrivate
Definition: TGLContextPrivate.h:67
TGLContext::~TGLContext
virtual ~TGLContext()
TGLContext dtor.
Definition: TGLContext.cxx:428
TGLContextIdentity::fFontManager
TGLFontManager * fFontManager
Definition: TGLContext.h:84
TGLContext::fDevice
TGLPaintDevice * fDevice
Definition: TGLContext.h:37
Rtypes.h
TGLContextIdentity::IsValid
Bool_t IsValid() const
Definition: TGLContext.h:99
TGLContextIdentity::RegisterDLNameRangeToWipe
void RegisterDLNameRangeToWipe(UInt_t base, Int_t size)
Remember dl range for deletion in next MakeCurrent or dtor execution.
Definition: TGLContext.cxx:514
TGLContextIdentity
Identifier of a shared GL-context.
Definition: TGLContext.h:81
int