// @(#)root/gl:$Id$
// Author:  Timur Pocheptsov, Jun 2007

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include <stdexcept>
#include <algorithm>
#include <memory>

#include "TVirtualX.h"
#include "GuiTypes.h"
#include "TString.h"
#include "TError.h"

#include "TROOT.h"
#include "TVirtualMutex.h"

#include "TGLContextPrivate.h"
#include "RConfigure.h"
#include "TGLIncludes.h"
#include "TGLContext.h"
#include "TGLWidget.h"
#include "TGLFormat.h"
#include "TGLUtil.h"

#include "TGLFontManager.h"

//______________________________________________________________________________
//
// This class encapsulates window-system specific information about a
// GL-context and alows their proper management in ROOT.

ClassImp(TGLContext);

Bool_t TGLContext::fgGlewInitDone = kFALSE;

//______________________________________________________________________________
TGLContext::TGLContext(TGLWidget *wid, Bool_t shareDefault,
                       const TGLContext *shareList)
   : fDevice(wid),
     fPimpl(0),
     fFromCtor(kTRUE),
     fValid(kFALSE),
     fIdentity(0)
{
   // TGLContext ctor "from" TGLWidget.
   // Is shareDefault is true, the shareList is set from default
   // context-identity. Otherwise the given shareList is used (can be
   // null).
   // Makes thread switching.

   if (shareDefault)
      shareList = TGLContextIdentity::GetDefaultContextAny();

   if (!gVirtualX->IsCmdThread()) {
      gROOT->ProcessLineFast(Form("((TGLContext *)0x%lx)->SetContext((TGLWidget *)0x%lx, (TGLContext *)0x%lx)",
                                  (ULong_t)this, (ULong_t)wid, (ULong_t)shareList));
   } else {

      R__LOCKGUARD2(gROOTMutex);

      SetContext(wid, shareList);
   }

   if (shareDefault)
      fIdentity = TGLContextIdentity::GetDefaultIdentity();
   else
      fIdentity = shareList ? shareList->GetIdentity() : new TGLContextIdentity;

   fIdentity->AddRef(this);

   fFromCtor = kFALSE;
}

//______________________________________________________________________________
void TGLContext::GlewInit()
{
   // Initialize GLEW - static private function.
   // Called immediately after creation of the first GL context.

   if (!fgGlewInitDone)
   {
      GLenum status = glewInit();
      if (status != GLEW_OK)
         Warning("TGLContext::GlewInit", "GLEW initalization failed.");
      else if (gDebug > 0)
         Info("TGLContext::GlewInit", "GLEW initalization successful.");
      fgGlewInitDone = kTRUE;
   }
}

//==============================================================================
#ifdef WIN32
//==============================================================================

namespace {

   struct LayoutCompatible_t {
      void          *fDummy0;
      void          *fDummy1;
      HWND          *fPHwnd;
      unsigned char  fDummy2;
      unsigned       fDummy3;
      unsigned short fDummy4;
      unsigned short fDummy5;
      void          *fDummy6;
      unsigned       fDummy7:2;
   };

}

//______________________________________________________________________________
void TGLContext::SetContext(TGLWidget *widget, const TGLContext *shareList)
{
   //WIN32 gl-context creation. Defined as a member-function (this code removed from ctor)
   //to make WIN32/X11 separation cleaner.
   //This function is public only for calls via gROOT and called from ctor.
   if (!fFromCtor) {
      Error("TGLContext::SetContext", "SetContext must be called only from ctor");
      return;
   }

   std::auto_ptr<TGLContextPrivate> safe_ptr(fPimpl = new TGLContextPrivate);
   LayoutCompatible_t *trick =
      reinterpret_cast<LayoutCompatible_t *>(widget->GetId());
   HWND hWND = *trick->fPHwnd;
   HDC  hDC  = GetWindowDC(hWND);

   if (!hDC) {
      Error("TGLContext::SetContext", "GetWindowDC failed");
      throw std::runtime_error("GetWindowDC failed");
   }

   const Rgl::TGuardBase &dcGuard = Rgl::make_guard(ReleaseDC, hWND, hDC);
   if (HGLRC glContext = wglCreateContext(hDC)) {
      if (shareList && !wglShareLists(shareList->fPimpl->fGLContext, glContext)) {
         wglDeleteContext(glContext);
         Error("TGLContext::SetContext", "Context sharing failed!");
         throw std::runtime_error("Context sharing failed");
      }
      fPimpl->fHWND = hWND;
      fPimpl->fHDC = hDC;
      fPimpl->fGLContext = glContext;
   } else {
      Error("TGLContext::SetContext", "wglCreateContext failed");
      throw std::runtime_error("wglCreateContext failed");
   }

   //Register context for "parent" gl-device.
   fValid = kTRUE;
   fDevice->AddContext(this);
   TGLContextPrivate::RegisterContext(this);

   dcGuard.Stop();
   safe_ptr.release();
}

