Home    Features    Download    Screenshots    Manual    Reference    Forums    License    Contact   
 
  Panda3D Manual: Starting Panda3D (CXX)
  <<prev top next>>     

To start Panda3D, create a text file and save it with a .cxx extension. PSPad is a good text-editor with C++ highlighting, but any text editor will work. Enter the following text into your C++ file:

#include "pandaFramework.h"
#include "pandaSystem.h"

PandaFramework framework;

int main(int argc, char *argv[]) {
    //open a new window 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 only needs to be called 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.

To run your program, follow the compile steps explained on this page.

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

  <<prev top next>>     
.
screenshot
Angels Fall First: the Second Antarean War
screenshot
Psychedelic Flythrough of the Mind of a Computer
screenshot
Psychedelic Flythrough of the Mind of a Computer