TridOpenGLGlobal Class Reference

#include <TridOpenGLGlobal.h>

List of all members.

Public Member Functions

 ~TridOpenGLGlobal (void)
int GlfLoadFont (const char *fontfile="")

Static Public Member Functions

static TridOpenGLGlobalInstance (void)

Private Member Functions

 TridOpenGLGlobal (void)

Private Attributes

Bool_t fGL_Started
Bool_t fGLF_Started
std::string fGLF_Font
void * fLibGLHandle
void * fLibGLUHandle

Static Private Attributes

static TridOpenGLGlobalsInstance = NULL

Detailed Description

Definition at line 26 of file TridOpenGLGlobal.h.


Constructor & Destructor Documentation

TridOpenGLGlobal::~TridOpenGLGlobal ( void   ) 

Definition at line 75 of file TridOpenGLGlobal.cxx.

References fGLF_Started, fLibGLHandle, fLibGLUHandle, and glfUnloadFont().

00076 {
00077   if(fGLF_Started) glfUnloadFont();
00078   if(fLibGLHandle) dlclose(fLibGLHandle);
00079   if(fLibGLHandle) dlclose(fLibGLUHandle);
00080 }

TridOpenGLGlobal::TridOpenGLGlobal ( void   )  [private]

Definition at line 32 of file TridOpenGLGlobal.cxx.

References fGL_Started, fGLF_Font, fGLF_Started, fLibGLHandle, and fLibGLUHandle.

Referenced by Instance().

00033 {
00034   fGL_Started = false;
00035   fGLF_Started = false;
00036   fGLF_Font = "";
00037 
00038   // Load the GL libraries. These may be loaded by ROOT
00039   // anyway, but who cares?
00040   fGL_Started = true;
00041 
00042   #ifdef __APPLE__
00043   fLibGLHandle = dlopen("libGL.dylib", RTLD_LAZY);
00044   if(!fLibGLHandle) {
00045      fGL_Started = false;
00046      cerr << "Error on load of libGL:  " << dlerror() << endl;
00047   }
00048   fLibGLUHandle = dlopen("libGLU.dylib", RTLD_LAZY | RTLD_GLOBAL);
00049   if(!fLibGLUHandle) {
00050      fGL_Started = false;
00051      cerr << "Error on load of libGLU: " << dlerror() << endl;
00052   }
00053   #else
00054   fLibGLHandle = dlopen("libGL.so", RTLD_LAZY);
00055   if(!fLibGLHandle) {
00056      fGL_Started = false;
00057      cerr << "Error on load of libGL:  " << dlerror() << endl;
00058   }
00059   fLibGLUHandle = dlopen("libGLU.so", RTLD_LAZY | RTLD_GLOBAL);
00060   if(!fLibGLUHandle) {
00061      fGL_Started = false;
00062      cerr << "Error on load of libGLU: " << dlerror() << endl;
00063   }
00064   #endif
00065 
00066   if(fGL_Started == false) {
00067     cerr << "TriD could not load the GL libraries!" << endl;
00068     cerr << "Make sure your system has OpenGL (or Mesa) installed correctly!" << endl;
00069     
00070   }
00071 }


Member Function Documentation

int TridOpenGLGlobal::GlfLoadFont ( const char *  fontfile = ""  ) 

Definition at line 84 of file TridOpenGLGlobal.cxx.

References fGLF_Started, glfInit(), glfLoadFont(), glfUnloadFont(), gSystem(), Msg::kDebug, Msg::kFatal, and MSG.

Referenced by TridGLFrame::SetupOpenGL().

00085 {
00086   // Look for the font file. Throw an error if we can't find it.
00087   string basename = fontfile;
00088   if(strlen(fontfile)==0) basename = "arial1.glf";
00089   
00090   // Look in the code directories. This should be safe; code
00091   // libraries won't exist only on 'production' farms, which
00092   // shouldn't be doing viewing anyway.
00093 
00094   const char* private_context = gSystem->Getenv("SRT_PRIVATE_CONTEXT");
00095   const char* public_context = gSystem->Getenv("SRT_PUBLIC_CONTEXT");
00096   const char* trid_dir       = gSystem->Getenv("TRID");
00097 
00098   string path = "./";
00099   if(private_context) path += string(":") + string(private_context) + string("/TriD/fonts/");
00100   if(public_context)  path += string(":") + string(public_context) + string("/TriD/fonts/");
00101   if(trid_dir)        path += string(":") + string(trid_dir);
00102   
00103   char* pathname = gSystem->Which(path.c_str(),basename.c_str());
00104   if(pathname==0) {
00105     MSG("TriD",Msg::kFatal) << "TridOpenGLGlobal: Cannot find requested font " << basename << endl;
00106     return 1;
00107   }
00108   MSG("TriD",Msg::kDebug) << "Found font path: " << pathname << endl;
00109   
00110   if(fGLF_Started == false) {
00111     glfInit();
00112     fGLF_Started=true;
00113   } else {
00114     glfUnloadFont();
00115   }
00116   glfLoadFont(pathname);
00117   return 0;
00118 }

TridOpenGLGlobal & TridOpenGLGlobal::Instance ( void   )  [static]

Definition at line 22 of file TridOpenGLGlobal.cxx.

References sInstance, and TridOpenGLGlobal().

Referenced by TridGLFrame::SetupOpenGL().

00023 {
00024   if(sInstance==NULL) {
00025     sInstance = new TridOpenGLGlobal();
00026   }
00027   assert(sInstance);
00028   return (*sInstance);
00029 }


Member Data Documentation

Definition at line 39 of file TridOpenGLGlobal.h.

Referenced by TridOpenGLGlobal().

std::string TridOpenGLGlobal::fGLF_Font [private]

Definition at line 41 of file TridOpenGLGlobal.h.

Referenced by TridOpenGLGlobal().

Definition at line 40 of file TridOpenGLGlobal.h.

Referenced by GlfLoadFont(), TridOpenGLGlobal(), and ~TridOpenGLGlobal().

Definition at line 43 of file TridOpenGLGlobal.h.

Referenced by TridOpenGLGlobal(), and ~TridOpenGLGlobal().

Definition at line 44 of file TridOpenGLGlobal.h.

Referenced by TridOpenGLGlobal(), and ~TridOpenGLGlobal().

TridOpenGLGlobal * TridOpenGLGlobal::sInstance = NULL [static, private]

Definition at line 38 of file TridOpenGLGlobal.h.

Referenced by Instance().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1