Although this book is very Python-centric, we should not forget that the core of Panda3D is written in C++. Additionally, it is possible to extend the engine with our own native libraries. Not only that, but we're even able to drop Python and write our games in pure C++.
Even if we intend to write our games completely in Python, there might be this one occasion coming up in the future where we wished we had read the recipe about using the C++ debugger of Visual Studio 2008. The following recipe will prepare us for this situation, even if it is unlikely to occur.
In this recipe, you are going to debug the C++ code you created in Creating a scene using C++ found in Chapter 2, Creating and Building Scenes. For this to work, you need to add the property sheet containing your project settings to the Debug configuration just as you did for the Release configuration.
To be able to debug the code of the Panda3D engine on top of your own source code, you will need a debug build of the engine. If you want to use the release runtime from the installer package and just want to debug your own code, you need to apply the following workaround to be able to produce a debug build of your program:
python26_d.lib
. python26.lib
.The Visual Studio 2008 C++ debugger is a powerful tool. Let's see what can be done with it:
main.cpp
.Compared to the textmode debugger for Python, presented in the recipe found right before this one, the workflow doesn't differ too much. Basically, it's only the interface that differs drastically.
What we do with the tool is absolutely the same though. We set a breakpoint, define conditions that need to be fulfilled for triggering it, and create an action that prints a diagnostic message to the output window. While we are stepping through the code, we are watching variables as they change in the Autos and Locals windows. The Call Stack window shows us how we got to where we currently are in the program flow, the Breakpoints window is there to manage the breakpoints that are possibly scattered throughout the code of our game or library, and the Output window prints diagnostics and log messages.