Search code examples
c++panda3d

using panda3d without graphic stuff in c++?


I'm trying to write a windowless panda3d program, as a dedicated server. And I don't know how to use panda3d without creating any graphic stuff.

I have tried this:

load_prc_file_data("", "window-type none"); // do not effect.
load_prc_file_data("", "window-type offscreen"); // cause errors while running PandaFramework::open_window();

Actually I posted this on Panda3d Forums
And the only one answered told me not to do PandaFramework::open_window(); But in panda3d-cpp I don't know how to work without a WindowFramework, to be honest, I don't even know if the program works correctly.

Currently using: Panda3d1.9.2 Qt5.7.0 MSVC2015 Windows10SDK

Full core of .pro file:

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
INCLUDEPATH += "G:/Panda3D-1.9.2/include"
INCLUDEPATH += "G:/Panda3D-1.9.2/python/include"
LIBS += "G:/Panda3D-1.9.2/python/libs/python27.lib"
LIBS += "G:/Panda3D-1.9.2/lib/libp3framework.lib"
LIBS += "G:/Panda3D-1.9.2/lib/libpanda.lib"
LIBS += "G:/Panda3D-1.9.2/lib/libpandafx.lib"
LIBS += "G:/Panda3D-1.9.2/lib/libpandaexpress.lib"
LIBS += "G:/Panda3D-1.9.2/lib/libp3dtool.lib"
LIBS += "G:/Panda3D-1.9.2/lib/libp3dtoolconfig.lib"
LIBS += "G:/Panda3D-1.9.2/lib/libp3pystub.lib"
LIBS += "G:/Panda3D-1.9.2/lib/libp3direct.lib"

Full core of .cpp file:

#include <pandaFramework.h>
#include <pandaSystem.h>
#include <load_prc_file.h>
int main(int argc, char *argv[])
{
    PandaFramework pFramework;
    pFramework.open_framework(argc, argv);
    load_prc_file_data("", "window-type offscreen"); // cause errors
    WindowFramework *pWindow = pFramework.open_window();
    pFramework.main_loop();
    pFramework.close_framework();
    return 0;
}

Could somebody help me about this?


Solution

  • It's quite simple: if you don't want to open a window, don't call open_window. You'll still have access to the AsyncTaskManager::get_global_ptr() for scheduling tasks, to Loader for loading models, and you can create a scene graph by just creating a NodePath(new PandaNode("root")) and attaching objects to it, etc.

    The window-type .prc variable has no effect in PandaFramework, since creating a window is an explicit operation there.