Panda3D

config_util.cxx

00001 // Filename: config_util.cxx
00002 // Created by:  cary (04Jan00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "config_util.h"
00016 #include "animInterface.h"
00017 #include "bamCacheIndex.h"
00018 #include "bamCacheRecord.h"
00019 #include "bamReader.h"
00020 #include "bamReaderParam.h"
00021 #include "bitArray.h"
00022 #include "bitMask.h"
00023 #include "buttonHandle.h"
00024 #include "cachedTypedWritableReferenceCount.h"
00025 #include "callbackData.h"
00026 #include "callbackObject.h"
00027 #include "clockObject.h"
00028 #include "configurable.h"
00029 #include "copyOnWriteObject.h"
00030 #include "cPointerCallbackObject.h"
00031 #include "datagram.h"
00032 #include "doubleBitMask.h"
00033 #include "factoryParam.h"
00034 #include "namable.h"
00035 #include "nodeCachedReferenceCount.h"
00036 #include "pythonCallbackObject.h"
00037 #include "referenceCount.h"
00038 #include "sparseArray.h"
00039 #include "typedObject.h"
00040 #include "typedReferenceCount.h"
00041 #include "typedWritable.h"
00042 #include "typedWritableReferenceCount.h"
00043 #include "writableConfigurable.h"
00044 #include "writableParam.h"
00045 #include "keyboardButton.h"
00046 #include "mouseButton.h"
00047 
00048 #include "dconfig.h"
00049 
00050 ConfigureDef(config_util);
00051 NotifyCategoryDef(util, "");
00052 NotifyCategoryDef(bam, util_cat);
00053 
00054 ConfigVariableEnum<BamEnums::BamEndian> bam_endian
00055 ("bam-endian", BamEnums::BE_native,
00056  PRC_DESC("The default endianness to use for writing major numeric data "
00057           "tables to bam files.  This does not affect all numbers written "
00058           "to bam files, only those for which the individual object was "
00059           "designed to support this flag.  The default is \"native\"; you "
00060           "may set it to \"littleendian\" or \"bigendian\" to target a "
00061           "particular platform."));
00062 
00063 ConfigVariableEnum<BamEnums::BamTextureMode> bam_texture_mode
00064 ("bam-texture-mode", BamEnums::BTM_relative,
00065  PRC_DESC("Set this to specify how textures should be written into Bam files."
00066           "See the panda source or documentation for available options."));
00067 
00068 
00069 
00070 ConfigureFn(config_util) {
00071   init_libputil();
00072 }
00073 
00074 // Set this true to enable tracking of ReferenceCount pointer
00075 // allocation/deallcation via the MemoryUsage object.  This is
00076 // primarily useful for detecting memory leaks.  It has no effect when
00077 // compiling in NDEBUG mode.
00078 //
00079 // This variable is no longer defined here; instead, it's a member of
00080 // MemoryUsage.
00081 //
00082 // ConfigVariableBool track_memory_usage("track-memory-usage", false);
00083 
00084 ConfigVariableSearchPath &
00085 get_model_path() {
00086   static ConfigVariableSearchPath *model_path = NULL;
00087   if (model_path == NULL) {
00088     model_path = new ConfigVariableSearchPath
00089       ("model-path", 
00090        PRC_DESC("The default directories to search for all models and general "
00091                 "files loaded into Panda."));
00092   }
00093 
00094   return *model_path;
00095 }
00096 
00097 ConfigVariableSearchPath &
00098 get_plugin_path() {
00099   static ConfigVariableSearchPath *plugin_path = NULL;
00100   if (plugin_path == NULL) {
00101     plugin_path = new ConfigVariableSearchPath
00102       ("plugin-path", "<auto>",
00103        PRC_DESC("The directories to search for plugin shared libraries."));
00104   }
00105 
00106   return *plugin_path;
00107 }
00108 
00109 ConfigVariableDouble sleep_precision
00110 ("sleep-precision", 0.01,
00111  PRC_DESC("This is the accuracy within which we can expect select() to "
00112           "return precisely.  That is, if we use select() to request a "
00113           "timeout of 1.0 seconds, we can expect to actually sleep for "
00114           "somewhere between 1.0 and 1.0 + sleep-precision seconds."));
00115 
00116 ConfigVariableBool preload_textures
00117 ("preload-textures", true,
00118  PRC_DESC("When this is true, texture images are loaded from disk as soon "
00119           "as the Texture is created from the TexturePool.  When this is "
00120           "false, the Texture is created immediately, but the image data "
00121           "is not loaded from disk until the Texture is actually rendered "
00122           "(or otherwise prepared) on the GSG.  This can help reduce "
00123           "wasted memory from Textures that are created but never used "
00124           "to render."));
00125 
00126 ConfigVariableBool preload_simple_textures
00127 ("preload-simple-textures", false,
00128  PRC_DESC("When this is true, every texture image will have a simple "
00129           "image generated for it at load time.  (Normally, textures "
00130           "get a simple image at egg2bam time.)  This slows the initial "
00131           "loading time of textures, but allows you to take advantage "
00132           "of gsg::set_incomplete_render() to load textures on-the-fly "
00133           "in a sub-thread.  It's not generally necessary if you are "
00134           "loading bam files that were generated via egg2bam."));
00135 
00136 ////////////////////////////////////////////////////////////////////
00137 //     Function: init_libputil
00138 //  Description: Initializes the library.  This must be called at
00139 //               least once before any of the functions or classes in
00140 //               this library can be used.  Normally it will be
00141 //               called by the static initializers and need not be
00142 //               called explicitly, but special cases exist.
00143 ////////////////////////////////////////////////////////////////////
00144 void
00145 init_libputil() {
00146   static bool initialized = false;
00147   if (initialized) {
00148     return;
00149   }
00150   initialized = true;
00151 
00152   AnimInterface::init_type();
00153   BamCacheIndex::init_type();
00154   BamCacheRecord::init_type();
00155   BamReaderAuxData::init_type();
00156   BamReaderParam::init_type();
00157   BitArray::init_type();
00158   BitMask16::init_type();
00159   BitMask32::init_type();
00160   BitMask64::init_type();
00161   ButtonHandle::init_type();
00162   CPointerCallbackObject::init_type();
00163   CachedTypedWritableReferenceCount::init_type();
00164   CallbackData::init_type();
00165   CallbackObject::init_type();
00166   ClockObject::init_type();
00167   Configurable::init_type();
00168   CopyOnWriteObject::init_type();
00169   Datagram::init_type();
00170   DoubleBitMaskNative::init_type();
00171   FactoryParam::init_type();
00172   Namable::init_type();
00173   NodeCachedReferenceCount::init_type();
00174 #ifdef HAVE_PYTHON
00175   PythonCallbackObject::init_type();
00176 #endif
00177   QuadBitMaskNative::init_type();
00178   ReferenceCount::init_type();
00179   SparseArray::init_type();
00180   TypedObject::init_type();
00181   TypedReferenceCount::init_type();
00182   TypedWritable::init_type();
00183   TypedWritableReferenceCount::init_type();
00184   WritableConfigurable::init_type();
00185   WritableParam::init_type();
00186 
00187   KeyboardButton::init_keyboard_buttons();
00188   MouseButton::init_mouse_buttons();
00189 
00190   BamCacheIndex::register_with_read_factory();
00191   BamCacheRecord::register_with_read_factory();
00192 
00193   // Initialize the num_bits_on table, for BitMask::get_num_on_bits().
00194   for (int bit = 0; bit < 16; ++bit) {
00195     int w = (1 << bit);
00196     for (int i = 0; i < w; ++i) {
00197       num_bits_on[i + w] = num_bits_on[i] + 1;
00198     }
00199   }
00200 }
00201 
 All Classes Functions Variables Enumerations