//______________________________________________________________________________
Bool_t TGLContext::MakeCurrent()
{
   //If context is valid (TGLPaintDevice, for which context was created still exists),
   //make it current.
   if (!fValid) {
      Error("TGLContext::MakeCurrent", "This context is invalid.");
      return kFALSE;
   }

   if (!gVirtualX->IsCmdThread())
      return Bool_t(gROOT->ProcessLineFast(Form("((TGLContext *)0x%lx)->MakeCurrent()", this)));
   else {

      R__LOCKGUARD2(gROOTMutex);

      Bool_t rez = wglMakeCurrent(fPimpl->fHDC, fPimpl->fGLContext);
      if (rez) {
         if (!fgGlewInitDone)
            GlewInit();
         fIdentity->DeleteGLResources();
      }
      return rez;
   }
}

//______________________________________________________________________________
Bool_t TGLContext::ClearCurrent()
{
   //Reset current context.
   return wglMakeCurrent(0, 0);
}

//______________________________________________________________________________
void TGLContext::SwapBuffers()
{
   //If context is valid (TGLPaintDevice, for which context was created still exists),
   //swap buffers (in case of P-buffer call glFinish()).
   if (!fValid) {
      Error("TGLContext::SwapBuffers", "This context is invalid.");
      return;
   }

   if (!gVirtualX->IsCmdThread())
      gROOT->ProcessLineFast(Form("((TGLContext *)0x%lx)->SwapBuffers()", this));
   else {

      R__LOCKGUARD2(gROOTMutex);

      if (fPimpl->fHWND)
         wglSwapLayerBuffers(fPimpl->fHDC, WGL_SWAP_MAIN_PLANE);
      else
         glFinish();
   }
}

//______________________________________________________________________________
void TGLContext::Release()
{
   //Make the context invalid and (do thread switch, if needed)
   //free resources.
   if (!gVirtualX->IsCmdThread()) {
      gROOT->ProcessLineFast(Form("((TGLContext *)0x%lx)->Release()", this));
      return;
   }

   R__LOCKGUARD2(gROOTMutex);

   if (fPimpl->fHWND)
      ReleaseDC(fPimpl->fHWND, fPimpl->fHDC);

   TGLContextPrivate::RemoveContext(this);
   wglDeleteContext(fPimpl->fGLContext);
   fValid = kFALSE;
}

#elif defined(R__HAS_COCOA)

//______________________________________________________________________________
void TGLContext::SetContext(TGLWidget *widget, const TGLContext *shareList)
{
   //This function is public only for calls via gROOT and called from ctor.
   if (!fFromCtor) {
      Error("TGLContext::SetContext", "SetContext must be called only from ctor");
      return;
   }

   std::auto_ptr<TGLContextPrivate> safe_ptr(fPimpl = new TGLContextPrivate);

   fPimpl->fGLContext = gVirtualX->CreateOpenGLContext(widget->GetId(), shareList ? shareList->fPimpl->fGLContext : 0);
   fPimpl->fWindowID = widget->GetId();

   fValid = kTRUE;
   fDevice->AddContext(this);
   TGLContextPrivate::RegisterContext(this);

   safe_ptr.release();
}

//______________________________________________________________________________
Bool_t TGLContext::MakeCurrent()
{
   //If context is valid (TGLPaintDevice, for which context was created still exists),
   //make it current.

   if (!fValid) {
      Error("TGLContext::MakeCurrent", "This context is invalid.");
      return kFALSE;
   }

   const Bool_t rez = gVirtualX->MakeOpenGLContextCurrent(fPimpl->fGLContext, fPimpl->fWindowID);
   if (rez) {
      if (!fgGlewInitDone)
         GlewInit();
      fIdentity->DeleteGLResources();

   }

   return rez;
}

//______________________________________________________________________________
Bool_t TGLContext::ClearCurrent()
{
   //Reset current context.
   return kFALSE;
}

