- Panda3d 1.7 Game Developer's Cookbook
- Christoph Lang
- 835字
- 2021-04-09 21:21:43
Configuring Visual Studio 2008 to work with Panda3D
The scripting-centric architecture of the Panda3D divides development into two sides. One of them is the application code written in Python that is created by game programmers to control the gameplay behavior of their games. On the opposite side we can find the engine modules, which are written in C++ and compiled to native modules. At runtime, the Python interpreter found that the core of Panda3D loads these modules and lets us make calls into them to control the engine and the game running on it.
This programming model combines the best of both of these programming worlds. While the performance critical parts are implemented in C++, gameplay programmers do not know any of the advanced stuff going on under the hood to get things done. Instead, they are able to use Python, an expressive and easy to learn programming language, for using Panda3D's great features. This also allows the engine developers to work on the internals of Panda3D while gameplay programmers are able to concentrate on creating interesting games.
While this split between application and gameplay code works really well, nothing keeps us from using the Panda3D programming libraries and writing application side code in C++. There' s nothing wrong with coding our games in Python, and in general it is the path to follow with Panda3D. But the possibility to use C++ is there, so we shouldn't omit discussing this topic.
In this recipe we will configure Visual Studio 2008 for compiling Panda3D C++ projects on Windows. Panda3D is a cross-platform game engine and other compilers like gcc and alternative IDEs like KDevelop might as well be used for writing C++ programs that link to the Panda3D libraries but within the context of this book, we will be looking at how things are working on the Windows platform.
Getting ready
This recipe assumes that Visual Studio 2008 is already installed on your system. If not, you can download Visual C++ 2008 Express Edition from www.microsoft.com/express/Downloads/ for free. Some restrictions apply to this free edition, but all recipes in this book are tested to work with this version of Visual Studio.
Note
Although technically very similar, the Express and full editions of Visual Studio do differ in several ways. Some menus, options, and functions of the full versions are not available in the free Express edition. So if you are looking for help online you should always clearly state which version you are using.
How to do it...
The following tasks will help you to configure Visual Studio 2008 for developing Panda3D projects:
- In a text editor of your choice, create a new file and paste the following code:
<?xml version="1.0" encoding="Windows-1252"?> <VisualStudioPropertySheet ProjectType="Visual C++" Version="8.00" Name="PandaSettings" > <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories=""C:\Panda3D-1.7.0\python\include";"C:\Panda3D-1.7.0\include"" /> <Tool Name="VCLinkerTool" AdditionalDependencies="libp3framework.lib libpanda.lib libpandafx.lib libpandaexpress.lib libp3dtool.lib libp3dtoolconfig.lib libp3pystub.lib libp3direct.lib" AdditionalLibraryDirectories=""C:\Panda3D-1.7.0\python\libs";"C:\Panda3D-1.7.0\lib"" /> </VisualStudioPropertySheet>
- Save it as
PandaSettings.vsprops
in a directory of your choice. - Start Visual Studio 2008 or Visual C++ 2008 Express and create a new C++ project.
- Open the Property Manager, which is located in the same pane as the Solution Explorer and the Class View by default. If you can't find it this way, click View | Property Manager in the main menu.
- Right-click the item Release | Win32 and select Add Existing Property Sheet... from the popup menu.
- Locate and select the
PandaSettings.vsprops
file.
How it works...
In this recipe we set all the options for using Panda3D using a feature of Visual Studio called Property Sheets, which allow you to configure each build target of your project independently and in a reusable way.
Property Sheet settings are stored using XML, as you can see in the previous sample code. Let's have a look at the data stored in PandaSettings.vsprops
:
Following the XML header and the opening tag of the property sheet, we can see two <Tool/>
tags, the first of which is adding the required include paths to the header search paths. The second <Tool/>
tag instructs the linker to use the listed library files when it is generating the executable, as well as where it will need to look for these files.
There's more...
You might have noticed that we only configured the release target in this recipe. The reason for this is that the recipe is aimed at the precompiled Panda3D SDK, which only includes the files needed to produce release builds.
Note
If you want to create debug builds you will definitely need to compile Panda3D yourself and configure your debug target in the way shown in this recipe (but don't forget to modify the search paths accordingly!).
Also, you don't have to use Property Sheets to configure include directories and linked libraries. You may also right-click the project node in the project explorer, click Properties and then click Configuration Properties | Properties | C++ in the tree of configuration categories to then fill in the include directories in the Additional Include Directories field in the right pane of the window.
To configure the linker, choose Configuration Properties | Properties | Linker in the same window as previously described and fill in the library file names into the Additional Dependencies and Additional Library Directories fields.
- JasperReports for Java Developers
- AutoCAD 2017實用教程
- Visio圖形設計從新手到高手(兼容版·第2版)
- Photoshop后期強:數碼攝影后期完全寶典
- 中文版CorelDRAW X7基礎培訓教程(移動學習版)
- Microsoft BizTalk Server 2010 Patterns
- Plone 3 Multimedia
- COSPLAY的后期藝術:Lightroom+Photoshop修圖技法攻略
- iPhone JavaScript Cookbook
- Implementing SugarCRM 5.x
- UI功夫:PC和APP界面設計全流程圖解
- Getting Started with Oracle BPM Suite 11gR1 – A Hands/On Tutorial
- Professional Azure SQL Database Administration
- UML 2.0 in Action: A project/based tutorial
- 計算機圖形制作CorelDRAW X6項目教程