Panda3D
 All Classes Functions Variables Enumerations
config_util.cxx
1 // Filename: config_util.cxx
2 // Created by: cary (04Jan00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_util.h"
16 #include "animInterface.h"
17 #include "bamCacheIndex.h"
18 #include "bamCacheRecord.h"
19 #include "bamReader.h"
20 #include "bamReaderParam.h"
21 #include "bitArray.h"
22 #include "bitMask.h"
23 #include "buttonHandle.h"
24 #include "buttonMap.h"
25 #include "cachedTypedWritableReferenceCount.h"
26 #include "callbackData.h"
27 #include "callbackObject.h"
28 #include "clockObject.h"
29 #include "configurable.h"
30 #include "copyOnWriteObject.h"
31 #include "cPointerCallbackObject.h"
32 #include "datagram.h"
33 #include "doubleBitMask.h"
34 #include "factoryParam.h"
35 #include "namable.h"
36 #include "nodeCachedReferenceCount.h"
37 #include "paramValue.h"
38 #include "referenceCount.h"
39 #include "sparseArray.h"
40 #include "typedObject.h"
41 #include "typedReferenceCount.h"
42 #include "typedWritable.h"
43 #include "typedWritableReferenceCount.h"
44 #include "writableConfigurable.h"
45 #include "writableParam.h"
46 #include "keyboardButton.h"
47 #include "mouseButton.h"
48 
49 #include "dconfig.h"
50 
51 ConfigureDef(config_util);
52 NotifyCategoryDef(util, "");
53 NotifyCategoryDef(bam, util_cat);
54 
56 ("bam-endian", BamEnums::BE_native,
57  PRC_DESC("The default endianness to use for writing major numeric data "
58  "tables to bam files. This does not affect all numbers written "
59  "to bam files, only those for which the individual object was "
60  "designed to support this flag. The default is \"native\"; you "
61  "may set it to \"littleendian\" or \"bigendian\" to target a "
62  "particular platform."));
63 
64 ConfigVariableBool bam_stdfloat_double
65 ("bam-stdfloat-double",
66 #ifdef STDFLOAT_DOUBLE
67  true,
68 #else
69  false,
70 #endif
71  PRC_DESC("The default width of floating-point numbers to write to a bam "
72  "file. Set this true to force doubles (64-bit floats), or false "
73  "to force singles (32-bit floats). The default is whichever width "
74  "Panda has been compiled to use natively. Normally, this setting "
75  "should not be changed from the default."));
76 
78 ("bam-texture-mode", BamEnums::BTM_relative,
79  PRC_DESC("Set this to specify how textures should be written into Bam files."
80  "See the panda source or documentation for available options."));
81 
82 ConfigureFn(config_util) {
83  init_libputil();
84 }
85 
86 // Set this true to enable tracking of ReferenceCount pointer
87 // allocation/deallcation via the MemoryUsage object. This is
88 // primarily useful for detecting memory leaks. It has no effect when
89 // compiling in NDEBUG mode.
90 //
91 // This variable is no longer defined here; instead, it's a member of
92 // MemoryUsage.
93 //
94 // ConfigVariableBool track_memory_usage("track-memory-usage", false);
95 
97 get_model_path() {
98  static ConfigVariableSearchPath *model_path = NULL;
99  if (model_path == NULL) {
100  model_path = new ConfigVariableSearchPath
101  ("model-path",
102  PRC_DESC("The default directories to search for all models and general "
103  "files loaded into Panda."));
104  }
105 
106  return *model_path;
107 }
108 
110 get_plugin_path() {
111  static ConfigVariableSearchPath *plugin_path = NULL;
112  if (plugin_path == NULL) {
113  plugin_path = new ConfigVariableSearchPath
114  ("plugin-path", "<auto>",
115  PRC_DESC("The directories to search for plugin shared libraries."));
116  }
117 
118  return *plugin_path;
119 }
120 
121 ConfigVariableDouble sleep_precision
122 ("sleep-precision", 0.01,
123  PRC_DESC("This is the accuracy within which we can expect select() to "
124  "return precisely. That is, if we use select() to request a "
125  "timeout of 1.0 seconds, we can expect to actually sleep for "
126  "somewhere between 1.0 and 1.0 + sleep-precision seconds."));
127 
128 ConfigVariableBool preload_textures
129 ("preload-textures", true,
130  PRC_DESC("When this is true, texture images are loaded from disk as soon "
131  "as the Texture is created from the TexturePool. When this is "
132  "false, the Texture is created immediately, but the image data "
133  "is not loaded from disk until the Texture is actually rendered "
134  "(or otherwise prepared) on the GSG. This can help reduce "
135  "wasted memory from Textures that are created but never used "
136  "to render."));
137 
138 ConfigVariableBool preload_simple_textures
139 ("preload-simple-textures", false,
140  PRC_DESC("When this is true, every texture image will have a simple "
141  "image generated for it at load time. (Normally, textures "
142  "get a simple image at egg2bam time.) This slows the initial "
143  "loading time of textures, but allows you to take advantage "
144  "of gsg::set_incomplete_render() to load textures on-the-fly "
145  "in a sub-thread. It's not generally necessary if you are "
146  "loading bam files that were generated via egg2bam."));
147 
148 ConfigVariableBool cache_check_timestamps
149 ("cache-check-timestamps", true,
150  PRC_DESC("Set this true to check the timestamps on disk (when possible) "
151  "before reloading a file from the in-memory cache, e.g. via ModelPool, "
152  "TexturePool, etc. When this is false, a model or texture "
153  "that was previously loaded and is still found in the ModelPool is "
154  "immediately returned without consulting the disk, even if the "
155  "file on disk has recently changed. When this is true, the file "
156  "on disk is always checked to ensure its timestamp has not "
157  "recently changed; and if it has, the in-memory cache is automatically "
158  "invalidated and the file is reloaded from disk. This is not related "
159  "to on-disk caching via model-cache-dir, which always checks the "
160  "timestamps."));
161 
162 ////////////////////////////////////////////////////////////////////
163 // Function: init_libputil
164 // Description: Initializes the library. This must be called at
165 // least once before any of the functions or classes in
166 // this library can be used. Normally it will be
167 // called by the static initializers and need not be
168 // called explicitly, but special cases exist.
169 ////////////////////////////////////////////////////////////////////
170 void
171 init_libputil() {
172  static bool initialized = false;
173  if (initialized) {
174  return;
175  }
176  initialized = true;
177 
178  AnimInterface::init_type();
179  BamCacheIndex::init_type();
180  BamCacheRecord::init_type();
181  BamReaderAuxData::init_type();
182  BamReaderParam::init_type();
183  BitArray::init_type();
184  BitMask16::init_type();
185  BitMask32::init_type();
186  BitMask64::init_type();
187  ButtonHandle::init_type();
188  ButtonMap::init_type();
189  CPointerCallbackObject::init_type();
190  CachedTypedWritableReferenceCount::init_type();
191  CallbackData::init_type();
192  CallbackObject::init_type();
193  ClockObject::init_type();
194  Configurable::init_type();
195  CopyOnWriteObject::init_type();
196  Datagram::init_type();
197  DoubleBitMaskNative::init_type();
198  FactoryParam::init_type();
199  Namable::init_type();
200  NodeCachedReferenceCount::init_type();
201  ParamMatrix3d::init_type("ParamMatrix3d");
202  ParamMatrix3f::init_type("ParamMatrix3f");
203  ParamMatrix4d::init_type("ParamMatrix4d");
204  ParamMatrix4f::init_type("ParamMatrix4f");
205  ParamString::init_type("ParamString");
206  ParamTypedRefCount::init_type();
207  ParamValueBase::init_type();
208  ParamVecBase2d::init_type("ParamVecBase2d");
209  ParamVecBase2f::init_type("ParamVecBase2f");
210  ParamVecBase2i::init_type("ParamVecBase2i");
211  ParamVecBase3d::init_type("ParamVecBase3d");
212  ParamVecBase3f::init_type("ParamVecBase3f");
213  ParamVecBase3i::init_type("ParamVecBase3i");
214  ParamVecBase4f::init_type("ParamVecBase4f");
215  ParamVecBase4d::init_type("ParamVecBase4d");
216  ParamVecBase4i::init_type("ParamVecBase4i");
217  ParamWstring::init_type("ParamWstring");
218  QuadBitMaskNative::init_type();
219  ReferenceCount::init_type();
220  SparseArray::init_type();
222  TypedReferenceCount::init_type();
223  TypedWritable::init_type();
224  TypedWritableReferenceCount::init_type();
225  WritableConfigurable::init_type();
226  WritableParam::init_type();
227 
230 
248 }
This is similar to a ConfigVariableList, but it returns its list as a DSearchPath, as a list of directories.
static void init_keyboard_buttons()
This is intended to be called only once, by the static initialization performed in config_util...
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:52
This is a convenience class to specialize ConfigVariable as a boolean type.
static void init_mouse_buttons()
This is intended to be called only once, by the static initialization performed in config_util...
This is a convenience class to specialize ConfigVariable as a floating-point type.
This class specializes ConfigVariable as an enumerated type.
static void register_with_read_factory()
Tells the BamReader how to create objects of type BamCacheRecord.
static void register_with_read_factory()
Tells the BamReader how to create objects of type ParamValue.
Definition: paramValue.I:159
static void register_with_read_factory()
Tells the BamReader how to create objects of type BamCacheRecord.