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