//______________________________________________________________________________
void TGLContext::SwapBuffers()
{
   //If context is valid (TGLPaintDevice, for which context was created still exists),
   //swap buffers (in case of P-buffer call glFinish()).
   if (!fValid) {
      Error("TGLContext::SwapBuffers", "This context is invalid.");
      return;
   }

   gVirtualX->FlushOpenGLBuffer(fPimpl->fGLContext);
}

//______________________________________________________________________________
void TGLContext::Release()
{
   //Make the context invalid and free resources.

   TGLContextPrivate::RemoveContext(this);
   gVirtualX->DeleteOpenGLContext(fPimpl->fGLContext);
   fValid = kFALSE;
}

//==============================================================================
#else // X11
//==============================================================================

//______________________________________________________________________________
void TGLContext::SetContext(TGLWidget *widget, const TGLContext *shareList)
{
   //X11 gl-context creation. Defined as a member-function (this code removed from ctor)
   //to make WIN32/X11 separation cleaner.
   //This function is public only for calls via gROOT and called from ctor.

   if (!fFromCtor) {
      Error("TGLContext::SetContext", "SetContext must be called only from ctor");
      return;
   }

   std::auto_ptr<TGLContextPrivate> safe_ptr(fPimpl = new TGLContextPrivate);
   Display *dpy = static_cast<Display *>(widget->GetInnerData().first);
   XVisualInfo *visInfo = static_cast<XVisualInfo *>(widget->GetInnerData().second);

   GLXContext glCtx = shareList ? glXCreateContext(dpy, visInfo, shareList->fPimpl->fGLContext, True)
                                : glXCreateContext(dpy, visInfo, None, True);

   if (!glCtx) {
      Error("TGLContext::SetContext", "glXCreateContext failed!");
      throw std::runtime_error("glXCreateContext failed!");
   }

   fPimpl->fDpy = dpy;
   fPimpl->fVisualInfo = visInfo;
   fPimpl->fGLContext = glCtx;
   fPimpl->fWindowID = widget->GetId();

   fValid = kTRUE;
   fDevice->AddContext(this);
   TGLContextPrivate::RegisterContext(this);

   safe_ptr.release();
}

//______________________________________________________________________________
Bool_t TGLContext::MakeCurrent()
{
   //If context is valid (TGLPaintDevice, for which context was created still exists),
   //make it current.

   if (!fValid) {
      Error("TGLContext::MakeCurrent", "This context is invalid.");
      return kFALSE;
   }

   if (fPimpl->fWindowID != 0) {
      const Bool_t rez = glXMakeCurrent(fPimpl->fDpy, fPimpl->fWindowID,
                                        fPimpl->fGLContext);
      if (rez) {
         if (!fgGlewInitDone)
            GlewInit();
         fIdentity->DeleteGLResources();
      }
      return rez;
   }

   return kFALSE;
}

//______________________________________________________________________________
Bool_t TGLContext::ClearCurrent()
{
   //Reset current context.
   return glXMakeCurrent(fPimpl->fDpy, None, 0);
}

//______________________________________________________________________________
void TGLContext::SwapBuffers()
{
   //If context is valid (TGLPaintDevice, for which context was created still exists),
   //swap buffers (in case of P-buffer call glFinish()).

   if (!fValid) {
      Error("TGLContext::SwapCurrent", "This context is invalid.");
      return;
   }

   if (fPimpl->fWindowID != 0)
      glXSwapBuffers(fPimpl->fDpy, fPimpl->fWindowID);
   else
      glFinish();
}

//______________________________________________________________________________
void TGLContext::Release()
{
   //Make the context invalid and (do thread switch, if needed)
   //free resources.
   TGLContextPrivate::RemoveContext(this);
   glXDestroyContext(fPimpl->fDpy, fPimpl->fGLContext);
   fValid = kFALSE;
}

//==============================================================================
#endif
//==============================================================================

//______________________________________________________________________________
TGLContext::~TGLContext()
{
   //TGLContext dtor. If it's called before TGLPaintDevice's dtor
   //(context is valid) resource will be freed and context
   //un-registered.
   if (fValid) {
      Release();
      fDevice->RemoveContext(this);
   }

   fIdentity->Release(this);

   delete fPimpl;
}

//______________________________________________________________________________
TGLContextIdentity *TGLContext::GetIdentity()const
{
   //We can have several shared contexts,
   //and gl-scene wants to know, if some context
   //(defined by its identity) can be used.
   return fIdentity;
}

