Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]

X:/dropbox/visualizationlibrary/src/vlCore/GlobalSettings.cpp

Go to the documentation of this file.
00001 /**************************************************************************************/
00002 /*                                                                                    */
00003 /*  Visualization Library                                                             */
00004 /*  http://www.visualizationlibrary.org                                               */
00005 /*                                                                                    */
00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
00007 /*  All rights reserved.                                                              */
00008 /*                                                                                    */
00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
00010 /*  are permitted provided that the following conditions are met:                     */
00011 /*                                                                                    */
00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
00013 /*  list of conditions and the following disclaimer.                                  */
00014 /*                                                                                    */
00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
00017 /*  other materials provided with the distribution.                                   */
00018 /*                                                                                    */
00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
00029 /*                                                                                    */
00030 /**************************************************************************************/
00031 
00032 #include <vlCore/GlobalSettings.hpp>
00033 #include <cstdlib>
00034 #include <cstdio>
00035 
00036 using namespace vl;
00037 
00038 //-----------------------------------------------------------------------------
00039 GlobalSettings::GlobalSettings()
00040 {
00041   VL_DEBUG_SET_OBJECT_NAME()
00042 
00043   #ifndef NDEBUG
00044     mVerbosityLevel  = vl::VEL_VERBOSITY_NORMAL;
00045     mCheckOpenGLStates = true;
00046   #else
00047     mVerbosityLevel  = vl::VEL_VERBOSITY_ERROR;
00048     mCheckOpenGLStates = false;
00049   #endif
00050 
00051   // initialize from environment variables
00052 
00053   char* val = NULL;
00054 
00055   // log file
00056 
00057   val = getenv("VL_LOGFILE_PATH");
00058   if (val)
00059     mDefaultLogPath = val;
00060   else
00061     mDefaultLogPath = "log.txt";
00062 
00063   // data path
00064 
00065   val = getenv("VL_DATA_PATH");
00066   if (val)
00067     mDefaultDataPath = val;
00068   else
00069     mDefaultDataPath = "../data";
00070 
00071   // verbosity level
00072 
00073   val = getenv("VL_VERBOSITY_LEVEL");
00074   if (val)
00075   {
00076     if ( String(val).toUpperCase() == "SILENT")
00077       setVerbosityLevel(vl::VEL_VERBOSITY_SILENT);
00078     else
00079     if ( String(val).toUpperCase() == "ERROR")
00080       setVerbosityLevel(vl::VEL_VERBOSITY_ERROR);
00081     else
00082     if ( String(val).toUpperCase() == "NORMAL")
00083       setVerbosityLevel(vl::VEL_VERBOSITY_NORMAL);
00084     else
00085     if ( String(val).toUpperCase() == "DEBUG")
00086       setVerbosityLevel(vl::VEL_VERBOSITY_DEBUG);
00087     else
00088     {
00089       // no log here yet.
00090       fprintf(stderr,"VL_VERBOSITY_LEVEL variable has unknown value %s! Legal values: SILENT, ERROR, NORMAL, DEBUG\n\n", val);
00091     }
00092   }
00093 
00094   // opengl state checks
00095 
00096   val = getenv("VL_CHECK_GL_STATES");
00097   if (val)
00098   {
00099     if ( String(val).toUpperCase() == "YES" )
00100       setCheckOpenGLStates(true);
00101     else
00102     if ( String(val).toUpperCase() == "NO" )
00103       setCheckOpenGLStates(false);
00104     else
00105     {
00106       // no log here yet.
00107       fprintf(stderr,"VL_CHECK_GL_STATES variable has unknown value '%s'! Legal values: YES, NO.\n\n", val);
00108     }
00109   }
00110 }
00111 //-----------------------------------------------------------------------------

Visualization Library 2011.09.1160 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 2 2013 13:40:28.
Permission is granted to use this page to write and publish articles regarding Visualization Library.