Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
GlobalSettings.cpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
33 #include <cstdlib>
34 #include <cstdio>
35 
36 using namespace vl;
37 
38 //-----------------------------------------------------------------------------
40 {
41  VL_DEBUG_SET_OBJECT_NAME()
42 
43  #ifndef NDEBUG
45  mCheckOpenGLStates = true;
46  #else
47  mVerbosityLevel = vl::VEL_VERBOSITY_ERROR;
48  mCheckOpenGLStates = false;
49  #endif
50 
51  // initialize from environment variables
52 
53  char* val = NULL;
54 
55  // log file
56 
57  val = getenv("VL_LOGFILE_PATH");
58  if (val)
59  mDefaultLogPath = val;
60  else
61  mDefaultLogPath = "log.txt";
62 
63  // data path
64 
65  val = getenv("VL_DATA_PATH");
66  if (val)
67  mDefaultDataPath = val;
68  else
69  mDefaultDataPath = "../data";
70 
71  // verbosity level
72 
73  val = getenv("VL_VERBOSITY_LEVEL");
74  if (val)
75  {
76  if ( String(val).toUpperCase() == "SILENT")
78  else
79  if ( String(val).toUpperCase() == "ERROR")
81  else
82  if ( String(val).toUpperCase() == "NORMAL")
84  else
85  if ( String(val).toUpperCase() == "DEBUG")
87  else
88  {
89  // no log here yet.
90  fprintf(stderr,"VL_VERBOSITY_LEVEL variable has unknown value %s! Legal values: SILENT, ERROR, NORMAL, DEBUG\n\n", val);
91  }
92  }
93 
94  // opengl state checks
95 
96  val = getenv("VL_CHECK_GL_STATES");
97  if (val)
98  {
99  if ( String(val).toUpperCase() == "YES" )
100  setCheckOpenGLStates(true);
101  else
102  if ( String(val).toUpperCase() == "NO" )
103  setCheckOpenGLStates(false);
104  else
105  {
106  // no log here yet.
107  fprintf(stderr,"VL_CHECK_GL_STATES variable has unknown value '%s'! Legal values: YES, NO.\n\n", val);
108  }
109  }
110 }
111 //-----------------------------------------------------------------------------
EVerbosityLevel mVerbosityLevel
< No log information is generated.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
< Outputs normal information messages, plus all error messages.
Visualization Library main namespace.
#define NULL
Definition: OpenGLDefs.hpp:81
< Outputs critical and runtime error messages.
< Outputs extra information messages useful for debugging, plus all normal and error messages...
void setCheckOpenGLStates(bool check_clean)
If true VL checks at the beginning of each rendering that the OpenGL states are clean and ready to be...
void setVerbosityLevel(EVerbosityLevel verb_level)
The verbosity level of VL.