diff --git a/direct/src/plugin_standalone/Sources.pp b/direct/src/plugin_standalone/Sources.pp index a6d462a1bc..ec55cf7d7b 100644 --- a/direct/src/plugin_standalone/Sources.pp +++ b/direct/src/plugin_standalone/Sources.pp @@ -19,7 +19,7 @@ #define OSX_SYS_FRAMEWORKS Foundation AppKit #define SOURCES \ - panda3d.cxx + panda3d.cxx panda3d.h panda3d.I #define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib diff --git a/direct/src/plugin_standalone/panda3d.I b/direct/src/plugin_standalone/panda3d.I new file mode 100755 index 0000000000..ec049a6324 --- /dev/null +++ b/direct/src/plugin_standalone/panda3d.I @@ -0,0 +1,26 @@ +// Filename: panda3d.I +// Created by: drose (30Jun09) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: Panda3D::URLGetter::get_instance +// Access: Public +// Description: Returns the P3D_instance associated with this +// URLGetter. +//////////////////////////////////////////////////////////////////// +P3D_instance *Panda3D::URLGetter:: +get_instance() { + return _instance; +} + diff --git a/direct/src/plugin_standalone/panda3d.h b/direct/src/plugin_standalone/panda3d.h new file mode 100755 index 0000000000..1b9adc3766 --- /dev/null +++ b/direct/src/plugin_standalone/panda3d.h @@ -0,0 +1,90 @@ +// Filename: panda3d.h +// Created by: drose (30Jun09) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef PANDA3D_H +#define PANDA3D_H + +// This program must link with Panda for HTTPClient support. This +// means it probably should be built with LINK_ALL_STATIC defined, so +// we won't have to deal with confusing .dll or .so files that might +// compete on the disk with the dynamically-loaded versions. There's +// no competition in memory address space, though, because +// p3d_plugin--the only file we dynamically link in--doesn't itself +// link with Panda. + +#include "pandabase.h" +#include "p3d_plugin.h" +#include "httpChannel.h" +#include "ramfile.h" +#include "pset.h" + +//////////////////////////////////////////////////////////////////// +// Class : Panda3D +// Description : A standalone program that invokes the Panda3D plugin +// to launch .p3d files. +//////////////////////////////////////////////////////////////////// +class Panda3D { +public: + Panda3D(); + + int run(int argc, char *argv[]); + +private: + void run_getters(); + void handle_request(P3D_request *request); + void make_parent_window(P3D_window_handle &parent_window, + int win_width, int win_height); + + P3D_instance *create_instance(const string &arg, P3D_window_type window_type, + int win_x, int win_y, int win_width, + int win_height, + P3D_window_handle parent_window, + const Filename &output_filename); + void delete_instance(P3D_instance *instance); + + void usage(); + bool parse_int_pair(char *arg, int &x, int &y); + +private: + typedef pset Instances; + Instances _instances; + + // This nested class keeps track of active URL requests. + class URLGetter { + public: + URLGetter(P3D_instance *instance, int unique_id, + const URLSpec &url, const string &post_data); + + bool run(); + inline P3D_instance *get_instance(); + + private: + P3D_instance *_instance; + int _unique_id; + URLSpec _url; + string _post_data; + + PT(HTTPChannel) _channel; + Ramfile _rf; + size_t _bytes_sent; + }; + + typedef pset URLGetters; + URLGetters _url_getters; +}; + +#include "panda3d.I" + +#endif +