Panda3D Manual: Starting Panda3D

Creating a New Panda3D Application

To start Panda3D, create a text file and save it with a .cxx extension. Any text editor will work. Enter the following text into your C++ file:

#include "pandaFramework.h"
#include "pandaSystem.h"
 
int main(int argc, char *argv[]) {
//open a new window framework
PandaFramework framework;
framework.open_framework(argc, argv);
//set the window title to My Panda3D Window
framework.set_window_title("My Panda3D Window");
//open the window
WindowFramework *window = framework.open_window();
 
//here is room for your own code
 
//do the main loop, equal to run() in python
framework.main_loop();
//close the window framework
framework.close_framework();
return (0);
}

For information about the Window Framework to open a window, click here.

pandaFramework.h and pandaSystem.h load most of the Panda3D modules. The main_loop() subroutine contains the Panda3D main loop. It renders a frame, handles the background tasks, and then repeats. It does not normally return, so it needs to be called only once and must be the last line in your script. In this particular example, there will be nothing to render, so you should expect a window containing an empty grey area.

Running the Program

The steps required to build and run your program were already explained on Getting Started with your Development Environment.

If Panda3D has been installed properly, a gray window titled My Panda3D Window will appear when you run your program. There is nothing we can do with this window, but that will change shortly.