From 562296e694d4b91835afd4697ef34c6172a2045c Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Feb 2012 12:20:16 +0000 Subject: [PATCH] add support for the libRocket debugger --- dtool/Config.pp | 3 +- dtool/LocalSetup.pp | 5 +++- makepanda/makepanda.py | 25 +++++++++++----- panda/src/rocket/rocketRegion.cxx | 47 +++++++++++++++++++++++++++++++ panda/src/rocket/rocketRegion.h | 4 +++ 5 files changed, 75 insertions(+), 9 deletions(-) diff --git a/dtool/Config.pp b/dtool/Config.pp index fe489fc3d8..3abec127d9 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -1108,8 +1108,9 @@ // libRocket is a GUI library #define ROCKET_IPATH /usr/local/include #define ROCKET_LPATH /usr/local/lib -#define ROCKET_LIBS RocketCore boost_python +#define ROCKET_LIBS RocketCore RocketDebugger boost_python #defer HAVE_ROCKET $[libtest $[ROCKET_LPATH],$[ROCKET_LIBS]] +#defer HAVE_ROCKET_DEBUGGER $[< $[OPTIMIZE],4] // Unset this if you built libRocket without Python bindings #defer HAVE_ROCKET_PYTHON $[and $[HAVE_ROCKET],$[HAVE_PYTHON]] diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index 45dfa727af..825bce2758 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -316,7 +316,10 @@ $[cdefine STDFLOAT_DOUBLE] $[cdefine HAVE_MAYA] $[cdefine MAYA_PRE_5_0] -/* Define if we have libRocket available and built with Python support. */ +/* Define if we have libRocket available and built with the Rocket Debugger. */ +$[cdefine HAVE_ROCKET_DEBUGGER] + +/* Define if we have built libRocket available and built with Python support. */ $[cdefine HAVE_ROCKET_PYTHON] /* Define if we have SoftImage available. */ diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index f974d8126e..5821952c55 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -506,9 +506,12 @@ if (COMPILER=="MSVC"): if (PkgSkip("FFMPEG")==0): LibName("FFMPEG", GetThirdpartyDir() + "ffmpeg/lib/avformat.lib") if (PkgSkip("FFMPEG")==0): LibName("FFMPEG", GetThirdpartyDir() + "ffmpeg/lib/avutil.lib") if (PkgSkip("SWSCALE")==0): LibName("SWSCALE", GetThirdpartyDir() + "ffmpeg/lib/swscale.lib") - if (PkgSkip("ROCKET")==0): LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketCore.lib") - if (PkgSkip("ROCKET")==0): LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketControls.lib") - if (PkgSkip("ROCKET")==0): LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/boost_python-vc90-mt-1_48.lib") + if (PkgSkip("ROCKET")==0): + LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketCore.lib") + LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketControls.lib") + LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/boost_python-vc90-mt-1_48.lib") + if (GetOptimize() <= 3): + LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketDebugger.lib") if (PkgSkip("OPENAL")==0): if (os.path.exists(GetThirdpartyDir() + "openal/lib/pandaopenal32.lib")): LibName("OPENAL", GetThirdpartyDir() + "openal/lib/pandaopenal32.lib") @@ -627,11 +630,15 @@ if (COMPILER=="LINUX"): SmartPkgEnable("TIFF", "", ("tiff"), "tiff.h") SmartPkgEnable("VRPN", "", ("vrpn", "quat"), ("vrpn", "quat.h", "vrpn/vrpn_Types.h")) SmartPkgEnable("BULLET", "bullet", ("BulletSoftBody", "BulletDynamics", "BulletCollision", "LinearMath"), ("bullet", "bullet/btBulletDynamicsCommon.h")) - if sys.platform == "darwin": + + rocket_libs = ("RocketCore", "RocketControls") + if (GetOptimize() <= 3): + rocket_libs += ("RocketDebugger",) + if (sys.platform != "darwin"): # We use a statically linked libboost_python on OSX - SmartPkgEnable("ROCKET", "", ("RocketCore", "RocketControls"), "Rocket/Core.h") - else: - SmartPkgEnable("ROCKET", "", ("RocketCore", "RocketControls", "boost_python"), "Rocket/Core.h") + rocket_libs += ("boost_python",) + SmartPkgEnable("ROCKET", "", rocket_libs, "Rocket/Core.h") + SmartPkgEnable("GTK2", "gtk+-2.0") SmartPkgEnable("JPEG", "", ("jpeg"), "jpeglib.h") SmartPkgEnable("OPENSSL", "openssl", ("ssl", "crypto"), ("openssl/ssl.h", "openssl/crypto.h")) @@ -1733,6 +1740,7 @@ DTOOL_CONFIG=[ ("HAVE_FCOLLADA", 'UNDEF', 'UNDEF'), ("HAVE_OPENAL_FRAMEWORK", 'UNDEF', 'UNDEF'), ("HAVE_ROCKET_PYTHON", '1', '1'), + ("HAVE_ROCKET_DEBUGGER", 'UNDEF', 'UNDEF'), ("PRC_SAVE_DESCRIPTIONS", '1', '1'), # ("_SECURE_SCL", '0', 'UNDEF'), # ("_SECURE_SCL_THROWS", '0', 'UNDEF'), @@ -1828,6 +1836,9 @@ def WriteConfigSettings(): if (PkgSkip("PYTHON") != 0): dtool_config["HAVE_ROCKET_PYTHON"] = 'UNDEF' + if (GetOptimize() <= 3): + dtool_config["HAVE_ROCKET_DEBUGGER"] = '1' + if (GetOptimize() <= 3): if (dtool_config["HAVE_NET"] != 'UNDEF'): dtool_config["DO_PSTATS"] = '1' diff --git a/panda/src/rocket/rocketRegion.cxx b/panda/src/rocket/rocketRegion.cxx index 7186db9726..ee2c2c2e3d 100644 --- a/panda/src/rocket/rocketRegion.cxx +++ b/panda/src/rocket/rocketRegion.cxx @@ -17,6 +17,10 @@ #include "orthographicLens.h" #include "pStatTimer.h" +#ifdef HAVE_ROCKET_DEBUGGER +#include +#endif + TypeHandle RocketRegion::_type_handle; //////////////////////////////////////////////////////////////////// @@ -127,3 +131,46 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, trav->end_traverse(); } + +//////////////////////////////////////////////////////////////////// +// Function: RocketRegion::init_debugger +// Access: Published +// Description: Initializes the libRocket debugger. This will +// return false if the debugger failed to initialize, +// or if support for the debugger has not been built +// in (for example in an optimize=4 build). +//////////////////////////////////////////////////////////////////// +bool RocketRegion:: +init_debugger() { +#ifdef HAVE_ROCKET_DEBUGGER + return Rocket::Debugger::Initialise(_context); +#else + return false; +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: RocketRegion::set_debugger_visible +// Access: Published +// Description: Sets whether the debugger should be visible. +//////////////////////////////////////////////////////////////////// +void RocketRegion:: +set_debugger_visible(bool visible) { +#ifdef HAVE_ROCKET_DEBUGGER + Rocket::Debugger::SetVisible(visible); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: RocketRegion::is_debugger_visible +// Access: Published +// Description: Returns true if the debugger is visible. +//////////////////////////////////////////////////////////////////// +bool RocketRegion:: +is_debugger_visible() const { +#ifdef HAVE_ROCKET_DEBUGGER + return Rocket::Debugger::IsVisible(); +#else + return false; +#endif +} diff --git a/panda/src/rocket/rocketRegion.h b/panda/src/rocket/rocketRegion.h index 7e66f97965..cb297ec27a 100644 --- a/panda/src/rocket/rocketRegion.h +++ b/panda/src/rocket/rocketRegion.h @@ -53,6 +53,10 @@ PUBLISHED: INLINE void set_input_handler(RocketInputHandler *handler); INLINE RocketInputHandler *get_input_handler() const; + bool init_debugger(); + void set_debugger_visible(bool visible); + bool is_debugger_visible() const; + private: RocketRenderInterface _interface; Rocket::Core::Context* _context;