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 ConfigVariableBool bam_stdfloat_double
00064 ("bam-stdfloat-double", 
00065 #ifdef STDFLOAT_DOUBLE
00066  true,
00067 #else
00068  false,
00069 #endif
00070  PRC_DESC("The default width of floating-point numbers to write to a bam "
00071           "file.  Set this true to force doubles (64-bit floats), or false "
00072           "to force sinles (32-bit floats).  The default is whichever width "
00073           "Panda has been compiled to use natively.  Normally, this setting "
00074           "should not be changed from the default."));
00075 
00076 ConfigVariableEnum<BamEnums::BamTextureMode> bam_texture_mode
00077 ("bam-texture-mode", BamEnums::BTM_relative,
00078  PRC_DESC("Set this to specify how textures should be written into Bam files."
00079           "See the panda source or documentation for available options."));
00080 
00081 
00082 
00083 ConfigureFn(config_util) {
00084   init_libputil();
00085 }
00086 
00087 // Set this true to enable tracking of ReferenceCount pointer
00088 // allocation/deallcation via the MemoryUsage object.  This is
00089 // primarily useful for detecting memory leaks.  It has no effect when
00090 // compiling in NDEBUG mode.
00091 //
00092 // This variable is no longer defined here; instead, it's a member of
00093 // MemoryUsage.
00094 //
00095 // ConfigVariableBool track_memory_usage("track-memory-usage", false);
00096 
00097 ConfigVariableSearchPath &
00098 get_model_path() {
00099   static ConfigVariableSearchPath *model_path = NULL;
00100   if (model_path == NULL) {
00101     model_path = new ConfigVariableSearchPath
00102       ("model-path", 
00103        PRC_DESC("The default directories to search for all models and general "
00104                 "files loaded into Panda."));
00105   }
00106 
00107   return *model_path;
00108 }
00109 
00110 ConfigVariableSearchPath &
00111 get_plugin_path() {
00112   static ConfigVariableSearchPath *plugin_path = NULL;
00113   if (plugin_path == NULL) {
00114     plugin_path = new ConfigVariableSearchPath
00115       ("plugin-path", "<auto>",
00116        PRC_DESC("The directories to search for plugin shared libraries."));
00117   }
00118 
00119   return *plugin_path;
00120 }
00121 
00122 ConfigVariableDouble sleep_precision
00123 ("sleep-precision", 0.01,
00124  PRC_DESC("This is the accuracy within which we can expect select() to "
00125           "return precisely.  That is, if we use select() to request a "
00126           "timeout of 1.0 seconds, we can expect to actually sleep for "
00127           "somewhere between 1.0 and 1.0 + sleep-precision seconds."));
00128 
00129 ConfigVariableBool preload_textures
00130 ("preload-textures", true,
00131  PRC_DESC("When this is true, texture images are loaded from disk as soon "
00132           "as the Texture is created from the TexturePool.  When this is "
00133           "false, the Texture is created immediately, but the image data "
00134           "is not loaded from disk until the Texture is actually rendered "
00135           "(or otherwise prepared) on the GSG.  This can help reduce "
00136           "wasted memory from Textures that are created but never used "
00137           "to render."));
00138 
00139 ConfigVariableBool preload_simple_textures
00140 ("preload-simple-textures", false,
00141  PRC_DESC("When this is true, every texture image will have a simple "
00142           "image generated for it at load time.  (Normally, textures "
00143           "get a simple image at egg2bam time.)  This slows the initial "
00144           "loading time of textures, but allows you to take advantage "
00145           "of gsg::set_incomplete_render() to load textures on-the-fly "
00146           "in a sub-thread.  It's not generally necessary if you are "
00147           "loading bam files that were generated via egg2bam."));
00148 
00149 ////////////////////////////////////////////////////////////////////
00150 //     Function: init_libputil
00151 //  Description: Initializes the library.  This must be called at
00152 //               least once before any of the functions or classes in
00153 //               this library can be used.  Normally it will be
00154 //               called by the static initializers and need not be
00155 //               called explicitly, but special cases exist.
00156 ////////////////////////////////////////////////////////////////////
00157 void
00158 init_libputil() {
00159   static bool initialized = false;
00160   if (initialized) {
00161     return;
00162   }
00163   initialized = true;
00164 
00165   AnimInterface::init_type();
00166   BamCacheIndex::init_type();
00167   BamCacheRecord::init_type();
00168   BamReaderAuxData::init_type();
00169   BamReaderParam::init_type();
00170   BitArray::init_type();
00171   BitMask16::init_type();
00172   BitMask32::init_type();
00173   BitMask64::init_type();
00174   ButtonHandle::init_type();
00175   CPointerCallbackObject::init_type();
00176   CachedTypedWritableReferenceCount::init_type();
00177   CallbackData::init_type();
00178   CallbackObject::init_type();
00179   ClockObject::init_type();
00180   Configurable::init_type();
00181   CopyOnWriteObject::init_type();
00182   Datagram::init_type();
00183   DoubleBitMaskNative::init_type();
00184   FactoryParam::init_type();
00185   Namable::init_type();
00186   NodeCachedReferenceCount::init_type();
00187 #ifdef HAVE_PYTHON
00188   PythonCallbackObject::init_type();
00189 #endif
00190   QuadBitMaskNative::init_type();
00191   ReferenceCount::init_type();
00192   SparseArray::init_type();
00193   TypedObject::init_type();
00194   TypedReferenceCount::init_type();
00195   TypedWritable::init_type();
00196   TypedWritableReferenceCount::init_type();
00197   WritableConfigurable::init_type();
00198   WritableParam::init_type();
00199 
00200   KeyboardButton::init_keyboard_buttons();
00201   MouseButton::init_mouse_buttons();
00202 
00203   BamCacheIndex::register_with_read_factory();
00204   BamCacheRecord::register_with_read_factory();
00205 
00206   // Initialize the num_bits_on table, for BitMask::get_num_on_bits().
00207   for (int bit = 0; bit < 16; ++bit) {
00208     int w = (1 << bit);
00209     for (int i = 0; i < w; ++i) {
00210       num_bits_on[i + w] = num_bits_on[i] + 1;
00211     }
00212   }
00213 }
00214 
 All Classes Functions Variables Enumerations