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
20
21#include "TGLFormat.h"
22#include "Rtypes.h"
23
25class TGLPaintDevice;
26//class TGLPBuffer;
27class TGLWidget;
28class TGLFontManager;
29
31{
32 friend class TGLContextPrivate;
33 friend class TGLWidget;
34 // friend class TGLPBuffer;
35
36private:
38 std::unique_ptr<TGLContextPrivate> fPimpl;
39
40 Bool_t fFromCtor;//To prohibit user's calls of SetContext.
42
44
46
47public:
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
70private:
73
74 ClassDef(TGLContext, 0); // Control internal gl-context resources.
75};
76
77
78//______________________________________________________________________________
79
81{
82
83protected:
84 TGLFontManager* fFontManager; // FreeType font manager.
85
86public:
88 virtual ~TGLContextIdentity();
89
90 void AddRef(TGLContext* ctx);
91 void Release(TGLContext* ctx);
92
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
105
108
110
111private:
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
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
Identifier of a shared GL-context.
Definition: TGLContext.h:81
std::list< DLRange_t > DLTrash_t
Definition: TGLContext.h:118
virtual ~TGLContextIdentity()
Destructor.
Definition: TGLContext.cxx:479
static TGLContextIdentity * GetDefaultIdentity()
Get identity of a default Gl context. Static.
Definition: TGLContext.cxx:547
Bool_t IsValid() const
Definition: TGLContext.h:99
std::list< TGLContext * > CtxList_t
Definition: TGLContext.h:121
void CheckDestroy()
Private function called when reference count is reduced.
Definition: TGLContext.cxx:577
TGLContextIdentity()
Constructor.
Definition: TGLContext.cxx:471
std::pair< UInt_t, Int_t > DLRange_t
Definition: TGLContext.h:117
TGLFontManager * fFontManager
Definition: TGLContext.h:84
Int_t GetClientRefCnt() const
Definition: TGLContext.h:97
static TGLContextIdentity * fgDefaultIdentity
Definition: TGLContext.h:126
void DeleteGLResources()
Delete GL resources registered for destruction.
Definition: TGLContext.cxx:522
void Release(TGLContext *ctx)
Remove context ctx from the list of references.
Definition: TGLContext.cxx:496
DLTrash_t::const_iterator DLTrashIt_t
Definition: TGLContext.h:119
static TGLContextIdentity * GetCurrent()
Find identitfy of current context. Static.
Definition: TGLContext.cxx:538
TGLFontManager * GetFontManager()
Get the free-type font-manager associated with this context-identity.
Definition: TGLContext.cxx:568
void AddRef(TGLContext *ctx)
Add context ctx to the list of references.
Definition: TGLContext.cxx:487
void RegisterDLNameRangeToWipe(UInt_t base, Int_t size)
Remember dl range for deletion in next MakeCurrent or dtor execution.
Definition: TGLContext.cxx:514
void ReleaseClient()
Definition: TGLContext.h:94
Int_t GetRefCnt() const
Definition: TGLContext.h:96
static TGLContext * GetDefaultContextAny()
Get the first GL context with the default identity.
Definition: TGLContext.cxx:558
DLTrash_t fDLTrash
Definition: TGLContext.h:123
This class encapsulates window-system specific information about a GL-context and alows their proper ...
Definition: TGLContext.h:31
Bool_t fValid
Definition: TGLContext.h:41
void Release()
Make the context invalid and (do thread switch, if needed) free resources.
Definition: TGLContext.cxx:412
void SwapBuffers()
If context is valid (TGLPaintDevice, for which context was created still exists), swap buffers (in ca...
Definition: TGLContext.cxx:395
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
static Bool_t fgGlewInitDone
Definition: TGLContext.h:45
std::unique_ptr< TGLContextPrivate > fPimpl
Definition: TGLContext.h:38
virtual ~TGLContext()
TGLContext dtor.
Definition: TGLContext.cxx:428
Bool_t MakeCurrent()
If context is valid (TGLPaintDevice, for which context was created still exists), make it current.
Definition: TGLContext.cxx:362
void SetContext(TGLWidget *widget, const TGLContext *shareList)
X11 gl-context creation.
Definition: TGLContext.cxx:329
static void GlewInit()
Initialize GLEW - static private function.
Definition: TGLContext.cxx:85
TGLContext(TGLWidget *glWidget, Bool_t shareDefault=kTRUE, const TGLContext *shareList=0)
TGLContext ctor "from" TGLWidget.
Definition: TGLContext.cxx:51
TGLContext & operator=(const TGLContext &)
Bool_t ClearCurrent()
Reset current context.
Definition: TGLContext.cxx:386
TGLContextIdentity * fIdentity
Definition: TGLContext.h:43
TGLPaintDevice * fDevice
Definition: TGLContext.h:37
Bool_t IsValid() const
Definition: TGLContext.h:65
static TGLContext * GetCurrent()
Ask TGLContextPrivate to lookup context in its internal map.
Definition: TGLContext.cxx:451
TGLContext(const TGLContext &)
Bool_t fFromCtor
Definition: TGLContext.h:40
A FreeType GL font manager.
GL window with context.
Definition: TGLWidget.h:28