Panda3D allows you to configure the engine runtime using a central configuration file. This recipe will show you where to find this configuration file and will explain a selection of settings you are able to specify to tweak Panda3D's behavior.
You can configure the Panda3D engine with these two steps:
C:Panda3D-1.7.0etcConfig.prc
in a text editor.Now that you've opened Panda3D's configuration file, it is time to explain a good part of the vast array of settings the engine allows you to modify. The following table will present the names of the configuration variables, the values that can be set, as well as a short description of what part of Panda3D is influenced by the setting.
The column containing the possible values uses several notations:
MAX_INT
and MAX_DBL
are used as placeholders for the maximum possible values for signed integer and floating point variables. prc
file format uses #t
for true and #f
for false for Boolean configuration flags. For example, the following line in Config.prc
enables full screen mode:fullscreen #t
icon-filename /c/mygame/assets/icon.ico
Name |
Possible Values |
Description | |
---|---|---|---|
audio-volume |
[0.0..1.0] |
Sets the master volume of your game. | |
background-color |
Any combination of 3 floating point numbers between 0 and 1, e.g.: 1.0 0.3 0.4 |
This variable sets the default background color for the render window and all render buffers in RGB format. | |
cursor-filename |
A valid file path |
Allows you to specify an image file to use as the mouse cursor. | |
cursor-hidden |
#t, #f |
If set to true, this makes the mouse cursor invisible when it is within the bounds of the game window. | |
disable-sticky-keys |
#t, #f |
If set to true, this disables the "sticky keys" feature of Windows. It's a good idea to set this to true because the sticky keys popup window will cause your game to lose focus! | |
fullscreen |
#t, #f |
Set this variable to #t if your game should switch to fullscreen mode on startup. | |
icon-filename |
A valid file path |
This variable instructs Panda3D to use the given file as its application icon. | |
model-path |
A valid file path |
The model-path variable sets one or more paths the engine will use as your search path when looking for models to load. The special symbol $THIS_PRC_DIR can be used to define directories relative to the configuration file. With $MAIN_DIR you are able to set a path relative to the directory the game's main python file resides in. For example, we can find these three lines in the default
These lines add the directory containing the main Python source file and the directories containing the sample models that come with the Panda3D SDK to the engine asset search path. | |
show-frame-rate-meter |
#t, #f |
If enabled, this shows a frame rate counter in the game window. | |
sync-video |
#t, #f |
Enables and disables vertical synchronization. If this is set to true, the maximum frame rate will be equal to the refresh rate of your display device. | |
win-origin |
Two integer values, for example, 25 20 |
Lets you define the position of the top left corner of the game window. When fullscreen mode is enabled, this setting has no effect. | |
win-size |
Two integer values, for example, 640 480 |
Sets the window size as well as the resolution when in fullscreen mode. When going to fullscreen mode, Panda3D switches the screen resolution to the values specified in this variable. If this does not match your screen resolution, it might have an effect on the positions and sizes of your desktop icons and any open program window. | |
window-title |
A string |
This setting is used to specify the title of the game window. The string does not have to be put within quotes even if it contains spaces. |
By setting the configuration variables above, you are already able to modify the engine's runtime behavior to your liking. But Panda3D's configuration system provides a few additional features you should know about.
The preceding table only shows a selection of the most commonly used configuration variables. To get a list of all configuration variables available in Panda3D, insert the following import statement and method call into your application code:
from panda3d.core import ConfigVariableManager ConfigVariableManager.getGlobalPtr().listVariables()
You do not need to put all engine settings into the global configuration file shown in this recipe. Instead, you can use the following function to load settings from any given file:
loadPrcFile("myconfig.prc")
You should put this call to a global scope to make sure settings are loaded before the engine systems that are using them are initialized.