TGLContextPrivate.cxx

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TGLContextPrivate.cxx 28662 2009-05-18 10:23:34Z rdm $
00002 // Author:  Timur Pocheptsov, Jun 2007
00003 
00004 #include "TGLContextPrivate.h"
00005 
00006 //______________________________________________________________________________
00007 void TGLContextPrivate::RegisterContext(TGLContext *ctx)
00008 {
00009    //Register gl-context to find it later as current (GetCurrentContext)
00010    if (ctx->IsValid())
00011       fgContexts[ctx->fPimpl->fGLContext] = ctx;
00012 }
00013 
00014 //______________________________________________________________________________
00015 void TGLContextPrivate::RemoveContext(TGLContext *ctx)
00016 {
00017    //Un-register deleted context.
00018    if (ctx->IsValid())
00019       fgContexts.erase(ctx->fPimpl->fGLContext);
00020 }
00021 
00022 #ifdef WIN32
00023 
00024 std::map<HGLRC, TGLContext *> TGLContextPrivate::fgContexts;
00025 
00026 //______________________________________________________________________________
00027 TGLContext *TGLContextPrivate::GetCurrentContext()
00028 {
00029    //Ask wgl what HGLRC is current and look up corresponding TGLContext.
00030    HGLRC glContext = wglGetCurrentContext();
00031    std::map<HGLRC, TGLContext *>::const_iterator it = fgContexts.find(glContext);
00032 
00033    if (it != fgContexts.end())
00034       return it->second;
00035 
00036    return 0;
00037 }
00038 
00039 #else
00040 
00041 std::map<GLXContext, TGLContext *> TGLContextPrivate::fgContexts;
00042 
00043 //______________________________________________________________________________
00044 TGLContext *TGLContextPrivate::GetCurrentContext()
00045 {
00046    //Ask wgl what HGLRC is current and look up corresponding TGLContext.
00047    GLXContext glContext = glXGetCurrentContext();
00048    std::map<GLXContext, TGLContext *>::const_iterator it = fgContexts.find(glContext);
00049 
00050    if (it != fgContexts.end())
00051       return it->second;
00052 
00053    return 0;
00054 }
00055 
00056 #endif

Generated on Tue Jul 5 14:18:06 2011 for ROOT_528-00b_version by  doxygen 1.5.1