//______________________________________________________________________________
TGLContext *TGLContext::GetCurrent()
{
   //Ask TGLContextPrivate to lookup context in its internal map.
   return TGLContextPrivate::GetCurrentContext();
}


//______________________________________________________________________________
//
// Identifier of a shared GL-context.
// Objects shared among GL-contexts include:
// display-list definitions, texture objects and shader programs.

ClassImp(TGLContextIdentity)

TGLContextIdentity* TGLContextIdentity::fgDefaultIdentity = new TGLContextIdentity;

//______________________________________________________________________________
TGLContextIdentity::TGLContextIdentity():
fFontManager(0), fCnt(0), fClientCnt(0)
{
   // Constructor.

}

//______________________________________________________________________________
TGLContextIdentity::~TGLContextIdentity()
{
   // Destructor.

   if (fFontManager) delete fFontManager;
}

//______________________________________________________________________________
void TGLContextIdentity::AddRef(TGLContext* ctx)
{
   //Add context ctx to the list of references.
   ++fCnt;
   fCtxs.push_back(ctx);
}

//______________________________________________________________________________
void TGLContextIdentity::Release(TGLContext* ctx)
{
   //Remove context ctx from the list of references.
   CtxList_t::iterator i = std::find(fCtxs.begin(), fCtxs.end(), ctx);
   if (i != fCtxs.end())
   {
      fCtxs.erase(i);
      --fCnt;
      CheckDestroy();
   }
   else
   {
      Error("TGLContextIdentity::Release", "unregistered context.");
   }
}

//______________________________________________________________________________
void TGLContextIdentity::RegisterDLNameRangeToWipe(UInt_t base, Int_t size)
{
   //Remember dl range for deletion in next MakeCurrent or dtor execution.
   fDLTrash.push_back(DLRange_t(base, size));
}

//______________________________________________________________________________
void TGLContextIdentity::DeleteGLResources()
{
   //Delete GL resources registered for destruction.

   if (!fDLTrash.empty())
   {
      for (DLTrashIt_t it = fDLTrash.begin(), e = fDLTrash.end(); it != e; ++it)
         glDeleteLists(it->first, it->second);
      fDLTrash.clear();
   }

   if (fFontManager)
      fFontManager->ClearFontTrash();
}

//______________________________________________________________________________
TGLContextIdentity* TGLContextIdentity::GetCurrent()
{
   //Find identitfy of current context. Static.
   TGLContext* ctx = TGLContext::GetCurrent();
   return ctx ? ctx->GetIdentity() : 0;
}

//______________________________________________________________________________
TGLContextIdentity* TGLContextIdentity::GetDefaultIdentity()
{
   //Get identity of a default Gl context. Static.
   if (fgDefaultIdentity == 0)
      fgDefaultIdentity = new TGLContextIdentity;
   return fgDefaultIdentity;
}

//______________________________________________________________________________
TGLContext* TGLContextIdentity::GetDefaultContextAny()
{
   //Get the first GL context with the default identity.
   //Can return zero, but that's OK, too. Static.
   if (fgDefaultIdentity == 0 || fgDefaultIdentity->fCtxs.empty())
      return 0;
   return fgDefaultIdentity->fCtxs.front();
}

//______________________________________________________________________________
TGLFontManager* TGLContextIdentity::GetFontManager()
{
   //Get the free-type font-manager associated with this context-identity.
   if(!fFontManager) fFontManager = new TGLFontManager();
   return fFontManager;
}

