Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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=nullptr);
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
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
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassDef(name, id)
Definition Rtypes.h:337
Identifier of a shared GL-context.
Definition TGLContext.h:81
std::list< DLRange_t > DLTrash_t
Definition TGLContext.h:118
virtual ~TGLContextIdentity()
Destructor.
static TGLContextIdentity * GetDefaultIdentity()
Get identity of a default Gl context. Static.
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.
TGLContextIdentity()
Constructor.
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.
void Release(TGLContext *ctx)
Remove context ctx from the list of references.
DLTrash_t::const_iterator DLTrashIt_t
Definition TGLContext.h:119
static TGLContextIdentity * GetCurrent()
Find identitfy of current context. Static.
TGLFontManager * GetFontManager()
Get the free-type font-manager associated with this context-identity.
void AddRef(TGLContext *ctx)
Add context ctx to the list of references.
void RegisterDLNameRangeToWipe(UInt_t base, Int_t size)
Remember dl range for deletion in next MakeCurrent or dtor execution.
Int_t GetRefCnt() const
Definition TGLContext.h:96
static TGLContext * GetDefaultContextAny()
Get the first GL context with the default identity.
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.
void SwapBuffers()
If context is valid (TGLPaintDevice, for which context was created still exists), swap buffers (in ca...
TGLContextIdentity * GetIdentity() const
We can have several shared contexts, and gl-scene wants to know, if some context (defined by its iden...
static Bool_t fgGlewInitDone
Definition TGLContext.h:45
std::unique_ptr< TGLContextPrivate > fPimpl
Definition TGLContext.h:38
virtual ~TGLContext()
TGLContext dtor.
Bool_t MakeCurrent()
If context is valid (TGLPaintDevice, for which context was created still exists), make it current.
void SetContext(TGLWidget *widget, const TGLContext *shareList)
X11 gl-context creation.
static void GlewInit()
Initialize GLEW - static private function.
TGLContext & operator=(const TGLContext &)
Bool_t ClearCurrent()
Reset current context.
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.
TGLContext(const TGLContext &)
Bool_t fFromCtor
Definition TGLContext.h:40
A FreeType GL font manager.
GL window with context.
Definition TGLWidget.h:28