//______________________________________________________________________________
void TGLContextIdentity::CheckDestroy()
{
   //Private function called when reference count is reduced.
   if (fCnt <= 0 && fClientCnt <= 0)
   {
      if (this == fgDefaultIdentity)
         fgDefaultIdentity = 0;
      delete this;
   }
}
 TGLContext.cxx:1
 TGLContext.cxx:2
 TGLContext.cxx:3
 TGLContext.cxx:4
 TGLContext.cxx:5
 TGLContext.cxx:6
 TGLContext.cxx:7
 TGLContext.cxx:8
 TGLContext.cxx:9
 TGLContext.cxx:10
 TGLContext.cxx:11
 TGLContext.cxx:12
 TGLContext.cxx:13
 TGLContext.cxx:14
 TGLContext.cxx:15
 TGLContext.cxx:16
 TGLContext.cxx:17
 TGLContext.cxx:18
 TGLContext.cxx:19
 TGLContext.cxx:20
 TGLContext.cxx:21
 TGLContext.cxx:22
 TGLContext.cxx:23
 TGLContext.cxx:24
 TGLContext.cxx:25
 TGLContext.cxx:26
 TGLContext.cxx:27
 TGLContext.cxx:28
 TGLContext.cxx:29
 TGLContext.cxx:30
 TGLContext.cxx:31
 TGLContext.cxx:32
 TGLContext.cxx:33
 TGLContext.cxx:34
 TGLContext.cxx:35
 TGLContext.cxx:36
 TGLContext.cxx:37
 TGLContext.cxx:38
 TGLContext.cxx:39
 TGLContext.cxx:40
 TGLContext.cxx:41
 TGLContext.cxx:42
 TGLContext.cxx:43
 TGLContext.cxx:44
 TGLContext.cxx:45
 TGLContext.cxx:46
 TGLContext.cxx:47
 TGLContext.cxx:48
 TGLContext.cxx:49
 TGLContext.cxx:50
 TGLContext.cxx:51
 TGLContext.cxx:52
 TGLContext.cxx:53
 TGLContext.cxx:54
 TGLContext.cxx:55
 TGLContext.cxx:56
 TGLContext.cxx:57
 TGLContext.cxx:58
 TGLContext.cxx:59
 TGLContext.cxx:60
 TGLContext.cxx:61
 TGLContext.cxx:62
 TGLContext.cxx:63
 TGLContext.cxx:64
 TGLContext.cxx:65
 TGLContext.cxx:66
 TGLContext.cxx:67
 TGLContext.cxx:68
 TGLContext.cxx:69
 TGLContext.cxx:70
 TGLContext.cxx:71
 TGLContext.cxx:72
 TGLContext.cxx:73
 TGLContext.cxx:74
 TGLContext.cxx:75
 TGLContext.cxx:76
 TGLContext.cxx:77
 TGLContext.cxx:78
 TGLContext.cxx:79
 TGLContext.cxx:80
 TGLContext.cxx:81
 TGLContext.cxx:82
 TGLContext.cxx:83
 TGLContext.cxx:84
 TGLContext.cxx:85
 TGLContext.cxx:86
 TGLContext.cxx:87
 TGLContext.cxx:88
 TGLContext.cxx:89
 TGLContext.cxx:90
 TGLContext.cxx:91
 TGLContext.cxx:92
 TGLContext.cxx:93
 TGLContext.cxx:94
 TGLContext.cxx:95
 TGLContext.cxx:96
 TGLContext.cxx:97
 TGLContext.cxx:98
 TGLContext.cxx:99
 TGLContext.cxx:100
 TGLContext.cxx:101
 TGLContext.cxx:102
 TGLContext.cxx:103
 TGLContext.cxx:104
 TGLContext.cxx:105
 TGLContext.cxx:106
 TGLContext.cxx:107
 TGLContext.cxx:108
 TGLContext.cxx:109
 TGLContext.cxx:110
 TGLContext.cxx:111
 TGLContext.cxx:112
 TGLContext.cxx:113
 TGLContext.cxx:114
 TGLContext.cxx:115
 TGLContext.cxx:116
 TGLContext.cxx:117
 TGLContext.cxx:118
 TGLContext.cxx:119
 TGLContext.cxx:120
 TGLContext.cxx:121
 TGLContext.cxx:122
 TGLContext.cxx:123
 TGLContext.cxx:124
 TGLContext.cxx:125
 TGLContext.cxx:126
 TGLContext.cxx:127
 TGLContext.cxx:128
 TGLContext.cxx:129
 TGLContext.cxx:130
 TGLContext.cxx:131
 TGLContext.cxx:132
 TGLContext.cxx:133
 TGLContext.cxx:134
 TGLContext.cxx:135
 TGLContext.cxx:136
 TGLContext.cxx:137
 TGLContext.cxx:138
 TGLContext.cxx:139
 TGLContext.cxx:140
 TGLContext.cxx:141
 TGLContext.cxx:142
 TGLContext.cxx:143
 TGLContext.cxx:144
 TGLContext.cxx:145
 TGLContext.cxx:146
 TGLContext.cxx:147
 TGLContext.cxx:148
 TGLContext.cxx:149
 TGLContext.cxx:150
 TGLContext.cxx:151
 TGLContext.cxx:152
 TGLContext.cxx:153
 TGLContext.cxx:154
 TGLContext.cxx:155
 TGLContext.cxx:156
 TGLContext.cxx:157
 TGLContext.cxx:158
 TGLContext.cxx:159
 TGLContext.cxx:160
 TGLContext.cxx:161
 TGLContext.cxx:162
 TGLContext.cxx:163
 TGLContext.cxx:164
 TGLContext.cxx:165
 TGLContext.cxx:166
 TGLContext.cxx:167
 TGLContext.cxx:168
 TGLContext.cxx:169
 TGLContext.cxx:170
 TGLContext.cxx:171
 TGLContext.cxx:172
 TGLContext.cxx:173
 TGLContext.cxx:174
 TGLContext.cxx:175
 TGLContext.cxx:176
 TGLContext.cxx:177
 TGLContext.cxx:178
 TGLContext.cxx:179
 TGLContext.cxx:180
 TGLContext.cxx:181
 TGLContext.cxx:182
 TGLContext.cxx:183
 TGLContext.cxx:184
 TGLContext.cxx:185
 TGLContext.cxx:186
 TGLContext.cxx:187
 TGLContext.cxx:188
 TGLContext.cxx:189
 TGLContext.cxx:190
 TGLContext.cxx:191
 TGLContext.cxx:192
 TGLContext.cxx:193
 TGLContext.cxx:194
 TGLContext.cxx:195
 TGLContext.cxx:196
 TGLContext.cxx:197
 TGLContext.cxx:198
 TGLContext.cxx:199
 TGLContext.cxx:200
 TGLContext.cxx:201
 TGLContext.cxx:202
 TGLContext.cxx:203
 TGLContext.cxx:204
 TGLContext.cxx:205
 TGLContext.cxx:206
 TGLContext.cxx:207
 TGLContext.cxx:208
 TGLContext.cxx:209
 TGLContext.cxx:210
 TGLContext.cxx:211
 TGLContext.cxx:212
 TGLContext.cxx:213
 TGLContext.cxx:214
 TGLContext.cxx:215
 TGLContext.cxx:216
 TGLContext.cxx:217
 TGLContext.cxx:218
 TGLContext.cxx:219
 TGLContext.cxx:220
 TGLContext.cxx:221
 TGLContext.cxx:222
 TGLContext.cxx:223
 TGLContext.cxx:224
 TGLContext.cxx:225
 TGLContext.cxx:226
 TGLContext.cxx:227
 TGLContext.cxx:228
 TGLContext.cxx:229
 TGLContext.cxx:230
 TGLContext.cxx:231
 TGLContext.cxx:232
 TGLContext.cxx:233
 TGLContext.cxx:234
 TGLContext.cxx:235
 TGLContext.cxx:236
 TGLContext.cxx:237
 TGLContext.cxx:238
 TGLContext.cxx:239
 TGLContext.cxx:240
 TGLContext.cxx:241
 TGLContext.cxx:242
 TGLContext.cxx:243
 TGLContext.cxx:244
 TGLContext.cxx:245
 TGLContext.cxx:246
 TGLContext.cxx:247
 TGLContext.cxx:248
 TGLContext.cxx:249
 TGLContext.cxx:250
 TGLContext.cxx:251
 TGLContext.cxx:252
 TGLContext.cxx:253
 TGLContext.cxx:254
 TGLContext.cxx:255
 TGLContext.cxx:256
 TGLContext.cxx:257
 TGLContext.cxx:258
 TGLContext.cxx:259
 TGLContext.cxx:260
 TGLContext.cxx:261
 TGLContext.cxx:262
 TGLContext.cxx:263
 TGLContext.cxx:264
 TGLContext.cxx:265
 TGLContext.cxx:266
 TGLContext.cxx:267
 TGLContext.cxx:268
 TGLContext.cxx:269
 TGLContext.cxx:270
 TGLContext.cxx:271
 TGLContext.cxx:272
 TGLContext.cxx:273
 TGLContext.cxx:274
 TGLContext.cxx:275
 TGLContext.cxx:276
 TGLContext.cxx:277
 TGLContext.cxx:278
 TGLContext.cxx:279
 TGLContext.cxx:280
 TGLContext.cxx:281
 TGLContext.cxx:282
 TGLContext.cxx:283
 TGLContext.cxx:284
 TGLContext.cxx:285
 TGLContext.cxx:286
 TGLContext.cxx:287
 TGLContext.cxx:288
 TGLContext.cxx:289
 TGLContext.cxx:290
 TGLContext.cxx:291
 TGLContext.cxx:292
 TGLContext.cxx:293
 TGLContext.cxx:294
 TGLContext.cxx:295
 TGLContext.cxx:296
 TGLContext.cxx:297
 TGLContext.cxx:298
 TGLContext.cxx:299
 TGLContext.cxx:300
 TGLContext.cxx:301
 TGLContext.cxx:302
 TGLContext.cxx:303
 TGLContext.cxx:304
 TGLContext.cxx:305
 TGLContext.cxx:306
 TGLContext.cxx:307
 TGLContext.cxx:308
 TGLContext.cxx:309
 TGLContext.cxx:310
 TGLContext.cxx:311
 TGLContext.cxx:312
 TGLContext.cxx:313
 TGLContext.cxx:314
 TGLContext.cxx:315
 TGLContext.cxx:316
 TGLContext.cxx:317
 TGLContext.cxx:318
 TGLContext.cxx:319
 TGLContext.cxx:320
 TGLContext.cxx:321
 TGLContext.cxx:322
 TGLContext.cxx:323
 TGLContext.cxx:324
 TGLContext.cxx:325
 TGLContext.cxx:326
 TGLContext.cxx:327
 TGLContext.cxx:328
 TGLContext.cxx:329
 TGLContext.cxx:330
 TGLContext.cxx:331
 TGLContext.cxx:332
 TGLContext.cxx:333
 TGLContext.cxx:334
 TGLContext.cxx:335
 TGLContext.cxx:336
 TGLContext.cxx:337
 TGLContext.cxx:338
 TGLContext.cxx:339
 TGLContext.cxx:340
 TGLContext.cxx:341
 TGLContext.cxx:342
 TGLContext.cxx:343
 TGLContext.cxx:344
 TGLContext.cxx:345
 TGLContext.cxx:346
 TGLContext.cxx:347
 TGLContext.cxx:348
 TGLContext.cxx:349
 TGLContext.cxx:350
 TGLContext.cxx:351
 TGLContext.cxx:352
 TGLContext.cxx:353
 TGLContext.cxx:354
 TGLContext.cxx:355
 TGLContext.cxx:356
 TGLContext.cxx:357
 TGLContext.cxx:358
 TGLContext.cxx:359
 TGLContext.cxx:360
 TGLContext.cxx:361
 TGLContext.cxx:362
 TGLContext.cxx:363
 TGLContext.cxx:364
 TGLContext.cxx:365
 TGLContext.cxx:366
 TGLContext.cxx:367
 TGLContext.cxx:368
 TGLContext.cxx:369
 TGLContext.cxx:370
 TGLContext.cxx:371
 TGLContext.cxx:372
 TGLContext.cxx:373
 TGLContext.cxx:374
 TGLContext.cxx:375
 TGLContext.cxx:376
 TGLContext.cxx:377
 TGLContext.cxx:378
 TGLContext.cxx:379
 TGLContext.cxx:380
 TGLContext.cxx:381
 TGLContext.cxx:382
 TGLContext.cxx:383
 TGLContext.cxx:384
 TGLContext.cxx:385
 TGLContext.cxx:386
 TGLContext.cxx:387
 TGLContext.cxx:388
 TGLContext.cxx:389
 TGLContext.cxx:390
 TGLContext.cxx:391
 TGLContext.cxx:392
 TGLContext.cxx:393
 TGLContext.cxx:394
 TGLContext.cxx:395
 TGLContext.cxx:396
 TGLContext.cxx:397
 TGLContext.cxx:398
 TGLContext.cxx:399
 TGLContext.cxx:400
 TGLContext.cxx:401
 TGLContext.cxx:402
 TGLContext.cxx:403
 TGLContext.cxx:404
 TGLContext.cxx:405
 TGLContext.cxx:406
 TGLContext.cxx:407
 TGLContext.cxx:408
 TGLContext.cxx:409
 TGLContext.cxx:410
 TGLContext.cxx:411
 TGLContext.cxx:412
 TGLContext.cxx:413
 TGLContext.cxx:414
 TGLContext.cxx:415
 TGLContext.cxx:416
 TGLContext.cxx:417
 TGLContext.cxx:418
 TGLContext.cxx:419
 TGLContext.cxx:420
 TGLContext.cxx:421
 TGLContext.cxx:422
 TGLContext.cxx:423
 TGLContext.cxx:424
 TGLContext.cxx:425
 TGLContext.cxx:426
 TGLContext.cxx:427
 TGLContext.cxx:428
 TGLContext.cxx:429
 TGLContext.cxx:430
 TGLContext.cxx:431
 TGLContext.cxx:432
 TGLContext.cxx:433
 TGLContext.cxx:434
 TGLContext.cxx:435
 TGLContext.cxx:436
 TGLContext.cxx:437
 TGLContext.cxx:438
 TGLContext.cxx:439
 TGLContext.cxx:440
 TGLContext.cxx:441
 TGLContext.cxx:442
 TGLContext.cxx:443
 TGLContext.cxx:444
 TGLContext.cxx:445
 TGLContext.cxx:446
 TGLContext.cxx:447
 TGLContext.cxx:448
 TGLContext.cxx:449
 TGLContext.cxx:450
 TGLContext.cxx:451
 TGLContext.cxx:452
 TGLContext.cxx:453
 TGLContext.cxx:454
 TGLContext.cxx:455
 TGLContext.cxx:456
 TGLContext.cxx:457
 TGLContext.cxx:458
 TGLContext.cxx:459
 TGLContext.cxx:460
 TGLContext.cxx:461
 TGLContext.cxx:462
 TGLContext.cxx:463
 TGLContext.cxx:464
 TGLContext.cxx:465
 TGLContext.cxx:466
 TGLContext.cxx:467
 TGLContext.cxx:468
 TGLContext.cxx:469
 TGLContext.cxx:470
 TGLContext.cxx:471
 TGLContext.cxx:472
 TGLContext.cxx:473
 TGLContext.cxx:474
 TGLContext.cxx:475
 TGLContext.cxx:476
 TGLContext.cxx:477
 TGLContext.cxx:478
 TGLContext.cxx:479
 TGLContext.cxx:480
 TGLContext.cxx:481
 TGLContext.cxx:482
 TGLContext.cxx:483
 TGLContext.cxx:484
 TGLContext.cxx:485
 TGLContext.cxx:486
 TGLContext.cxx:487
 TGLContext.cxx:488
 TGLContext.cxx:489
 TGLContext.cxx:490
 TGLContext.cxx:491
 TGLContext.cxx:492
 TGLContext.cxx:493
 TGLContext.cxx:494
 TGLContext.cxx:495
 TGLContext.cxx:496
 TGLContext.cxx:497
 TGLContext.cxx:498
 TGLContext.cxx:499
 TGLContext.cxx:500
 TGLContext.cxx:501
 TGLContext.cxx:502
 TGLContext.cxx:503
 TGLContext.cxx:504
 TGLContext.cxx:505
 TGLContext.cxx:506
 TGLContext.cxx:507
 TGLContext.cxx:508
 TGLContext.cxx:509
 TGLContext.cxx:510
 TGLContext.cxx:511
 TGLContext.cxx:512
 TGLContext.cxx:513
 TGLContext.cxx:514
 TGLContext.cxx:515
 TGLContext.cxx:516
 TGLContext.cxx:517
 TGLContext.cxx:518
 TGLContext.cxx:519
 TGLContext.cxx:520
 TGLContext.cxx:521
 TGLContext.cxx:522
 TGLContext.cxx:523
 TGLContext.cxx:524
 TGLContext.cxx:525
 TGLContext.cxx:526
 TGLContext.cxx:527
 TGLContext.cxx:528
 TGLContext.cxx:529
 TGLContext.cxx:530
 TGLContext.cxx:531
 TGLContext.cxx:532
 TGLContext.cxx:533
 TGLContext.cxx:534
 TGLContext.cxx:535
 TGLContext.cxx:536
 TGLContext.cxx:537
 TGLContext.cxx:538
 TGLContext.cxx:539
 TGLContext.cxx:540
 TGLContext.cxx:541
 TGLContext.cxx:542
 TGLContext.cxx:543
 TGLContext.cxx:544
 TGLContext.cxx:545
 TGLContext.cxx:546
 TGLContext.cxx:547
 TGLContext.cxx:548
 TGLContext.cxx:549
 TGLContext.cxx:550
 TGLContext.cxx:551
 TGLContext.cxx:552
 TGLContext.cxx:553
 TGLContext.cxx:554
 TGLContext.cxx:555
 TGLContext.cxx:556
 TGLContext.cxx:557
 TGLContext.cxx:558
 TGLContext.cxx:559
 TGLContext.cxx:560
 TGLContext.cxx:561
 TGLContext.cxx:562
 TGLContext.cxx:563
 TGLContext.cxx:564
 TGLContext.cxx:565
 TGLContext.cxx:566
 TGLContext.cxx:567
 TGLContext.cxx:568
 TGLContext.cxx:569
 TGLContext.cxx:570