Browse Source

rocket: remove libRocket support and sample program

libRocket is unmaintained and does not support Python 3, and since Python 2.7 is EOL, there is no longer any point for us to keep supporting it.
rdb 6 years ago
parent
commit
da8ba5de17
38 changed files with 0 additions and 2916 deletions
  1. 0 1
      doc/INSTALL
  2. 0 25
      makepanda/installer.nsi
  3. 0 60
      makepanda/makepanda.py
  4. 0 8
      panda/src/pandabase/pandasymbols.h
  5. 0 79
      panda/src/rocket/config_rocket.cxx
  6. 0 24
      panda/src/rocket/config_rocket.h
  7. 0 6
      panda/src/rocket/p3rocket_composite1.cxx
  8. 0 145
      panda/src/rocket/rocketFileInterface.cxx
  9. 0 50
      panda/src/rocket/rocketFileInterface.h
  10. 0 348
      panda/src/rocket/rocketInputHandler.cxx
  11. 0 82
      panda/src/rocket/rocketInputHandler.h
  12. 0 68
      panda/src/rocket/rocketRegion.I
  13. 0 182
      panda/src/rocket/rocketRegion.cxx
  14. 0 87
      panda/src/rocket/rocketRegion.h
  15. 0 50
      panda/src/rocket/rocketRegion_ext.cxx
  16. 0 37
      panda/src/rocket/rocketRegion_ext.h
  17. 0 348
      panda/src/rocket/rocketRenderInterface.cxx
  18. 0 75
      panda/src/rocket/rocketRenderInterface.h
  19. 0 54
      panda/src/rocket/rocketSystemInterface.cxx
  20. 0 32
      panda/src/rocket/rocketSystemInterface.h
  21. BIN
      samples/rocket-console/assets/Perfect DOS VGA 437.ttf
  22. 0 38
      samples/rocket-console/assets/console.rcss
  23. 0 11
      samples/rocket-console/assets/console.rml
  24. 0 1
      samples/rocket-console/assets/dos437.txt
  25. 0 54
      samples/rocket-console/assets/loading.rml
  26. 0 18
      samples/rocket-console/assets/modenine.nfo
  27. BIN
      samples/rocket-console/assets/modenine.ttf
  28. BIN
      samples/rocket-console/assets/monitor.egg.pz
  29. 0 12
      samples/rocket-console/assets/monitor.txt
  30. 0 44
      samples/rocket-console/assets/rkt.rcss
  31. 0 316
      samples/rocket-console/assets/takeyga_kb.egg
  32. BIN
      samples/rocket-console/assets/tex/takeyga_kb_diffuse.dds
  33. BIN
      samples/rocket-console/assets/tex/takeyga_kb_normal.dds
  34. BIN
      samples/rocket-console/assets/tex/takeyga_kb_specular.dds
  35. 0 56
      samples/rocket-console/assets/window.rcss
  36. 0 42
      samples/rocket-console/assets/window.rml
  37. 0 153
      samples/rocket-console/console.py
  38. 0 410
      samples/rocket-console/main.py

+ 0 - 1
doc/INSTALL

@@ -193,7 +193,6 @@ it will show you the available command-line options:
   --use-mfc         --no-mfc       (enable/disable use of MFC)
   --use-mfc         --no-mfc       (enable/disable use of MFC)
   --use-wx          --no-wx        (enable/disable use of WX)
   --use-wx          --no-wx        (enable/disable use of WX)
   --use-fltk        --no-fltk      (enable/disable use of FLTK)
   --use-fltk        --no-fltk      (enable/disable use of FLTK)
-  --use-rocket      --no-rocket    (enable/disable use of ROCKET)
   --use-carbon      --no-carbon    (enable/disable use of CARBON)
   --use-carbon      --no-carbon    (enable/disable use of CARBON)
   --use-cocoa       --no-cocoa     (enable/disable use of COCOA)
   --use-cocoa       --no-cocoa     (enable/disable use of COCOA)
   --use-x11         --no-x11       (enable/disable use of X11)
   --use-x11         --no-x11       (enable/disable use of X11)

+ 0 - 25
makepanda/installer.nsi

@@ -79,7 +79,6 @@ LangString DESC_SecFFMpeg ${LANG_ENGLISH} "Support for decoding video and audio
 LangString DESC_SecBullet ${LANG_ENGLISH} "Support for the Bullet physics engine."
 LangString DESC_SecBullet ${LANG_ENGLISH} "Support for the Bullet physics engine."
 LangString DESC_SecODE ${LANG_ENGLISH} "Support for the Open Dynamics Engine to implement physics."
 LangString DESC_SecODE ${LANG_ENGLISH} "Support for the Open Dynamics Engine to implement physics."
 LangString DESC_SecPhysX ${LANG_ENGLISH} "Support for NVIDIA PhysX to implement physics."
 LangString DESC_SecPhysX ${LANG_ENGLISH} "Support for NVIDIA PhysX to implement physics."
-LangString DESC_SecRocket ${LANG_ENGLISH} "Support for the libRocket GUI library.  This is an optional library that offers an HTML/CSS-like approach to creating user interfaces."
 LangString DESC_SecTools ${LANG_ENGLISH} "Useful tools and model converters to help with Panda3D development.  Recommended."
 LangString DESC_SecTools ${LANG_ENGLISH} "Useful tools and model converters to help with Panda3D development.  Recommended."
 LangString DESC_SecGroupPython ${LANG_ENGLISH} "Contains modules that provide Python support for Panda3D."
 LangString DESC_SecGroupPython ${LANG_ENGLISH} "Contains modules that provide Python support for Panda3D."
 LangString DESC_SecPyShared ${LANG_ENGLISH} "Contains the common Python code used by the Panda3D Python bindings."
 LangString DESC_SecPyShared ${LANG_ENGLISH} "Contains the common Python code used by the Panda3D Python bindings."
@@ -116,7 +115,6 @@ var MANPAGE
 !insertmacro !defineifexist HAVE_BULLET "${BUILT}\bin\libpandabullet.dll"
 !insertmacro !defineifexist HAVE_BULLET "${BUILT}\bin\libpandabullet.dll"
 !insertmacro !defineifexist HAVE_ODE "${BUILT}\bin\libpandaode.dll"
 !insertmacro !defineifexist HAVE_ODE "${BUILT}\bin\libpandaode.dll"
 !insertmacro !defineifexist HAVE_PHYSX "${BUILT}\bin\libpandaphysx.dll"
 !insertmacro !defineifexist HAVE_PHYSX "${BUILT}\bin\libpandaphysx.dll"
-!insertmacro !defineifexist HAVE_ROCKET "${BUILT}\bin\libp3rocket.dll"
 !insertmacro !defineifexist HAVE_SAMPLES "${SOURCE}\samples"
 !insertmacro !defineifexist HAVE_SAMPLES "${SOURCE}\samples"
 !insertmacro !defineifexist HAVE_MAX_PLUGINS "${BUILT}\plugins\*.dlo"
 !insertmacro !defineifexist HAVE_MAX_PLUGINS "${BUILT}\plugins\*.dlo"
 !insertmacro !defineifexist HAVE_MAYA_PLUGINS "${BUILT}\plugins\*.mll"
 !insertmacro !defineifexist HAVE_MAYA_PLUGINS "${BUILT}\plugins\*.mll"
@@ -182,14 +180,6 @@ var MANPAGE
             SkipPhysXPyd:
             SkipPhysXPyd:
         !endif
         !endif
 
 
-        !ifdef HAVE_ROCKET
-            SectionGetFlags ${SecRocket} $R0
-            IntOp $R0 $R0 & ${SF_SELECTED}
-            StrCmp $R0 ${SF_SELECTED} 0 SkipRocketPyd
-            File /nonfatal /r "${BUILT}\panda3d\rocket${EXT_SUFFIX}"
-            SkipRocketPyd:
-        !endif
-
         SetOutPath $INSTDIR\pandac\input
         SetOutPath $INSTDIR\pandac\input
         File /r "${BUILT}\pandac\input\*"
         File /r "${BUILT}\pandac\input\*"
         SetOutPath $INSTDIR\Pmw
         SetOutPath $INSTDIR\Pmw
@@ -342,18 +332,6 @@ SectionGroup "Panda3D Libraries"
         File /nonfatal /r "${BUILT}\bin\cudart*.dll"
         File /nonfatal /r "${BUILT}\bin\cudart*.dll"
     SectionEnd
     SectionEnd
     !endif
     !endif
-
-    !ifdef HAVE_ROCKET
-    Section "libRocket GUI" SecRocket
-        SectionIn 1 2
-
-        SetOutPath "$INSTDIR\bin"
-        File "${BUILT}\bin\libp3rocket.dll"
-        File /nonfatal /r "${BUILT}\bin\Rocket*.dll"
-        File /nonfatal /r "${BUILT}\bin\_rocket*.pyd"
-        File /nonfatal /r "${BUILT}\bin\boost_python*.dll"
-    SectionEnd
-    !endif
 SectionGroupEnd
 SectionGroupEnd
 
 
 Section "Tools and utilities" SecTools
 Section "Tools and utilities" SecTools
@@ -917,9 +895,6 @@ SectionEnd
   !ifdef HAVE_PHYSX
   !ifdef HAVE_PHYSX
     !insertmacro MUI_DESCRIPTION_TEXT ${SecPhysX} $(DESC_SecPhysX)
     !insertmacro MUI_DESCRIPTION_TEXT ${SecPhysX} $(DESC_SecPhysX)
   !endif
   !endif
-  !ifdef HAVE_ROCKET
-    !insertmacro MUI_DESCRIPTION_TEXT ${SecRocket} $(DESC_SecRocket)
-  !endif
   !insertmacro MUI_DESCRIPTION_TEXT ${SecTools} $(DESC_SecTools)
   !insertmacro MUI_DESCRIPTION_TEXT ${SecTools} $(DESC_SecTools)
   !insertmacro MUI_DESCRIPTION_TEXT ${SecGroupPython} $(DESC_SecGroupPython)
   !insertmacro MUI_DESCRIPTION_TEXT ${SecGroupPython} $(DESC_SecGroupPython)
   !insertmacro MUI_DESCRIPTION_TEXT ${SecPyShared} $(DESC_SecPyShared)
   !insertmacro MUI_DESCRIPTION_TEXT ${SecPyShared} $(DESC_SecPyShared)

+ 0 - 60
makepanda/makepanda.py

@@ -85,7 +85,6 @@ PkgListSet(["PYTHON", "DIRECT",                        # Python support
   "ARTOOLKIT", "OPENCV", "DIRECTCAM", "VISION",        # Augmented Reality
   "ARTOOLKIT", "OPENCV", "DIRECTCAM", "VISION",        # Augmented Reality
   "GTK2",                                              # GTK2 is used for PStats on Unix
   "GTK2",                                              # GTK2 is used for PStats on Unix
   "MFC", "WX", "FLTK",                                 # Used for web plug-in only
   "MFC", "WX", "FLTK",                                 # Used for web plug-in only
-  "ROCKET",                                            # GUI libraries
   "COCOA",                                             # Mac OS X toolkits
   "COCOA",                                             # Mac OS X toolkits
   "X11",                                               # Unix platform support
   "X11",                                               # Unix platform support
   "PANDATOOL", "PVIEW", "DEPLOYTOOLS",                 # Toolchain
   "PANDATOOL", "PVIEW", "DEPLOYTOOLS",                 # Toolchain
@@ -667,13 +666,6 @@ if (COMPILER == "MSVC"):
             LibName("SQUISH",   GetThirdpartyDir() + "squish/lib/squishd.lib")
             LibName("SQUISH",   GetThirdpartyDir() + "squish/lib/squishd.lib")
         else:
         else:
             LibName("SQUISH",   GetThirdpartyDir() + "squish/lib/squish.lib")
             LibName("SQUISH",   GetThirdpartyDir() + "squish/lib/squish.lib")
-    if (PkgSkip("ROCKET")==0):
-        LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketCore.lib")
-        LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketControls.lib")
-        if (PkgSkip("PYTHON")==0):
-            LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/" + SDK["PYTHONVERSION"] + "/boost_python-vc100-mt-1_54.lib")
-        if (GetOptimize() <= 3):
-            LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketDebugger.lib")
     if (PkgSkip("OPENAL")==0):
     if (PkgSkip("OPENAL")==0):
         LibName("OPENAL", GetThirdpartyDir() + "openal/lib/OpenAL32.lib")
         LibName("OPENAL", GetThirdpartyDir() + "openal/lib/OpenAL32.lib")
         if not os.path.isfile(GetThirdpartyDir() + "openal/bin/OpenAL32.dll"):
         if not os.path.isfile(GetThirdpartyDir() + "openal/bin/OpenAL32.dll"):
@@ -852,12 +844,6 @@ if (COMPILER=="GCC"):
         if os.path.isfile(irrxml):
         if os.path.isfile(irrxml):
             LibName("ASSIMP", irrxml)
             LibName("ASSIMP", irrxml)
 
 
-    rocket_libs = ("RocketCore", "RocketControls")
-    if (GetOptimize() <= 3):
-        rocket_libs += ("RocketDebugger",)
-    rocket_libs += ("boost_python",)
-    SmartPkgEnable("ROCKET",    "",          rocket_libs, "Rocket/Core.h")
-
     if not PkgSkip("PYTHON"):
     if not PkgSkip("PYTHON"):
         python_lib = SDK["PYTHONVERSION"]
         python_lib = SDK["PYTHONVERSION"]
         SmartPkgEnable("PYTHON", "", python_lib, (SDK["PYTHONVERSION"], SDK["PYTHONVERSION"] + "/Python.h"))
         SmartPkgEnable("PYTHON", "", python_lib, (SDK["PYTHONVERSION"], SDK["PYTHONVERSION"] + "/Python.h"))
@@ -925,8 +911,6 @@ if (COMPILER=="GCC"):
         LibName("GL", "-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
         LibName("GL", "-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
 
 
         # Temporary exceptions to removal of this flag
         # Temporary exceptions to removal of this flag
-        if not PkgSkip("ROCKET"):
-            LibName("ROCKET", "-undefined dynamic_lookup")
         if not PkgSkip("FFMPEG"):
         if not PkgSkip("FFMPEG"):
             LibName("FFMPEG", "-undefined dynamic_lookup")
             LibName("FFMPEG", "-undefined dynamic_lookup")
         if not PkgSkip("ASSIMP"):
         if not PkgSkip("ASSIMP"):
@@ -2275,8 +2259,6 @@ DTOOL_CONFIG=[
     ("HAVE_SQUISH",                    'UNDEF',                  'UNDEF'),
     ("HAVE_SQUISH",                    'UNDEF',                  'UNDEF'),
     ("HAVE_COCOA",                     'UNDEF',                  'UNDEF'),
     ("HAVE_COCOA",                     'UNDEF',                  'UNDEF'),
     ("HAVE_OPENAL_FRAMEWORK",          'UNDEF',                  'UNDEF'),
     ("HAVE_OPENAL_FRAMEWORK",          'UNDEF',                  'UNDEF'),
-    ("HAVE_ROCKET_PYTHON",             '1',                      '1'),
-    ("HAVE_ROCKET_DEBUGGER",           'UNDEF',                  'UNDEF'),
     ("USE_TAU",                        'UNDEF',                  'UNDEF'),
     ("USE_TAU",                        'UNDEF',                  'UNDEF'),
     ("PRC_SAVE_DESCRIPTIONS",          '1',                      '1'),
     ("PRC_SAVE_DESCRIPTIONS",          '1',                      '1'),
 #    ("_SECURE_SCL",                    '0',                      'UNDEF'),
 #    ("_SECURE_SCL",                    '0',                      'UNDEF'),
@@ -2371,14 +2353,6 @@ def WriteConfigSettings():
     if (GetOptimize() <= 2 and GetTarget() == "windows"):
     if (GetOptimize() <= 2 and GetTarget() == "windows"):
         dtool_config["USE_DEBUG_PYTHON"] = '1'
         dtool_config["USE_DEBUG_PYTHON"] = '1'
 
 
-    # This should probably be more sophisticated, such as based
-    # on whether the libRocket Python modules are available.
-    if (PkgSkip("PYTHON") != 0):
-        dtool_config["HAVE_ROCKET_PYTHON"] = 'UNDEF'
-
-    if (GetOptimize() <= 3):
-        dtool_config["HAVE_ROCKET_DEBUGGER"] = '1'
-
     if (GetOptimize() <= 3):
     if (GetOptimize() <= 3):
         if (dtool_config["HAVE_NET"] != 'UNDEF'):
         if (dtool_config["HAVE_NET"] != 'UNDEF'):
             dtool_config["DO_PSTATS"] = '1'
             dtool_config["DO_PSTATS"] = '1'
@@ -3024,8 +2998,6 @@ CopyAllHeaders('panda/src/parametrics')
 CopyAllHeaders('panda/src/pgui')
 CopyAllHeaders('panda/src/pgui')
 CopyAllHeaders('panda/src/pnmimagetypes')
 CopyAllHeaders('panda/src/pnmimagetypes')
 CopyAllHeaders('panda/src/recorder')
 CopyAllHeaders('panda/src/recorder')
-if (PkgSkip("ROCKET")==0):
-    CopyAllHeaders('panda/src/rocket')
 if (PkgSkip("VRPN")==0):
 if (PkgSkip("VRPN")==0):
     CopyAllHeaders('panda/src/vrpn')
     CopyAllHeaders('panda/src/vrpn')
 CopyAllHeaders('panda/src/wgldisplay')
 CopyAllHeaders('panda/src/wgldisplay')
@@ -4098,38 +4070,6 @@ if (PkgSkip("VISION") == 0):
   PyTargetAdd('vision.pyd', input='libp3interrogatedb.dll')
   PyTargetAdd('vision.pyd', input='libp3interrogatedb.dll')
   PyTargetAdd('vision.pyd', input=COMMON_PANDA_LIBS)
   PyTargetAdd('vision.pyd', input=COMMON_PANDA_LIBS)
 
 
-#
-# DIRECTORY: panda/src/rocket/
-#
-
-if (PkgSkip("ROCKET") == 0):
-  OPTS=['DIR:panda/src/rocket', 'BUILDING:ROCKET', 'ROCKET', 'PYTHON']
-  TargetAdd('p3rocket_composite1.obj', opts=OPTS, input='p3rocket_composite1.cxx')
-
-  TargetAdd('libp3rocket.dll', input='p3rocket_composite1.obj')
-  TargetAdd('libp3rocket.dll', input=COMMON_PANDA_LIBS)
-  TargetAdd('libp3rocket.dll', opts=OPTS)
-
-  OPTS=['DIR:panda/src/rocket', 'ROCKET', 'RTTI', 'EXCEPTIONS']
-  IGATEFILES=GetDirectoryContents('panda/src/rocket', ["rocketInputHandler.h",
-    "rocketInputHandler.cxx", "rocketRegion.h", "rocketRegion.cxx", "rocketRegion_ext.h"])
-  TargetAdd('libp3rocket.in', opts=OPTS, input=IGATEFILES)
-  TargetAdd('libp3rocket.in', opts=['IMOD:panda3d.rocket', 'ILIB:libp3rocket', 'SRCDIR:panda/src/rocket'])
-
-  PyTargetAdd('p3rocket_rocketRegion_ext.obj', opts=OPTS, input='rocketRegion_ext.cxx')
-
-  PyTargetAdd('rocket_module.obj', input='libp3rocket.in')
-  PyTargetAdd('rocket_module.obj', opts=OPTS)
-  PyTargetAdd('rocket_module.obj', opts=['IMOD:panda3d.rocket', 'ILIB:rocket', 'IMPORT:panda3d.core'])
-
-  PyTargetAdd('rocket.pyd', input='rocket_module.obj')
-  PyTargetAdd('rocket.pyd', input='libp3rocket_igate.obj')
-  PyTargetAdd('rocket.pyd', input='p3rocket_rocketRegion_ext.obj')
-  PyTargetAdd('rocket.pyd', input='libp3rocket.dll')
-  PyTargetAdd('rocket.pyd', input='libp3interrogatedb.dll')
-  PyTargetAdd('rocket.pyd', input=COMMON_PANDA_LIBS)
-  PyTargetAdd('rocket.pyd', opts=['ROCKET'])
-
 #
 #
 # DIRECTORY: panda/src/p3skel
 # DIRECTORY: panda/src/p3skel
 #
 #

+ 0 - 8
panda/src/pandabase/pandasymbols.h

@@ -571,14 +571,6 @@
   #define EXPTP_PANDAX11 IMPORT_TEMPL
   #define EXPTP_PANDAX11 IMPORT_TEMPL
 #endif
 #endif
 
 
-#ifdef BUILDING_ROCKET
-  #define EXPCL_ROCKET EXPORT_CLASS
-  #define EXPTP_ROCKET EXPORT_TEMPL
-#else
-  #define EXPCL_ROCKET IMPORT_CLASS
-  #define EXPTP_ROCKET IMPORT_TEMPL
-#endif
-
 #ifdef BUILDING_TINYDISPLAY
 #ifdef BUILDING_TINYDISPLAY
   #define EXPCL_TINYDISPLAY EXPORT_CLASS
   #define EXPCL_TINYDISPLAY EXPORT_CLASS
   #define EXPTP_TINYDISPLAY EXPORT_TEMPL
   #define EXPTP_TINYDISPLAY EXPORT_TEMPL

+ 0 - 79
panda/src/rocket/config_rocket.cxx

@@ -1,79 +0,0 @@
-/**
- * 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."
- *
- * @file config_rocket.cxx
- * @author rdb
- * @date 2011-11-04
- */
-
-#include "config_rocket.h"
-#include "rocketFileInterface.h"
-#include "rocketInputHandler.h"
-#include "rocketRegion.h"
-#include "rocketSystemInterface.h"
-
-#include "pandaSystem.h"
-#include "dconfig.h"
-#include "default_font.h"
-
-// This is defined by both Panda and Rocket.
-#define Factory RocketFactory
-#include <Rocket/Core.h>
-#undef Factory
-
-#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_ROCKET)
-  #error Buildsystem error: BUILDING_ROCKET not defined
-#endif
-
-Configure(config_rocket);
-NotifyCategoryDef(rocket, "");
-
-ConfigureFn(config_rocket) {
-  init_librocket();
-}
-
-/**
- * Initializes the library.  This must be called at least once before any of
- * the functions or classes in this library can be used.  Normally it will be
- * called by the static initializers and need not be called explicitly, but
- * special cases exist.
- */
-void
-init_librocket() {
-  static bool initialized = false;
-  if (initialized) {
-    return;
-  }
-  initialized = true;
-
-  RocketInputHandler::init_type();
-  RocketRegion::init_type();
-
-  if (rocket_cat->is_debug()) {
-    rocket_cat->debug() << "Initializing libRocket library.\n";
-  }
-
-  RocketFileInterface* fi = new RocketFileInterface;
-  Rocket::Core::SetFileInterface(fi);
-
-  RocketSystemInterface* si = new RocketSystemInterface;
-  Rocket::Core::SetSystemInterface(si);
-
-  Rocket::Core::Initialise();
-
-  // Register that we have the libRocket system.
-  PandaSystem *ps = PandaSystem::get_global_ptr();
-  ps->add_system("libRocket");
-
-#ifdef COMPILE_IN_DEFAULT_FONT
-#ifdef HAVE_FREETYPE
-  // Load Panda's default compiled-in freetype font (Perspective Sans).
-  Rocket::Core::FontDatabase::LoadFontFace(default_font_data, default_font_size);
-#endif
-#endif
-}

+ 0 - 24
panda/src/rocket/config_rocket.h

@@ -1,24 +0,0 @@
-/**
- * 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."
- *
- * @file config_rocket.h
- * @author rdb
- * @date 2011-11-04
- */
-
-#ifndef CONFIG_ROCKET_H
-#define CONFIG_ROCKET_H
-
-#include "pandabase.h"
-#include "notifyCategoryProxy.h"
-
-NotifyCategoryDecl(rocket, EXPCL_ROCKET, EXPTP_ROCKET);
-
-extern EXPCL_ROCKET void init_librocket();
-
-#endif

+ 0 - 6
panda/src/rocket/p3rocket_composite1.cxx

@@ -1,6 +0,0 @@
-#include "config_rocket.cxx"
-#include "rocketFileInterface.cxx"
-#include "rocketInputHandler.cxx"
-#include "rocketRegion.cxx"
-#include "rocketRenderInterface.cxx"
-#include "rocketSystemInterface.cxx"

+ 0 - 145
panda/src/rocket/rocketFileInterface.cxx

@@ -1,145 +0,0 @@
-/**
- * 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."
- *
- * @file rocketFileInterface.cxx
- * @author rdb
- * @date 2011-11-03
- */
-
-#include "rocketFileInterface.h"
-#include "virtualFileSystem.h"
-
-/**
- * Constructs a RocketFileInterface for the given VFS, or the default if NULL
- * is given.
- */
-RocketFileInterface::
-RocketFileInterface(VirtualFileSystem *vfs) : _vfs(vfs) {
-  if (_vfs == nullptr) {
-    _vfs = VirtualFileSystem::get_global_ptr();
-  }
-}
-
-/**
- *
- */
-Rocket::Core::FileHandle RocketFileInterface::
-Open(const Rocket::Core::String& path) {
-  if (rocket_cat.is_debug()) {
-    rocket_cat.debug() << "Opening " << path.CString() << "\n";
-  }
-
-  Filename fn = Filename::from_os_specific(path.CString());
-
-  PT(VirtualFile) file = _vfs->get_file(fn);
-  if (file == nullptr) {
-    // failed?  Try model-path as a Panda-friendly fallback.
-    if (!_vfs->resolve_filename(fn, get_model_path())) {
-      rocket_cat.error() << "Could not resolve " << fn
-          << " along the model-path (currently: " << get_model_path() << ")\n";
-      return (Rocket::Core::FileHandle) nullptr;
-    }
-
-    file = _vfs->get_file(fn);
-    if (file == nullptr) {
-      rocket_cat.error() << "Failed to get " << fn << ", found on model-path\n";
-      return (Rocket::Core::FileHandle) nullptr;
-    }
-  }
-
-  std::istream *str = file->open_read_file(true);
-  if (str == nullptr) {
-    rocket_cat.error() << "Failed to open " << fn << " for reading\n";
-    return (Rocket::Core::FileHandle) nullptr;
-  }
-
-  VirtualFileHandle *handle = new VirtualFileHandle;
-  handle->_file = file;
-  handle->_stream = str;
-
-  // A FileHandle is actually just a void pointer.
-  return (Rocket::Core::FileHandle) handle;
-}
-
-/**
- *
- */
-void RocketFileInterface::
-Close(Rocket::Core::FileHandle file) {
-  VirtualFileHandle *handle = (VirtualFileHandle*) file;
-  if (handle == nullptr) {
-    return;
-  }
-
-  _vfs->close_read_file(handle->_stream);
-  delete handle;
-}
-
-/**
- *
- */
-size_t RocketFileInterface::
-Read(void* buffer, size_t size, Rocket::Core::FileHandle file) {
-  VirtualFileHandle *handle = (VirtualFileHandle*) file;
-  if (handle == nullptr) {
-    return 0;
-  }
-
-  handle->_stream->read((char*) buffer, size);
-  return handle->_stream->gcount();
-}
-
-/**
- *
- */
-bool RocketFileInterface::
-Seek(Rocket::Core::FileHandle file, long offset, int origin) {
-  VirtualFileHandle *handle = (VirtualFileHandle*) file;
-  if (handle == nullptr) {
-    return false;
-  }
-
-  switch(origin) {
-  case SEEK_SET:
-    handle->_stream->seekg(offset, std::ios::beg);
-    break;
-  case SEEK_CUR:
-    handle->_stream->seekg(offset, std::ios::cur);
-    break;
-  case SEEK_END:
-    handle->_stream->seekg(offset, std::ios::end);
-  };
-
-  return !handle->_stream->fail();
-}
-
-/**
- *
- */
-size_t RocketFileInterface::
-Tell(Rocket::Core::FileHandle file) {
-  VirtualFileHandle *handle = (VirtualFileHandle*) file;
-  if (handle == nullptr) {
-    return 0;
-  }
-
-  return handle->_stream->tellg();
-}
-
-/**
- *
- */
-size_t RocketFileInterface::
-Length(Rocket::Core::FileHandle file) {
-  VirtualFileHandle *handle = (VirtualFileHandle*) file;
-  if (handle == nullptr) {
-    return 0;
-  }
-
-  return handle->_file->get_file_size(handle->_stream);
-}

+ 0 - 50
panda/src/rocket/rocketFileInterface.h

@@ -1,50 +0,0 @@
-/**
- * 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."
- *
- * @file rocketFileInterface.h
- * @author rdb
- * @date 2011-11-03
- */
-
-#ifndef ROCKET_FILE_INTERFACE_H
-#define ROCKET_FILE_INTERFACE_H
-
-#include "config_rocket.h"
-#include "virtualFile.h"
-#include <Rocket/Core/FileInterface.h>
-
-class VirtualFileSystem;
-
-/**
- * Implementation of FileInterface to allow libRocket to read files from the
- * virtual file system.
- */
-class RocketFileInterface : public Rocket::Core::FileInterface {
-public:
-  RocketFileInterface(VirtualFileSystem *vfs = nullptr);
-  virtual ~RocketFileInterface() {};
-
-  Rocket::Core::FileHandle Open(const Rocket::Core::String& path);
-  void Close(Rocket::Core::FileHandle file);
-
-  size_t Read(void* buffer, size_t size, Rocket::Core::FileHandle file);
-  bool Seek(Rocket::Core::FileHandle file, long offset, int origin);
-  size_t Tell(Rocket::Core::FileHandle file);
-
-  size_t Length(Rocket::Core::FileHandle file);
-
-protected:
-  struct VirtualFileHandle {
-    PT(VirtualFile) _file;
-    std::istream *_stream;
-  };
-
-  VirtualFileSystem* _vfs;
-};
-
-#endif

+ 0 - 348
panda/src/rocket/rocketInputHandler.cxx

@@ -1,348 +0,0 @@
-/**
- * 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."
- *
- * @file rocketInputHandler.cxx
- * @author rdb
- * @date 2011-12-20
- */
-
-#include "rocketInputHandler.h"
-#include "buttonEventList.h"
-#include "dataGraphTraverser.h"
-#include "linmath_events.h"
-#include "rocketRenderInterface.h"
-#include "keyboardButton.h"
-#include "mouseButton.h"
-
-#ifndef CPPPARSER
-#include <Rocket/Core/Input.h>
-
-using namespace Rocket::Core::Input;
-#endif
-
-TypeHandle RocketInputHandler::_type_handle;
-
-/**
- *
- */
-RocketInputHandler::
-RocketInputHandler(const std::string &name) :
-  DataNode(name),
-  _mouse_xy(-1),
-  _mouse_xy_changed(false),
-  _modifiers(0),
-  _wheel_delta(0)
-{
-  _pixel_xy_input = define_input("pixel_xy", EventStoreVec2::get_class_type());
-  _button_events_input = define_input("button_events", ButtonEventList::get_class_type());
-}
-
-/**
- *
- */
-RocketInputHandler::
-~RocketInputHandler() {
-}
-
-/**
- * Returns the libRocket KeyIdentifier for the given ButtonHandle, or
- * KI_UNKNOWN (0) if it wasn't known.
- */
-int RocketInputHandler::
-get_rocket_key(const ButtonHandle handle) {
-  static pmap<int, int> keymap;
-  pmap<int, int>::const_iterator it;
-
-  if (keymap.size() > 0) {
-    it = keymap.find(handle.get_index());
-
-    if (it == keymap.end()) {
-      return 0;
-    } else {
-      return it->second;
-    }
-  }
-
-  keymap[KeyboardButton::space().get_index()]        = KI_SPACE;
-  keymap[KeyboardButton::backspace().get_index()]    = KI_BACK;
-  keymap[KeyboardButton::tab().get_index()]          = KI_TAB;
-  keymap[KeyboardButton::enter().get_index()]        = KI_RETURN;
-  keymap[KeyboardButton::escape().get_index()]       = KI_ESCAPE;
-  keymap[KeyboardButton::end().get_index()]          = KI_END;
-  keymap[KeyboardButton::home().get_index()]         = KI_HOME;
-  keymap[KeyboardButton::left().get_index()]         = KI_LEFT;
-  keymap[KeyboardButton::up().get_index()]           = KI_UP;
-  keymap[KeyboardButton::right().get_index()]        = KI_RIGHT;
-  keymap[KeyboardButton::down().get_index()]         = KI_DOWN;
-  keymap[KeyboardButton::insert().get_index()]       = KI_INSERT;
-  keymap[KeyboardButton::del().get_index()]          = KI_DELETE;
-  keymap[KeyboardButton::caps_lock().get_index()]    = KI_CAPITAL;
-  keymap[KeyboardButton::f1().get_index()]           = KI_F1;
-  keymap[KeyboardButton::f10().get_index()]          = KI_F10;
-  keymap[KeyboardButton::f11().get_index()]          = KI_F11;
-  keymap[KeyboardButton::f12().get_index()]          = KI_F12;
-  keymap[KeyboardButton::f13().get_index()]          = KI_F13;
-  keymap[KeyboardButton::f14().get_index()]          = KI_F14;
-  keymap[KeyboardButton::f15().get_index()]          = KI_F15;
-  keymap[KeyboardButton::f16().get_index()]          = KI_F16;
-  keymap[KeyboardButton::f2().get_index()]           = KI_F2;
-  keymap[KeyboardButton::f3().get_index()]           = KI_F3;
-  keymap[KeyboardButton::f4().get_index()]           = KI_F4;
-  keymap[KeyboardButton::f5().get_index()]           = KI_F5;
-  keymap[KeyboardButton::f6().get_index()]           = KI_F6;
-  keymap[KeyboardButton::f7().get_index()]           = KI_F7;
-  keymap[KeyboardButton::f8().get_index()]           = KI_F8;
-  keymap[KeyboardButton::f9().get_index()]           = KI_F9;
-  keymap[KeyboardButton::help().get_index()]         = KI_HELP;
-  keymap[KeyboardButton::lcontrol().get_index()]     = KI_LCONTROL;
-  keymap[KeyboardButton::lshift().get_index()]       = KI_LSHIFT;
-  keymap[KeyboardButton::num_lock().get_index()]     = KI_NUMLOCK;
-  keymap[KeyboardButton::page_down().get_index()]    = KI_NEXT;
-  keymap[KeyboardButton::page_up().get_index()]      = KI_PRIOR;
-  keymap[KeyboardButton::pause().get_index()]        = KI_PAUSE;
-  keymap[KeyboardButton::print_screen().get_index()] = KI_SNAPSHOT;
-  keymap[KeyboardButton::rcontrol().get_index()]     = KI_RCONTROL;
-  keymap[KeyboardButton::rshift().get_index()]       = KI_RSHIFT;
-  keymap[KeyboardButton::scroll_lock().get_index()]  = KI_SCROLL;
-
-  // these "OEM" keys have standard mappings in Panda3D
-  keymap[KeyboardButton::ascii_key(';').get_index()]  = KI_OEM_1;
-  keymap[KeyboardButton::ascii_key('=').get_index()]  = KI_OEM_PLUS;
-  keymap[KeyboardButton::ascii_key(',').get_index()]  = KI_OEM_COMMA;
-  keymap[KeyboardButton::ascii_key('-').get_index()]  = KI_OEM_MINUS;
-  keymap[KeyboardButton::ascii_key('.').get_index()]  = KI_OEM_PERIOD;
-  keymap[KeyboardButton::ascii_key('/').get_index()]  = KI_OEM_2;
-  keymap[KeyboardButton::ascii_key('`').get_index()]  = KI_OEM_3;
-  keymap[KeyboardButton::ascii_key('[').get_index()]  = KI_OEM_4;
-  keymap[KeyboardButton::ascii_key('\\').get_index()] = KI_OEM_5;
-  keymap[KeyboardButton::ascii_key(']').get_index()]  = KI_OEM_6;
-
-  // comment says this may either be "<>" or "\|", but "\" (unshifted) is
-  // handled already, and "<" is only available "shifted" on 101-keyboards, so
-  // assume it's this one...
-  keymap[KeyboardButton::ascii_key('<').get_index()]  = KI_OEM_102;
-
-  for (char c = 'a'; c <= 'z'; ++c) {
-    keymap[KeyboardButton::ascii_key(c).get_index()] = (c - 'a') + KI_A;
-  }
-  for (char c = '0'; c <= '9'; ++c) {
-    keymap[KeyboardButton::ascii_key(c).get_index()] = (c - '0') + KI_0;
-  }
-
-  it = keymap.find(handle.get_index());
-  if (it != keymap.end()) {
-    return it->second;
-  }
-  return 0;
-}
-
-/**
- * The virtual implementation of transmit_data().  This function receives an
- * array of input parameters and should generate an array of output
- * parameters.  The input parameters may be accessed with the index numbers
- * returned by the define_input() calls that were made earlier (presumably in
- * the constructor); likewise, the output parameters should be set with the
- * index numbers returned by the define_output() calls.
- */
-void RocketInputHandler::
-do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input,
-                 DataNodeTransmit &output) {
-  MutexHolder holder(_lock);
-
-  if (input.has_data(_pixel_xy_input)) {
-    // The mouse is within the window.  Get the current mouse position.
-    const EventStoreVec2 *pixel_xy;
-    DCAST_INTO_V(pixel_xy, input.get_data(_pixel_xy_input).get_ptr());
-    LVecBase2 p = pixel_xy->get_value();
-
-    // Determine if mouse moved from last position
-    if (p != _mouse_xy) {
-      _mouse_xy_changed = true;
-      _mouse_xy = p;
-    }
-  }
-
-  ButtonEventList new_button_events;
-
-  // Look for new button events.
-  if (input.has_data(_button_events_input)) {
-    const ButtonEventList *this_button_events;
-    DCAST_INTO_V(this_button_events, input.get_data(_button_events_input).get_ptr());
-    int num_events = this_button_events->get_num_events();
-    for (int i = 0; i < num_events; i++) {
-      const ButtonEvent &be = this_button_events->get_event(i);
-
-      int rocket_key = KI_UNKNOWN;
-
-      switch (be._type) {
-      case ButtonEvent::T_down:
-        if (be._button == KeyboardButton::control()) {
-          _modifiers |= KM_CTRL;
-        } else if (be._button == KeyboardButton::shift()) {
-          _modifiers |= KM_SHIFT;
-        } else if (be._button == KeyboardButton::alt()) {
-          _modifiers |= KM_ALT;
-        } else if (be._button == KeyboardButton::meta()) {
-          _modifiers |= KM_META;
-
-        } else if (be._button == KeyboardButton::enter()) {
-          _text_input.push_back('\n');
-
-        } else if (be._button == MouseButton::wheel_up()) {
-          _wheel_delta -= 1;
-        } else if (be._button == MouseButton::wheel_down()) {
-          _wheel_delta += 1;
-
-        } else if (be._button == MouseButton::one()) {
-          _mouse_buttons[0] = true;
-        } else if (be._button == MouseButton::two()) {
-          _mouse_buttons[1] = true;
-        } else if (be._button == MouseButton::three()) {
-          _mouse_buttons[2] = true;
-        } else if (be._button == MouseButton::four()) {
-          _mouse_buttons[3] = true;
-        } else if (be._button == MouseButton::five()) {
-          _mouse_buttons[4] = true;
-        }
-
-        rocket_key = get_rocket_key(be._button);
-        if (rocket_key != KI_UNKNOWN) {
-          _keys[rocket_key] = true;
-        }
-        break;
-
-      case ButtonEvent::T_repeat:
-        if (be._button == KeyboardButton::enter()) {
-          _text_input.push_back('\n');
-        }
-
-        rocket_key = get_rocket_key(be._button);
-        if (rocket_key != KI_UNKNOWN) {
-          _repeated_keys.push_back(rocket_key);
-        }
-        break;
-
-      case ButtonEvent::T_up:
-        if (be._button == KeyboardButton::control()) {
-          _modifiers &= ~KM_CTRL;
-        } else if (be._button == KeyboardButton::shift()) {
-          _modifiers &= ~KM_SHIFT;
-        } else if (be._button == KeyboardButton::alt()) {
-          _modifiers &= ~KM_ALT;
-        } else if (be._button == KeyboardButton::meta()) {
-          _modifiers &= ~KM_META;
-
-        } else if (be._button == MouseButton::one()) {
-          _mouse_buttons[0] = false;
-        } else if (be._button == MouseButton::two()) {
-          _mouse_buttons[1] = false;
-        } else if (be._button == MouseButton::three()) {
-          _mouse_buttons[2] = false;
-        } else if (be._button == MouseButton::four()) {
-          _mouse_buttons[3] = false;
-        } else if (be._button == MouseButton::five()) {
-          _mouse_buttons[4] = false;
-        }
-
-        rocket_key = get_rocket_key(be._button);
-        if (rocket_key != KI_UNKNOWN) {
-          _keys[rocket_key] = false;
-        }
-        break;
-
-      case ButtonEvent::T_keystroke:
-        // Ignore control characters; otherwise, they actually get added to
-        // strings in the UI.
-        if (be._keycode > 0x1F && (be._keycode < 0x7F || be._keycode > 0x9F)) {
-          _text_input.push_back(be._keycode);
-        }
-        break;
-
-      case ButtonEvent::T_resume_down:
-        break;
-
-      case ButtonEvent::T_move:
-        break;
-
-      case ButtonEvent::T_candidate:
-        break;
-
-      case ButtonEvent::T_raw_down:
-        break;
-
-      case ButtonEvent::T_raw_up:
-        break;
-      }
-    }
-  }
-}
-
-/**
- * Updates the libRocket context with the changes that we have gathered in
- * do_transmit_data.  Also calls Update() on the context.
- */
-void RocketInputHandler::
-update_context(Rocket::Core::Context *context, int xoffs, int yoffs) {
-  MutexHolder holder(_lock);
-
-  if (_keys.size() > 0) {
-    ButtonActivityMap::const_iterator it;
-    for (it = _keys.begin(); it != _keys.end(); ++it) {
-      if (it->second) {
-        context->ProcessKeyDown((KeyIdentifier) it->first, _modifiers);
-      } else {
-        context->ProcessKeyUp((KeyIdentifier) it->first, _modifiers);
-      }
-    }
-    _keys.clear();
-  }
-
-  if (_repeated_keys.size() > 0) {
-    pvector<int>::const_iterator it;
-
-    for (it = _repeated_keys.begin(); it != _repeated_keys.end(); ++it) {
-      context->ProcessKeyUp((KeyIdentifier) *it, _modifiers);
-      context->ProcessKeyDown((KeyIdentifier) *it, _modifiers);
-    }
-    _repeated_keys.clear();
-  }
-
-  if (_text_input.size() > 0) {
-    pvector<short>::const_iterator it;
-    for (it = _text_input.begin(); it != _text_input.end(); ++it) {
-      context->ProcessTextInput(*it);
-    }
-    _text_input.clear();
-  }
-
-  if (_mouse_xy_changed) {
-    _mouse_xy_changed = false;
-
-    context->ProcessMouseMove(_mouse_xy.get_x() - xoffs,
-                              _mouse_xy.get_y() - yoffs, _modifiers);
-  }
-
-  if (_mouse_buttons.size() > 0) {
-    ButtonActivityMap::const_iterator it;
-    for (it = _mouse_buttons.begin(); it != _mouse_buttons.end(); ++it) {
-      if (it->second) {
-        context->ProcessMouseButtonDown(it->first, _modifiers);
-      } else {
-        context->ProcessMouseButtonUp(it->first, _modifiers);
-      }
-    }
-    _mouse_buttons.clear();
-  }
-
-  if (_wheel_delta != 0) {
-    context->ProcessMouseWheel(_wheel_delta, _modifiers);
-    _wheel_delta = 0;
-  }
-
-  context->Update();
-}

+ 0 - 82
panda/src/rocket/rocketInputHandler.h

@@ -1,82 +0,0 @@
-/**
- * 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."
- *
- * @file rocketInputHandler.h
- * @author rdb
- * @date 2011-12-20
- */
-
-#ifndef ROCKETINPUTHANDLER_H
-#define ROCKETINPUTHANDLER_H
-
-#include "config_rocket.h"
-#include "dataNode.h"
-#include "buttonHandle.h"
-
-namespace Rocket {
-  namespace Core {
-    class Context;
-  }
-}
-
-/**
- * DataNode that listens for keyboard and mouse events and passes them to
- * libRocket.
- */
-class EXPCL_ROCKET RocketInputHandler : public DataNode {
-PUBLISHED:
-  RocketInputHandler(const std::string &name = std::string());
-  virtual ~RocketInputHandler();
-
-  static int get_rocket_key(const ButtonHandle handle);
-
-public:
-  void update_context(Rocket::Core::Context *context, int xoffs, int yoffs);
-
-protected:
-  // Inherited from DataNode
-  virtual void do_transmit_data(DataGraphTraverser *trav,
-                                const DataNodeTransmit &input,
-                                DataNodeTransmit &output);
-
-private:
-  Mutex _lock;
-
-  // inputs
-  int _pixel_xy_input;
-  int _button_events_input;
-
-  LVecBase2 _mouse_xy;
-  bool _mouse_xy_changed;
-  int _modifiers;
-  int _wheel_delta;
-  typedef pmap<int, bool> ButtonActivityMap;
-  ButtonActivityMap _mouse_buttons;
-  ButtonActivityMap _keys;
-  pvector<int> _repeated_keys;
-  pvector<short> _text_input;
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    DataNode::init_type();
-    register_type(_type_handle, "RocketInputHandler",
-                  DataNode::get_class_type());
-  }
-  virtual TypeHandle get_type() const {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-  static TypeHandle _type_handle;
-};
-
-#endif

+ 0 - 68
panda/src/rocket/rocketRegion.I

@@ -1,68 +0,0 @@
-/**
- * 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."
- *
- * @file rocketRegion.I
- * @author rdb
- * @date 2011-12-01
- */
-
-/**
- * Creates a libRocket context with the given name (must be unique) for the
- * given window.  Returns a new DisplayRegion where the libRocket context will
- * render to.  This variant of make() creates a region that fills the entire
- * window.
- */
-INLINE RocketRegion *RocketRegion::
-make(const std::string &context_name, GraphicsOutput *window) {
-  return make(context_name, window, LVecBase4(0.0f, 1.0f, 0.0f, 1.0f));
-}
-
-/**
- * Creates a libRocket context with the given name (must be unique) for the
- * given window.  Returns a new DisplayRegion where the libRocket context will
- * render to.
- */
-INLINE RocketRegion *RocketRegion::
-make(const std::string &context_name, GraphicsOutput *window,
-     const LVecBase4 &dimensions) {
-
-  return new RocketRegion(window, dimensions, context_name);
-}
-
-#ifndef CPPPARSER
-/**
- * Returns a pointer to the Rocket context associated with this region.  Does
- * not increase the reference count, so if you want to preserve it for longer
- * than this region exists, be sure to call AddReference() and
- * RemoveReference() yourself.
- */
-Rocket::Core::Context* RocketRegion::
-get_context() const {
-  return _context;
-}
-#endif
-
-/**
- * Sets the RocketInputHandler object from which to gather the keyboard and
- * mouse inputs to pass to the libRocket context before rendering.  You may
- * use one input handler to provide inputs to any number of RocketRegion
- * objects.
- */
-INLINE void RocketRegion::
-set_input_handler(RocketInputHandler *handler) {
-  _input_handler = handler;
-}
-
-/**
- * Returns the RocketInputHandler object previously passed to
- * set_input_handler.
- */
-INLINE RocketInputHandler *RocketRegion::
-get_input_handler() const {
-  return _input_handler;
-}

+ 0 - 182
panda/src/rocket/rocketRegion.cxx

@@ -1,182 +0,0 @@
-/**
- * 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."
- *
- * @file rocketRegion.cxx
- * @author rdb
- * @date 2011-11-30
- */
-
-#include "rocketRegion.h"
-#include "graphicsOutput.h"
-#include "orthographicLens.h"
-#include "pStatTimer.h"
-
-#if defined(HAVE_ROCKET_DEBUGGER) && !defined(CPPPARSER)
-#include <Rocket/Debugger.h>
-#endif
-
-#ifdef HAVE_PYTHON
-#include "py_panda.h"
-#endif
-
-TypeHandle RocketRegion::_type_handle;
-
-/**
- * Make sure that context_name is unique.
- */
-RocketRegion::
-RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions,
-             const std::string &context_name) :
-  DisplayRegion(window, dr_dimensions) {
-
-  // A hack I don't like.  libRocket's decorator system has a bug somewhere,
-  // and this seems to be a workaround.
-  if (Rocket::Core::GetRenderInterface() == nullptr) {
-    Rocket::Core::SetRenderInterface(&_interface);
-  }
-
-  int pl, pr, pb, pt;
-  get_pixels(pl, pr, pb, pt);
-  Rocket::Core::Vector2i dimensions (pr - pl, pt - pb);
-
-  if (rocket_cat.is_debug()) {
-    rocket_cat.debug()
-      << "Setting initial context dimensions to ("
-      << dimensions.x << ", " << dimensions.y << ")\n";
-  }
-
-  _context = Rocket::Core::CreateContext(context_name.c_str(),
-                                         dimensions, &_interface);
-  nassertv(_context != nullptr);
-
-  _lens = new OrthographicLens;
-  _lens->set_film_size(dimensions.x, -dimensions.y);
-  _lens->set_film_offset(dimensions.x * 0.5, dimensions.y * 0.5);
-  _lens->set_near_far(-1, 1);
-
-  PT(Camera) cam = new Camera(context_name, _lens);
-  set_camera(NodePath(cam));
-}
-
-/**
- *
- */
-RocketRegion::
-~RocketRegion() {
-  if (Rocket::Core::GetRenderInterface() == &_interface) {
-    Rocket::Core::SetRenderInterface(nullptr);
-  }
-
-  if (_context != nullptr) {
-    if (_context->GetReferenceCount() > 1) {
-      _context->RemoveReference();
-      return;
-    }
-
-    // We need to do this because libRocket may call into Python code to throw
-    // destruction events.
-#ifdef HAVE_ROCKET_PYTHON
-    PyGILState_STATE gstate;
-    gstate = PyGILState_Ensure();
-#endif
-
-    _context->RemoveReference();
-
-#ifdef HAVE_ROCKET_PYTHON
-    PyGILState_Release(gstate);
-#endif
-  }
-}
-
-/**
- * Performs a cull traversal for this region.
- */
-void RocketRegion::
-do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
-        GraphicsStateGuardian *gsg, Thread *current_thread) {
-
-  PStatTimer timer(get_cull_region_pcollector(), current_thread);
-
-  // We (unfortunately) need to do this because libRocket may call into Python
-  // code to throw events.
-#ifdef HAVE_ROCKET_PYTHON
-  PyGILState_STATE gstate;
-  gstate = PyGILState_Ensure();
-#endif
-
-  int pl, pr, pb, pt;
-  get_pixels(pl, pr, pb, pt);
-  Rocket::Core::Vector2i dimensions (pr - pl, pt - pb);
-
-  if (_context->GetDimensions() != dimensions) {
-    if (rocket_cat.is_debug()) {
-      rocket_cat.debug() << "Setting context dimensions to ("
-        << dimensions.x << ", " << dimensions.y << ")\n";
-    }
-
-    _context->SetDimensions(dimensions);
-
-    _lens->set_film_size(dimensions.x, -dimensions.y);
-    _lens->set_film_offset(dimensions.x * 0.5, dimensions.y * 0.5);
-  }
-
-  if (_input_handler != nullptr) {
-    _input_handler->update_context(_context, pl, pb);
-  } else {
-    _context->Update();
-  }
-
-  CullTraverser *trav = get_cull_traverser();
-  trav->set_cull_handler(cull_handler);
-  trav->set_scene(scene_setup, gsg, get_incomplete_render());
-  trav->set_view_frustum(nullptr);
-
-  _interface.render(_context, trav);
-
-#ifdef HAVE_ROCKET_PYTHON
-  PyGILState_Release(gstate);
-#endif
-
-  trav->end_traverse();
-}
-
-/**
- * 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
-}
-
-/**
- * Sets whether the debugger should be visible.
- */
-void RocketRegion::
-set_debugger_visible(bool visible) {
-#ifdef HAVE_ROCKET_DEBUGGER
-  Rocket::Debugger::SetVisible(visible);
-#endif
-}
-
-/**
- * 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
-}

+ 0 - 87
panda/src/rocket/rocketRegion.h

@@ -1,87 +0,0 @@
-/**
- * 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."
- *
- * @file rocketRegion.h
- * @author rdb
- * @date 2011-11-30
- */
-
-#ifndef ROCKETREGION_H
-#define ROCKETREGION_H
-
-#include "config_rocket.h"
-#include "displayRegion.h"
-#include "rocketRenderInterface.h"
-#include "rocketInputHandler.h"
-
-class OrthographicLens;
-
-/**
- * Represents a region in a window or buffer where the libRocket UI will be
- * rendered to.
- */
-class EXPCL_ROCKET RocketRegion : public DisplayRegion {
-protected:
-  RocketRegion(GraphicsOutput *window, const LVecBase4 &dimensions,
-               const std::string &context_name);
-
-  virtual void do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
-                       GraphicsStateGuardian *gsg, Thread *current_thread);
-
-PUBLISHED:
-  virtual ~RocketRegion();
-
-  INLINE static RocketRegion* make(const std::string &context_name,
-                                   GraphicsOutput *window);
-  INLINE static RocketRegion* make(const std::string &context_name,
-                                   GraphicsOutput *window,
-                                   const LVecBase4 &dimensions);
-#ifndef CPPPARSER
-  INLINE Rocket::Core::Context* get_context() const;
-#endif
-#ifdef HAVE_ROCKET_PYTHON
-  EXTENSION(PyObject *get_context() const);
-  MAKE_PROPERTY(context, get_context);
-#endif
-
-  INLINE void set_input_handler(RocketInputHandler *handler);
-  INLINE RocketInputHandler *get_input_handler() const;
-  MAKE_PROPERTY(input_handler, get_input_handler, set_input_handler);
-
-  bool init_debugger();
-  void set_debugger_visible(bool visible);
-  bool is_debugger_visible() const;
-  MAKE_PROPERTY(debugger_visible, is_debugger_visible, set_debugger_visible);
-
-private:
-  RocketRenderInterface _interface;
-  Rocket::Core::Context* _context;
-  PT(OrthographicLens) _lens;
-  PT(RocketInputHandler) _input_handler;
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    DisplayRegion::init_type();
-    register_type(_type_handle, "RocketRegion",
-                  DisplayRegion::get_class_type());
-  }
-  virtual TypeHandle get_type() const {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-  static TypeHandle _type_handle;
-};
-
-#include "rocketRegion.I"
-
-#endif /* ROCKETREGION_H */

+ 0 - 50
panda/src/rocket/rocketRegion_ext.cxx

@@ -1,50 +0,0 @@
-/**
- * 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."
- *
- * @file rocketRegion_ext.cxx
- * @author rdb
- * @date 2011-12-06
- */
-
-#include "rocketRegion_ext.h"
-#include "extension.h"
-
-#ifdef HAVE_PYTHON
-
-#ifndef CPPPARSER
-#define HAVE_LONG_LONG 1
-#include <Rocket/Core/Context.h>
-#include <Rocket/Core/Python/Utilities.h>
-#endif
-
-/**
- * Returns a pointer to the Rocket context associated with this region.  Will
- * only be valid as long as this region still exists, so be sure to toss it
- * when you toss the region itself.  It's best to call this method just once
- * and store the context in a Python variable, to avoid overhead.
- */
-PyObject* Extension<RocketRegion>::
-get_context() const {
-  try {
-    Rocket::Core::Context* context = _this->get_context();
-    python::object py_context = Rocket::Core::Python::Utilities::MakeObject(context);
-
-    // Make sure the context won't be destroyed before both the Python
-    // references and the C++ references to it are completely gone.
-    Py_INCREF(py_context.ptr());
-    context->AddReference();
-    return py_context.ptr();
-
-  } catch (const python::error_already_set &e) {
-    (void)e;
-    // Return NULL, which will trigger the exception in Python
-  }
-  return nullptr;
-}
-
-#endif

+ 0 - 37
panda/src/rocket/rocketRegion_ext.h

@@ -1,37 +0,0 @@
-/**
- * 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."
- *
- * @file rocketRegion_ext.h
- * @author rdb
- * @date 2013-09-13
- */
-
-#ifndef ROCKETREGION_EXT_H
-#define ROCKETREGION_EXT_H
-
-#include "dtoolbase.h"
-
-#ifdef HAVE_PYTHON
-
-#include "extension.h"
-#include "rocketRegion.h"
-#include "py_panda.h"
-
-/**
- * This class defines the extension methods for GeomVertexArrayData, which are
- * called instead of any C++ methods with the same prototype.
- */
-template<>
-class Extension<RocketRegion> : public ExtensionBase<RocketRegion> {
-public:
-  PyObject *get_context() const;
-};
-
-#endif  // HAVE_PYTHON
-
-#endif  // ROCKETREGION_EXT_H

+ 0 - 348
panda/src/rocket/rocketRenderInterface.cxx

@@ -1,348 +0,0 @@
-/**
- * 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."
- *
- * @file rocketRenderInterface.cxx
- * @author rdb
- * @date 2011-11-04
- */
-
-#include "rocketRenderInterface.h"
-#include "cullableObject.h"
-#include "cullHandler.h"
-#include "geomVertexData.h"
-#include "geomVertexArrayData.h"
-#include "internalName.h"
-#include "geomVertexWriter.h"
-#include "geomTriangles.h"
-#include "colorAttrib.h"
-#include "colorBlendAttrib.h"
-#include "cullBinAttrib.h"
-#include "depthTestAttrib.h"
-#include "depthWriteAttrib.h"
-#include "scissorAttrib.h"
-#include "texture.h"
-#include "textureAttrib.h"
-#include "texturePool.h"
-
-/**
- * Called by RocketNode in cull_callback.  Invokes context->Render() and culls
- * the result.
- */
-void RocketRenderInterface::
-render(Rocket::Core::Context* context, CullTraverser *trav) {
-  nassertv(context != nullptr);
-  MutexHolder holder(_lock);
-
-  _trav = trav;
-  _net_transform = trav->get_world_transform();
-  _net_state = RenderState::make(
-    CullBinAttrib::make("unsorted", 0),
-    DepthTestAttrib::make(RenderAttrib::M_none),
-    DepthWriteAttrib::make(DepthWriteAttrib::M_off),
-    ColorBlendAttrib::make(ColorBlendAttrib::M_add,
-      ColorBlendAttrib::O_incoming_alpha,
-      ColorBlendAttrib::O_one_minus_incoming_alpha
-    ),
-    ColorAttrib::make_vertex()
-  );
-  _dimensions = context->GetDimensions();
-
-  context->Render();
-
-  _trav = nullptr;
-  _net_transform = nullptr;
-  _net_state = nullptr;
-}
-
-/**
- * Called internally to make a Geom from Rocket data.
- */
-PT(Geom) RocketRenderInterface::
-make_geom(Rocket::Core::Vertex* vertices,
-          int num_vertices, int* indices, int num_indices,
-          GeomEnums::UsageHint uh, const LVecBase2 &tex_scale) {
-
-  PT(GeomVertexData) vdata = new GeomVertexData("", GeomVertexFormat::get_v3c4t2(), uh);
-  vdata->unclean_set_num_rows(num_vertices);
-  {
-    GeomVertexWriter vwriter(vdata, InternalName::get_vertex());
-    GeomVertexWriter cwriter(vdata, InternalName::get_color());
-    GeomVertexWriter twriter(vdata, InternalName::get_texcoord());
-
-    // Write the vertex information.
-    for (int i = 0; i < num_vertices; ++i) {
-      const Rocket::Core::Vertex &vertex = vertices[i];
-
-      vwriter.add_data3f(LVector3f::right() * vertex.position.x + LVector3f::up() * vertex.position.y);
-      cwriter.add_data4i(vertex.colour.red, vertex.colour.green,
-                         vertex.colour.blue, vertex.colour.alpha);
-      twriter.add_data2f(vertex.tex_coord.x * tex_scale[0],
-                         (1.0f - vertex.tex_coord.y) * tex_scale[1]);
-    }
-  }
-
-  // Create a primitive and write the indices.
-  PT(GeomTriangles) triangles = new GeomTriangles(uh);
-  {
-    PT(GeomVertexArrayData) idata = triangles->modify_vertices();
-    idata->unclean_set_num_rows(num_indices);
-    GeomVertexWriter iwriter(idata, 0);
-
-    for (int i = 0; i < num_indices; ++i) {
-      iwriter.add_data1i(indices[i]);
-    }
-  }
-
-  PT(Geom) geom = new Geom(vdata);
-  geom->add_primitive(triangles);
-  return geom;
-}
-
-/**
- * Only call this during render().  Culls a geom.
- */
-void RocketRenderInterface::
-render_geom(const Geom* geom, const RenderState* state, const Rocket::Core::Vector2f& translation) {
-  LVector3 offset = LVector3::right() * translation.x + LVector3::up() * translation.y;
-
-  if (_enable_scissor) {
-    state = state->add_attrib(ScissorAttrib::make(_scissor));
-    rocket_cat.spam()
-      << "Rendering geom " << geom << " with state "
-      << *state << ", translation (" << offset << "), "
-      << "scissor region (" << _scissor << ")\n";
-  } else {
-    rocket_cat.spam()
-      << "Rendering geom " << geom << " with state "
-      << *state << ", translation (" << offset << ")\n";
-  }
-
-  CPT(TransformState) internal_transform =
-    _trav->get_scene()->get_cs_world_transform()->compose(
-      _net_transform->compose(TransformState::make_pos(offset)));
-
-  CullableObject *object =
-    new CullableObject(geom, _net_state->compose(state),
-                       internal_transform);
-  _trav->get_cull_handler()->record_object(object, _trav);
-}
-
-/**
- * Called by Rocket when it wants to render geometry that the application does
- * not wish to optimize.
- */
-void RocketRenderInterface::
-RenderGeometry(Rocket::Core::Vertex* vertices,
-               int num_vertices, int* indices, int num_indices,
-               Rocket::Core::TextureHandle thandle,
-               const Rocket::Core::Vector2f& translation) {
-
-  Texture *texture = (Texture *)thandle;
-
-  LVecBase2 tex_scale(1, 1);
-  if (texture != nullptr) {
-    tex_scale = texture->get_tex_scale();
-  }
-
-  PT(Geom) geom = make_geom(vertices, num_vertices, indices, num_indices,
-                            GeomEnums::UH_stream, tex_scale);
-
-  CPT(RenderState) state;
-  if (texture != nullptr) {
-    state = RenderState::make(TextureAttrib::make(texture));
-  } else {
-    state = RenderState::make_empty();
-  }
-
-  render_geom(geom, state, translation);
-}
-
-/**
- * Called by Rocket when it wants to compile geometry it believes will be
- * static for the forseeable future.
- */
-Rocket::Core::CompiledGeometryHandle RocketRenderInterface::
-CompileGeometry(Rocket::Core::Vertex* vertices,
-                int num_vertices, int* indices, int num_indices,
-                Rocket::Core::TextureHandle thandle) {
-
-  Texture *texture = (Texture *)thandle;
-
-  CompiledGeometry *c = new CompiledGeometry;
-  LVecBase2 tex_scale(1, 1);
-
-  if (texture != nullptr) {
-    rocket_cat.debug()
-      << "Compiling geom " << c->_geom << " with texture '"
-      << texture->get_name() << "'\n";
-
-    tex_scale = texture->get_tex_scale();
-
-    PT(TextureStage) stage = new TextureStage("");
-    stage->set_mode(TextureStage::M_modulate);
-
-    CPT(TextureAttrib) attr = DCAST(TextureAttrib, TextureAttrib::make());
-    attr = DCAST(TextureAttrib, attr->add_on_stage(stage, (Texture *)texture));
-
-    c->_state = RenderState::make(attr);
-
-  } else {
-    rocket_cat.debug()
-      << "Compiling geom " << c->_geom << " without texture\n";
-
-    c->_state = RenderState::make_empty();
-  }
-
-  c->_geom = make_geom(vertices, num_vertices, indices, num_indices,
-                       GeomEnums::UH_static, tex_scale);
-
-  return (Rocket::Core::CompiledGeometryHandle) c;
-}
-
-/**
- * Called by Rocket when it wants to render application-compiled geometry.
- */
-void RocketRenderInterface::
-RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation) {
-
-  CompiledGeometry *c = (CompiledGeometry*) geometry;
-  render_geom(c->_geom, c->_state, translation);
-}
-
-/**
- * Called by Rocket when it wants to release application-compiled geometry.
- */
-void RocketRenderInterface::
-ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry) {
-  delete (CompiledGeometry*) geometry;
-}
-
-/**
- * Called by Rocket when a texture is required by the library.
- */
-bool RocketRenderInterface::
-LoadTexture(Rocket::Core::TextureHandle& texture_handle,
-            Rocket::Core::Vector2i& texture_dimensions,
-            const Rocket::Core::String& source) {
-
-  // Prefer padding over scaling to avoid blurring people's pixel art.
-  LoaderOptions options;
-  if (Texture::get_textures_power_2() == ATS_none) {
-    options.set_auto_texture_scale(ATS_none);
-  } else {
-    options.set_auto_texture_scale(ATS_pad);
-  }
-
-  Filename fn = Filename::from_os_specific(source.CString());
-  PT(Texture) tex = TexturePool::load_texture(fn, 0, false, options);
-  if (tex == nullptr) {
-    texture_handle = 0;
-    texture_dimensions.x = 0;
-    texture_dimensions.y = 0;
-    return false;
-  }
-
-  tex->set_minfilter(SamplerState::FT_nearest);
-  tex->set_magfilter(SamplerState::FT_nearest);
-
-  // Since libRocket may make layout decisions based on the size of the image,
-  // it's important that we give it the original size of the image file in
-  // order to produce consistent results.
-  int width = tex->get_orig_file_x_size();
-  int height = tex->get_orig_file_y_size();
-  if (width == 0 && height == 0) {
-    // This shouldn't happen unless someone is playing very strange tricks
-    // with the TexturePool, but we might as well handle it.
-    width = tex->get_x_size();
-    height = tex->get_y_size();
-  }
-  texture_dimensions.x = width;
-  texture_dimensions.y = height;
-
-  tex->ref();
-  texture_handle = (Rocket::Core::TextureHandle) tex.p();
-
-  return true;
-}
-
-/**
- * Called by Rocket when a texture is required to be built from an internally-
- * generated sequence of pixels.
- */
-bool RocketRenderInterface::
-GenerateTexture(Rocket::Core::TextureHandle& texture_handle,
-                const Rocket::Core::byte* source,
-                const Rocket::Core::Vector2i& source_dimensions) {
-
-  PT(Texture) tex = new Texture;
-  tex->setup_2d_texture(source_dimensions.x, source_dimensions.y,
-                        Texture::T_unsigned_byte, Texture::F_rgba);
-
-  // Pad to nearest power of two if necessary.  It may not be necessary as
-  // libRocket seems to give power-of-two sizes already, but can't hurt.
-  tex->set_size_padded(source_dimensions.x, source_dimensions.y);
-
-  PTA_uchar image = tex->modify_ram_image();
-
-  // Convert RGBA to BGRA
-  size_t src_stride = source_dimensions.x * 4;
-  size_t dst_stride = tex->get_x_size() * 4;
-  const unsigned char *src_ptr = source + (src_stride * source_dimensions.y);
-  unsigned char *dst_ptr = &image[0];
-
-  for (; src_ptr > source; dst_ptr += dst_stride) {
-    src_ptr -= src_stride;
-    for (size_t i = 0; i < src_stride; i += 4) {
-      dst_ptr[i + 0] = src_ptr[i + 2];
-      dst_ptr[i + 1] = src_ptr[i + 1];
-      dst_ptr[i + 2] = src_ptr[i];
-      dst_ptr[i + 3] = src_ptr[i + 3];
-    }
-  }
-
-  tex->set_wrap_u(SamplerState::WM_clamp);
-  tex->set_wrap_v(SamplerState::WM_clamp);
-  tex->set_minfilter(SamplerState::FT_nearest);
-  tex->set_magfilter(SamplerState::FT_nearest);
-
-  tex->ref();
-  texture_handle = (Rocket::Core::TextureHandle) tex.p();
-
-  return true;
-}
-
-/**
- * Called by Rocket when a loaded texture is no longer required.
- */
-void RocketRenderInterface::
-ReleaseTexture(Rocket::Core::TextureHandle texture_handle) {
-  Texture *tex = (Texture *)texture_handle;
-  if (tex != nullptr) {
-    unref_delete(tex);
-  }
-}
-
-/**
- * Called by Rocket when it wants to enable or disable scissoring to clip
- * content.
- */
-void RocketRenderInterface::
-EnableScissorRegion(bool enable) {
-  _enable_scissor = enable;
-}
-
-/**
- * Called by Rocket when it wants to change the scissor region.
- */
-void RocketRenderInterface::
-SetScissorRegion(int x, int y, int width, int height) {
-  _scissor[0] = x / (PN_stdfloat) _dimensions.x;
-  _scissor[1] = (x + width) / (PN_stdfloat) _dimensions.x;
-  _scissor[2] = 1.0f - ((y + height) / (PN_stdfloat) _dimensions.y);
-  _scissor[3] = 1.0f - (y / (PN_stdfloat) _dimensions.y);
-}

+ 0 - 75
panda/src/rocket/rocketRenderInterface.h

@@ -1,75 +0,0 @@
-/**
- * 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."
- *
- * @file rocketRenderInterface.h
- * @author rdb
- * @date 2011-11-04
- */
-
-#ifndef ROCKET_RENDER_INTERFACE_H
-#define ROCKET_RENDER_INTERFACE_H
-
-#include "config_rocket.h"
-#include "cullTraverser.h"
-#include "cullTraverserData.h"
-#include "geom.h"
-#include "renderState.h"
-#include "transformState.h"
-
-#include <Rocket/Core/RenderInterface.h>
-
-/**
- * Class that provides the main render interface for libRocket integration.
- */
-class RocketRenderInterface : public Rocket::Core::RenderInterface {
-public:
-  void render(Rocket::Core::Context* context, CullTraverser *trav);
-
-protected:
-  struct CompiledGeometry {
-    CPT(Geom) _geom;
-    CPT(RenderState) _state;
-  };
-
-  PT(Geom) make_geom(Rocket::Core::Vertex* vertices,
-                     int num_vertices, int* indices, int num_indices,
-                     GeomEnums::UsageHint uh, const LVecBase2 &tex_scale);
-  void render_geom(const Geom* geom, const RenderState* state, const Rocket::Core::Vector2f& translation);
-
-  void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation);
-  Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture);
-  void RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation);
-  void ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry);
-
-  bool LoadTexture(Rocket::Core::TextureHandle& texture_handle,
-                   Rocket::Core::Vector2i& texture_dimensions,
-                   const Rocket::Core::String& source);
-  bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle,
-                       const Rocket::Core::byte* source,
-                       const Rocket::Core::Vector2i& source_dimensions);
-  void ReleaseTexture(Rocket::Core::TextureHandle texture_handle);
-
-  void EnableScissorRegion(bool enable);
-  void SetScissorRegion(int x, int y, int width, int height);
-
-private:
-  Mutex _lock;
-
-  // Hold the scissor settings and whether or not to enable scissoring.
-  bool _enable_scissor;
-  LVecBase4 _scissor;
-
-  // These are temporarily filled in by render().
-  CullTraverser *_trav;
-  CPT(TransformState) _net_transform;
-  CPT(RenderState) _net_state;
-  Rocket::Core::Vector2i _dimensions;
-
-};
-
-#endif

+ 0 - 54
panda/src/rocket/rocketSystemInterface.cxx

@@ -1,54 +0,0 @@
-/**
- * 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."
- *
- * @file rocketSystemInterface.cxx
- * @author rdb
- * @date 2011-11-03
- */
-
-#include "rocketSystemInterface.h"
-#include "clockObject.h"
-
-/**
- * Get the number of seconds elapsed since the start of the application.
- */
-float RocketSystemInterface::
-GetElapsedTime() {
-  ClockObject *clock = ClockObject::get_global_clock();
-  // XXX not sure exactly how Rocket uses uses it, maybe get_frame_time is
-  // better?
-  return clock->get_real_time();
-}
-
-/**
- * Log the specified message.  Returns true to continue execution, false to
- * break into the debugger.
- */
-bool RocketSystemInterface::
-LogMessage(Rocket::Core::Log::Type type, const Rocket::Core::String& message) {
-  switch(type) {
-  case Rocket::Core::Log::LT_ALWAYS:
-  case Rocket::Core::Log::LT_ERROR:
-  case Rocket::Core::Log::LT_ASSERT:
-    rocket_cat->error() << message.CString() << "\n";
-    return true;
-  case Rocket::Core::Log::LT_WARNING:
-    rocket_cat->warning() << message.CString() << "\n";
-    return true;
-  case Rocket::Core::Log::LT_INFO:
-    rocket_cat->info() << message.CString() << "\n";
-    return true;
-  case Rocket::Core::Log::LT_DEBUG:
-    rocket_cat->debug() << message.CString() << "\n";
-    return true;
-  case Rocket::Core::Log::LT_MAX:
-    // Not really sent; just to keep compiler happy
-    break;
-  }
-  return true;
-}

+ 0 - 32
panda/src/rocket/rocketSystemInterface.h

@@ -1,32 +0,0 @@
-/**
- * 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."
- *
- * @file rocketSystemInterface.h
- * @author rdb
- * @date 2011-11-03
- */
-
-#ifndef ROCKET_SYSTEM_INTERFACE_H
-#define ROCKET_SYSTEM_INTERFACE_H
-
-#include "config_rocket.h"
-
-#include <Rocket/Core/SystemInterface.h>
-#include <Rocket/Core/Log.h>
-
-/**
- * This is an implementation of SystemInterface that redirects the log output
- * to Panda's notify system.
- */
-class RocketSystemInterface : public Rocket::Core::SystemInterface {
-public:
-  float GetElapsedTime();
-  bool LogMessage(Rocket::Core::Log::Type type, const Rocket::Core::String& message);
-};
-
-#endif

BIN
samples/rocket-console/assets/Perfect DOS VGA 437.ttf


+ 0 - 38
samples/rocket-console/assets/console.rcss

@@ -1,38 +0,0 @@
-body
-{
-    font-family: "Perfect DOS VGA 437";
-    font-weight: normal;
-    font-style: normal;
-
-    // use all the allocated texture space
-    min-width: 100%;
-    min-height: 100%;
-
-    background-color: #000;
-}
-
-
-text#content
-{
-    z-index: 2;
-    font-size: 30px;
-
-    white-space: pre-wrap;
-
-    margin: auto;
-
-    text-align: left;
-    position: absolute;
-
-    // account for non-proportionality of our 1024x512
-    // buffer compared with VGA font proportions and
-    // wanting to center the screen with 40 columns
-    top: 16px;
-    left: 32px;
-
-    width: 100%;
-    height: 100%;
-
-    color: #888;
-
-}

+ 0 - 11
samples/rocket-console/assets/console.rml

@@ -1,11 +0,0 @@
-<rml>
-
-    <head>
-        <title>Administrative Console</title>
-        <link type="text/rcss" href="console.rcss"/>
-    </head>
-    <!-- events are bound strictly from code -->
-    <body >
-        <text id="content" />
-    </body>
-</rml>

+ 0 - 1
samples/rocket-console/assets/dos437.txt

@@ -1 +0,0 @@
-from www.dafont.com/perfect-dos-vga-437.font (info at http://zehfernando.com/2015/revisiting-vga-fonts/)

+ 0 - 54
samples/rocket-console/assets/loading.rml

@@ -1,54 +0,0 @@
-<rml>
-    <head >
-        <title>Main Menu</title>
-        <link type="text/template" href="window.rml" />
-        <style>
-            body
-            {
-                width: 400px;
-                height: 225px;
-
-                margin: auto;
-
-                background-color: #44f;
-            }
-
-
-            div#title_bar_content
-            {
-                font-size: 48;
-
-                //text-align: left;
-                position: absolute;
-                top: 40%;
-                //vertical-align: center;
-
-            }
-
-        </style>
-
-        <script>
-
-import _rocketcore as rocket
-
-# This handler overrides the 'onkeydown' handler from the template
-def OnKeyDown(event, document):
-    keyId = event.parameters['key_identifier']
-    if keyId in [ rocket.key_identifier.RETURN,
-                rocket.key_identifier.ESCAPE,
-                 rocket.key_identifier.SPACE ]:
-        FireClosing(document)
-
-# custom event
-def FireClosing(document):
-    document.DispatchEvent("aboutToClose", { }, False)
-
-    </script>
-
-    </head>
-    <body id='window' template="window" onclick='FireClosing(document)'>
-        <div id="title_bar_content" >
-            <label id="loadingLabel">Loading...</label>
-        </div>
-    </body>
-</rml>

+ 0 - 18
samples/rocket-console/assets/modenine.nfo

@@ -1,18 +0,0 @@
-ModeNine
-
-Based on Andrew Bulhak's ModeSeven, in turn inspired by the screen
-output of the BBC Micro.
-
-copyright: 
-(C) 1998 Andrew C. Bulhak
-(C) 2001 Graham H Freeman
-
-Freely Distributable. 
-
-All we ask is that this readme file must be included with the font package.
-Impresarios of free font sites and shovelware cd-roms, this means you!
-
-If you think this font is doovy, let us know at [email protected], and we
-might actually make more fonts. 
-
-Another fine Grudnuk Creations produkt | http://grudnuk.com/

BIN
samples/rocket-console/assets/modenine.ttf


BIN
samples/rocket-console/assets/monitor.egg.pz


+ 0 - 12
samples/rocket-console/assets/monitor.txt

@@ -1,12 +0,0 @@
-
-This is an edited version of this file from blendswap.com (http://www.blendswap.com/blends/view/74468).
-
-VERY IMPORTANT LICENSE INFORMATION:
-
-This file has been released by buzo under the following license:
-
-    Creative Commons Zero (Public Domain)
-
-You can use this model for any purposes according to the following conditions:
-
-    There are no requirements for CC-Zero licensed blends.

+ 0 - 44
samples/rocket-console/assets/rkt.rcss

@@ -1,44 +0,0 @@
-/*
-* Default styles for all the basic elements.
-*/
-
-div
-{
-    display: block;
-}
-
-p
-{
-    display: block;
-}
-
-h1
-{
-    display: block;
-}
-
-em
-{
-    font-style: italic;
-}
-
-strong
-{
-    font-weight: bold;
-}
-
-datagrid
-{
-    display: block;
-}
-
-select, dataselect, datacombo
-{
-    text-align: left;
-}
-
-tabset tabs
-{
-    display: block;
-}
-

+ 0 - 316
samples/rocket-console/assets/takeyga_kb.egg

@@ -1,316 +0,0 @@
-<CoordinateSystem> { Z-up } 
-<Material> takeyga_kb {
-  <Scalar> diffr { 0.800000 }
-  <Scalar> diffg { 0.800000 }
-  <Scalar> diffb { 0.800000 }
-  <Scalar> specr { 0.500000 }
-  <Scalar> specg { 0.500000 }
-  <Scalar> specb { 0.500000 }
-  <Scalar> shininess { 12.5 }
-  <Scalar> ambr { 1.000000 }
-  <Scalar> ambg { 1.000000 }
-  <Scalar> ambb { 1.000000 }
-  <Scalar> emitr { 0.000000 }
-  <Scalar> emitg { 0.000000 }
-  <Scalar> emitb { 0.000000 }
-}
-
-<Texture> Texture.001 {
-  "./tex/takeyga_kb_specular.dds"
-  <Scalar> envtype { MODULATE }
-  <Scalar> minfilter { LINEAR_MIPMAP_LINEAR }
-  <Scalar> magfilter { LINEAR_MIPMAP_LINEAR }
-  <Scalar> wrap { REPEAT }
-}
-
-<Texture> Tex {
-  "./tex/takeyga_kb_diffuse.dds"
-  <Scalar> envtype { MODULATE }
-  <Scalar> minfilter { LINEAR_MIPMAP_LINEAR }
-  <Scalar> magfilter { LINEAR_MIPMAP_LINEAR }
-  <Scalar> wrap { REPEAT }
-}
-
-<Texture> Texture {
-  "./tex/takeyga_kb_normal.dds"
-  <Scalar> envtype { NORMAL }
-  <Scalar> minfilter { LINEAR_MIPMAP_LINEAR }
-  <Scalar> magfilter { LINEAR_MIPMAP_LINEAR }
-  <Scalar> wrap { REPEAT }
-}
-
-  <Group> Cube.001 {
-    <Transform> {
-      <Matrix4> {
-        0.08499996364116669 0.0 0.0 0.0 
-        0.0 0.23999987542629242 0.0 0.0 
-        0.0 0.0 0.02500000037252903 0.0 
-        0.0 0.0 0.0 1.0 
-      }
-    }
-    
-    <VertexPool> Cube.001 {
-    
-      <Vertex> 0 {0.082953 0.240000 -0.025000
-        <UV>  {
-          0.158203125 0.595703125 
-        }
-      }
-      <Vertex> 1 {0.082953 -0.240000 -0.025000
-        <UV>  {
-          0.98828125 0.6015625 
-        }
-      }
-      <Vertex> 2 {-0.085000 -0.240000 -0.025000
-        <UV>  {
-          0.98828125 0.986328125 
-        }
-      }
-      <Vertex> 3 {-0.085000 0.240000 -0.025000
-        <UV>  {
-          0.162109375 0.98828125 
-        }
-      }
-      <Vertex> 4 {0.073544 0.227744 -0.005546
-        <UV>  {
-          0.990234375 0.017578125 
-        }
-      }
-      <Vertex> 5 {-0.067932 0.223167 0.018996
-        <UV>  {
-          0.98046875 0.46875 
-        }
-      }
-      <Vertex> 6 {-0.067932 -0.223167 0.018996
-        <UV>  {
-          0.017578125 0.470703125 
-        }
-      }
-      <Vertex> 7 {0.073544 -0.227744 -0.005546
-        <UV>  {
-          0.01953125 0.013671875 
-        }
-      }
-      <Vertex> 8 {0.082372 0.237328 -0.015273
-        <UV>  {
-          0.9794921875 0.552734375 
-        }
-      }
-      <Vertex> 9 {0.073544 0.227744 -0.005546
-        <UV>  {
-          0.9765625 0.57421875 
-        }
-      }
-      <Vertex> 10 {0.073544 -0.227744 -0.005546
-        <UV>  {
-          0.025390625 0.57421875 
-        }
-      }
-      <Vertex> 11 {0.082372 -0.237328 -0.015273
-        <UV>  {
-          0.0234375 0.5537109375 
-        }
-      }
-      <Vertex> 12 {0.082372 -0.237328 -0.015273
-        <UV>  {
-          0.0703125 0.6123046875 
-        }
-      }
-      <Vertex> 13 {0.073544 -0.227744 -0.005546
-        <UV>  {
-          0.095703125 0.615234375 
-        }
-      }
-      <Vertex> 14 {-0.067932 -0.223167 0.018996
-        <UV>  {
-          0.13671875 0.97265625 
-        }
-      }
-      <Vertex> 15 {-0.080884 -0.235006 0.001122
-        <UV>  {
-          0.07421875 0.982421875 
-        }
-      }
-      <Vertex> 16 {-0.080884 -0.235006 0.001122
-        <UV>  {
-          0.0166015625 0.5361328125 
-        }
-      }
-      <Vertex> 17 {-0.067932 -0.223167 0.018996
-        <UV>  {
-          0.017578125 0.58203125 
-        }
-      }
-      <Vertex> 18 {-0.067932 0.223167 0.018996
-        <UV>  {
-          0.978515625 0.580078125 
-        }
-      }
-      <Vertex> 19 {-0.080884 0.235006 0.001122
-        <UV>  {
-          0.984375 0.5341796875 
-        }
-      }
-      <Vertex> 20 {0.082372 0.237328 -0.015273
-        <UV>  {
-          0.0703125 0.6123046875 
-        }
-      }
-      <Vertex> 21 {0.082953 0.240000 -0.025000
-        <UV>  {
-          0.044921875 0.609375 
-        }
-      }
-      <Vertex> 22 {-0.085000 0.240000 -0.025000
-        <UV>  {
-          0.01171875 0.9921875 
-        }
-      }
-      <Vertex> 23 {-0.080884 0.235006 0.001122
-        <UV>  {
-          0.07421875 0.982421875 
-        }
-      }
-      <Vertex> 24 {0.082953 0.240000 -0.025000
-        <UV>  {
-          0.982421875 0.53125 
-        }
-      }
-      <Vertex> 25 {0.082372 0.237328 -0.015273
-        <UV>  {
-          0.9794921875 0.552734375 
-        }
-      }
-      <Vertex> 26 {0.082372 -0.237328 -0.015273
-        <UV>  {
-          0.0234375 0.5537109375 
-        }
-      }
-      <Vertex> 27 {0.082953 -0.240000 -0.025000
-        <UV>  {
-          0.021484375 0.533203125 
-        }
-      }
-      <Vertex> 28 {0.082953 -0.240000 -0.025000
-        <UV>  {
-          0.044921875 0.609375 
-        }
-      }
-      <Vertex> 29 {0.082372 -0.237328 -0.015273
-        <UV>  {
-          0.0703125 0.6123046875 
-        }
-      }
-      <Vertex> 30 {-0.080884 -0.235006 0.001122
-        <UV>  {
-          0.07421875 0.982421875 
-        }
-      }
-      <Vertex> 31 {-0.085000 -0.240000 -0.025000
-        <UV>  {
-          0.01171875 0.9921875 
-        }
-      }
-      <Vertex> 32 {-0.085000 -0.240000 -0.025000
-        <UV>  {
-          0.015625 0.490234375 
-        }
-      }
-      <Vertex> 33 {-0.080884 -0.235006 0.001122
-        <UV>  {
-          0.0166015625 0.5361328125 
-        }
-      }
-      <Vertex> 34 {-0.080884 0.235006 0.001122
-        <UV>  {
-          0.984375 0.5341796875 
-        }
-      }
-      <Vertex> 35 {-0.085000 0.240000 -0.025000
-        <UV>  {
-          0.990234375 0.48828125 
-        }
-      }
-      <Vertex> 36 {0.073544 0.227744 -0.005546
-        <UV>  {
-          0.095703125 0.615234375 
-        }
-      }
-      <Vertex> 37 {0.082372 0.237328 -0.015273
-        <UV>  {
-          0.0703125 0.6123046875 
-        }
-      }
-      <Vertex> 38 {-0.080884 0.235006 0.001122
-        <UV>  {
-          0.07421875 0.982421875 
-        }
-      }
-      <Vertex> 39 {-0.067932 0.223167 0.018996
-        <UV>  {
-          0.13671875 0.97265625 
-        }
-      }}
-    
-    
-    <Polygon> {
-      <TRef> { Tex }
-      <MRef> { takeyga_kb }
-      <Normal> {0.000000 0.000000 -1.000000}
-      <VertexRef> { 0 1 2 3 <Ref> { Cube.001 }} 
-    }
-    <Polygon> {
-      <TRef> { Tex }
-      <MRef> { takeyga_kb }
-      <Normal> {0.508027 -0.000000 0.861341}
-      <VertexRef> { 4 5 6 7 <Ref> { Cube.001 }} 
-    }
-    <Polygon> {
-      <TRef> { Tex }
-      <MRef> { takeyga_kb }
-      <Normal> {0.966167 -0.000000 0.257917}
-      <VertexRef> { 8 9 10 11 <Ref> { Cube.001 }} 
-    }
-    <Polygon> {
-      <TRef> { Tex }
-      <MRef> { takeyga_kb }
-      <Normal> {0.028240 -0.996449 0.079322}
-      <VertexRef> { 12 13 14 15 <Ref> { Cube.001 }} 
-    }
-    <Polygon> {
-      <TRef> { Tex }
-      <MRef> { takeyga_kb }
-      <Normal> {-0.978036 0.000000 0.208436}
-      <VertexRef> { 16 17 18 19 <Ref> { Cube.001 }} 
-    }
-    <Polygon> {
-      <TRef> { Tex }
-      <MRef> { takeyga_kb }
-      <Normal> {0.001260 0.999752 0.022233}
-      <VertexRef> { 20 21 22 23 <Ref> { Cube.001 }} 
-    }
-    <Polygon> {
-      <TRef> { Tex }
-      <MRef> { takeyga_kb }
-      <Normal> {0.999846 -0.000000 0.017550}
-      <VertexRef> { 24 25 26 27 <Ref> { Cube.001 }} 
-    }
-    <Polygon> {
-      <TRef> { Tex }
-      <MRef> { takeyga_kb }
-      <Normal> {0.001259 -0.999752 0.022233}
-      <VertexRef> { 28 29 30 31 <Ref> { Cube.001 }} 
-    }
-    <Polygon> {
-      <TRef> { Tex }
-      <MRef> { takeyga_kb }
-      <Normal> {-0.998928 0.000000 0.046291}
-      <VertexRef> { 32 33 34 35 <Ref> { Cube.001 }} 
-    }
-    <Polygon> {
-      <TRef> { Tex }
-      <MRef> { takeyga_kb }
-      <Normal> {0.028241 0.996449 0.079322}
-      <VertexRef> { 36 37 38 39 <Ref> { Cube.001 }} 
-    }
-  }

BIN
samples/rocket-console/assets/tex/takeyga_kb_diffuse.dds


BIN
samples/rocket-console/assets/tex/takeyga_kb_normal.dds


BIN
samples/rocket-console/assets/tex/takeyga_kb_specular.dds


+ 0 - 56
samples/rocket-console/assets/window.rcss

@@ -1,56 +0,0 @@
-body
-{
-    font-family: "MODENINE";
-    font-weight: normal;
-    font-style: normal;
-    font-size: 15;
-
-}
-
-body.window
-{
-    padding-top: 43px;
-    padding-bottom: 20px;
-
-    min-width: 250px;
-
-    min-height: 135px;
-    max-height: 700px;
-
-}
-
-
-
-div#title_bar
-{
-    z-index: 1;
-
-    position: absolute;
-    top: 0px;
-    left: 0px;
-
-    text-align: center;
-
-    color: #fff;
-    background-color: #22f;
-}
-
-
-div#title_bar span
-{
-    padding-top: 17px;
-    padding-bottom: 48px;
-
-    font-size: 32;
-    font-weight: bold;
-
-    outline-font-effect: outline;
-    outline-width: 1px;
-    outline-color: black;
-}
-
-div#title_bar_content
-{
-    text-align: center;
-    color: #cff;
-}

+ 0 - 42
samples/rocket-console/assets/window.rml

@@ -1,42 +0,0 @@
-<template name="window" content="content">
-    <head>
-        <link type="text/rcss" href="rkt.rcss"/>
-        <link type="text/rcss" href="window.rcss"/>
-
-
-        <script>
-import _rocketcore as rocket
-
-def OnLoad(document):
-    print "Rocket document loaded"
-
-# event handlers from templates can be overridden in windows using them
-def OnKeyDown(event, document):
-    keyId = event.parameters['key_identifier']
-    print "Base keydown: unhandled key ",keyId
-
-        </script>
-    </head>
-
-
-    <body class="window" onload='OnLoad(document)' onkeydown='OnKeyDown(event, document)'>
-        <div id="title_bar">
-            <handle move_target="#document">
-            <span id="title">Rocket Sample</span>
-
-                <div id="title_bar_content">
-                </div>
-            </handle>
-        </div>
-        <div id="window">
-            <div id="content">
-            </div>
-        </div>
-
-        <!-- drag and drop of window -->
-        <handle size_target="#document"
-             style="position: absolute; width: 16px; height: 16px; bottom: 0px; right: 0px;">
-        </handle>
-    </body>
-
-</template>

+ 0 - 153
samples/rocket-console/console.py

@@ -1,153 +0,0 @@
-"""
-Simple console widget for rocket
-"""
-import sys, os.path
-
-# workaround: https://www.panda3d.org/forums/viewtopic.php?t=10062&p=99697#p99054
-#from panda3d import rocket
-import _rocketcore as rocket
-
-from panda3d.rocket import RocketRegion, RocketInputHandler
-
-class Console(object):
-    def __init__(self, base, context, cols, rows, commandHandler):
-        self.base = base
-
-        self.context = context
-        self.loadFonts()
-        self.cols = cols
-        self.rows = rows
-        self.commandHandler = commandHandler
-
-        self.setupConsole()
-        self.allowEditing(True)
-
-    def getTextContainer(self):
-        return self.textEl
-
-    def setPrompt(self, prompt):
-        self.consolePrompt = prompt
-
-    def allowEditing(self, editMode):
-        self.editMode = editMode
-        if editMode:
-            self.input = ""
-            if not self.lastLine:
-                self.addLine("")
-            self.newEditLine()
-
-    def loadFonts(self):
-        rocket.LoadFontFace("Perfect DOS VGA 437.ttf")
-
-    def setupConsole(self):
-        self.document = self.context.LoadDocument("console.rml")
-        if not self.document:
-            raise AssertionError("did not find console.rml")
-
-        el = self.document.GetElementById('content')
-
-        self.textEl = el
-
-        # roundabout way of accessing the current object through rocket event...
-
-        # add attribute to let Rocket know about the receiver
-        self.context.console = self
-
-        # then reference through the string format (dunno how else to get the event...)
-        self.document.AddEventListener(
-            'keydown', 'document.context.console.handleKeyDown(event)', True)
-        self.document.AddEventListener(
-            'textinput', 'document.context.console.handleTextInput(event)', True)
-
-        self.consolePrompt = "C:\\>"
-
-        self.input = ""
-        self.lastLine = None
-
-        self.blinkState = False
-        self.queueBlinkCursor()
-
-        self.document.Show()
-
-    def queueBlinkCursor(self):
-        self.base.taskMgr.doMethodLater(0.2, self.blinkCursor, 'blinkCursor')
-
-    def blinkCursor(self, task):
-        self.blinkState = not self.blinkState
-        if self.editMode:
-            self.updateEditLine(self.input)
-        self.queueBlinkCursor()
-
-    def escape(self, text):
-        return text. \
-                replace('<', '&lt;'). \
-                replace('>', '&gt;'). \
-                replace('"', '&quot;')
-
-    def addLine(self, text):
-        curKids = list(self.textEl.child_nodes)
-        while len(curKids) >= self.rows:
-            self.textEl.RemoveChild(curKids[0])
-            curKids = curKids[1:]
-
-        line = self.document.CreateTextNode(self.escape(text) + '\n')
-        self.textEl.AppendChild(line)
-        self.lastLine = line
-
-    def addLines(self, lines):
-        for line in lines:
-            self.addLine(line)
-
-    def updateEditLine(self, newInput=''):
-        newText = self.consolePrompt + newInput
-        self.lastLine.text = self.escape(newText) + (self.blinkState and '_' or '')
-        self.input = newInput
-
-    def scroll(self):
-        self.blinkState = False
-        self.updateEditLine(self.input + '\n')
-
-    def handleKeyDown(self, event):
-        """
-        Handle control keys
-        """
-        keyId = event.parameters['key_identifier']
-        if not self.editMode:
-            if keyId == rocket.key_identifier.PAUSE:
-                if event.parameters['ctrl_key']:
-                    self.commandHandler(None)
-
-            return
-
-        if keyId == rocket.key_identifier.RETURN:
-            # emit line without cursor
-            self.scroll()
-
-            # handle command
-            self.commandHandler(self.input)
-
-            if self.editMode:
-                # start with new "command"
-                self.addLine(self.consolePrompt)
-                self.updateEditLine("")
-
-        elif keyId == rocket.key_identifier.BACK:
-            self.updateEditLine(self.input[0:-1])
-
-    def handleTextInput(self, event):
-        if not self.editMode:
-            return
-
-        # handle normal text character
-        data = event.parameters['data']
-        if 32 <= data < 128:
-            self.updateEditLine(self.input + chr(data))
-
-    def newEditLine(self):
-        self.addLine("")
-        self.updateEditLine()
-
-    def cls(self):
-        curKids = list(self.textEl.child_nodes)
-        for kid in curKids:
-            self.textEl.RemoveChild(kid)

+ 0 - 410
samples/rocket-console/main.py

@@ -1,410 +0,0 @@
-"""
-Show how to use libRocket in Panda3D.
-"""
-import sys
-from panda3d.core import loadPrcFile, loadPrcFileData, Point3,Vec4, Mat4, LoaderOptions  # @UnusedImport
-from panda3d.core import DirectionalLight, AmbientLight, PointLight
-from panda3d.core import Texture, PNMImage
-from panda3d.core import PandaSystem
-import random
-from direct.interval.LerpInterval import LerpHprInterval, LerpPosInterval, LerpFunc
-from direct.showbase.ShowBase import ShowBase
-
-# workaround: https://www.panda3d.org/forums/viewtopic.php?t=10062&p=99697#p99054
-#from panda3d import rocket
-import _rocketcore as rocket
-
-from panda3d.rocket import RocketRegion, RocketInputHandler
-
-loadPrcFileData("", "model-path $MAIN_DIR/assets")
-
-import console
-
-global globalClock
-
-class MyApp(ShowBase):
-
-    def __init__(self):
-        ShowBase.__init__(self)
-
-        self.win.setClearColor(Vec4(0.2, 0.2, 0.2, 1))
-
-        self.disableMouse()
-
-        self.render.setShaderAuto()
-
-        dlight = DirectionalLight('dlight')
-        alight = AmbientLight('alight')
-        dlnp = self.render.attachNewNode(dlight)
-        alnp = self.render.attachNewNode(alight)
-        dlight.setColor((0.8, 0.8, 0.5, 1))
-        alight.setColor((0.2, 0.2, 0.2, 1))
-        dlnp.setHpr(0, -60, 0)
-        self.render.setLight(dlnp)
-        self.render.setLight(alnp)
-
-        # Put lighting on the main scene
-        plight = PointLight('plight')
-        plnp = self.render.attachNewNode(plight)
-        plnp.setPos(0, 0, 10)
-        self.render.setLight(plnp)
-        self.render.setLight(alnp)
-
-        self.loadRocketFonts()
-
-        self.loadingTask = None
-
-        #self.startModelLoadingAsync()
-        self.startModelLoading()
-
-        self.inputHandler = RocketInputHandler()
-        self.mouseWatcher.attachNewNode(self.inputHandler)
-
-        self.openLoadingDialog()
-
-    def loadRocketFonts(self):
-        """ Load fonts referenced from e.g. 'font-family' RCSS directives.
-
-        Note: the name of the font as used in 'font-family'
-        is not always the same as the filename;
-        open the font in your OS to see its display name.
-        """
-        rocket.LoadFontFace("modenine.ttf")
-
-
-    def startModelLoading(self):
-        self.monitorNP = None
-        self.keyboardNP = None
-        self.loadingError = False
-
-        self.taskMgr.doMethodLater(1, self.loadModels, 'loadModels')
-
-    def loadModels(self, task):
-        self.monitorNP = self.loader.loadModel("monitor")
-        self.keyboardNP = self.loader.loadModel("takeyga_kb")
-
-    def startModelLoadingAsync(self):
-        """
-        NOTE: this seems to invoke a few bugs (crashes, sporadic model
-        reading errors, etc) so is disabled for now...
-        """
-        self.monitorNP = None
-        self.keyboardNP = None
-        self.loadingError = False
-
-        # force the "loading" to take some time after the first run...
-        options = LoaderOptions()
-        options.setFlags(options.getFlags() | LoaderOptions.LFNoCache)
-
-        def gotMonitorModel(model):
-            if not model:
-                self.loadingError = True
-            self.monitorNP = model
-
-        self.loader.loadModel("monitor", loaderOptions=options, callback=gotMonitorModel)
-
-        def gotKeyboardModel(model):
-            if not model:
-                self.loadingError = True
-            self.keyboardNP = model
-
-        self.loader.loadModel("takeyga_kb", loaderOptions=options, callback=gotKeyboardModel)
-
-    def openLoadingDialog(self):
-        self.userConfirmed = False
-
-        self.windowRocketRegion = RocketRegion.make('pandaRocket', self.win)
-        self.windowRocketRegion.setActive(1)
-
-        self.windowRocketRegion.setInputHandler(self.inputHandler)
-
-        self.windowContext = self.windowRocketRegion.getContext()
-
-        self.loadingDocument = self.windowContext.LoadDocument("loading.rml")
-        if not self.loadingDocument:
-            raise AssertionError("did not find loading.rml")
-
-        self.loadingDots = 0
-        el = self.loadingDocument.GetElementById('loadingLabel')
-        self.loadingText = el.first_child
-        self.stopLoadingTime = globalClock.getFrameTime() + 3
-        self.loadingTask = self.taskMgr.add(self.cycleLoading, 'doc changer')
-
-
-        # note: you may encounter errors like 'KeyError: 'document'"
-        # when invoking events using methods from your own scripts with this
-        # obvious code:
-        #
-        # self.loadingDocument.AddEventListener('aboutToClose',
-        #                                       self.onLoadingDialogDismissed, True)
-        #
-        # A workaround is to define callback methods in standalone Python
-        # files with event, self, and document defined to None.
-        #
-        # see https://www.panda3d.org/forums/viewtopic.php?f=4&t=16412
-        #
-
-        # Or, use this indirection technique to work around the problem,
-        # by publishing the app into the context, then accessing it through
-        # the document's context...
-
-        self.windowContext.app = self
-        self.loadingDocument.AddEventListener('aboutToClose',
-                                              'document.context.app.handleAboutToClose()', True)
-
-        self.loadingDocument.Show()
-
-    def handleAboutToClose(self):
-        self.userConfirmed = True
-        if self.monitorNP and self.keyboardNP:
-            self.onLoadingDialogDismissed()
-
-    def attachCustomRocketEvent(self, document, rocketEventName, pandaHandler, once=False):
-        # handle custom event
-
-        # note: you may encounter errors like 'KeyError: 'document'"
-        # when invoking events using methods from your own scripts with this
-        # obvious code:
-        #
-        # self.loadingDocument.AddEventListener('aboutToClose',
-        #                                       self.onLoadingDialogDismissed, True)
-        #
-        # see https://www.panda3d.org/forums/viewtopic.php?f=4&t=16412
-
-
-        # this technique converts Rocket events to Panda3D events
-
-        pandaEvent = 'panda.' + rocketEventName
-
-        document.AddEventListener(
-            rocketEventName,
-            "messenger.send('" + pandaEvent + "', [event])")
-
-        if once:
-            self.acceptOnce(pandaEvent, pandaHandler)
-        else:
-            self.accept(pandaEvent, pandaHandler)
-
-
-    def cycleLoading(self, task):
-        """
-        Update the "loading" text in the initial window until
-        the user presses Space, Enter, or Escape or clicks (see loading.rxml)
-        or sufficient time has elapsed (self.stopLoadingTime).
-        """
-        text = self.loadingText
-
-        now = globalClock.getFrameTime()
-        if self.monitorNP and self.keyboardNP:
-            text.text = "Ready"
-            if now > self.stopLoadingTime or self.userConfirmed:
-                self.onLoadingDialogDismissed()
-                return task.done
-        elif self.loadingError:
-            text.text = "Assets not found"
-        else:
-            count = 5
-            intv = int(now * 4) % count  # @UndefinedVariable
-            text.text = "Loading" + ("." * (1+intv)) + (" " * (2 - intv))
-
-        return task.cont
-
-    def onLoadingDialogDismissed(self):
-        """ Once a models are loaded, stop 'loading' and proceed to 'start' """
-        if self.loadingDocument:
-            if self.loadingTask:
-                self.taskMgr.remove(self.loadingTask)
-            self.loadingTask = None
-
-            self.showStarting()
-
-    def fadeOut(self, element, time):
-        """ Example updating RCSS attributes from code
-        by modifying the 'color' RCSS attribute to slowly
-        change from solid to transparent.
-
-        element: the Rocket element whose style to modify
-        time: time in seconds for fadeout
-        """
-
-        # get the current color from RCSS effective style
-        color = element.style.color
-        # convert to RGBA form
-        prefix = color[:color.rindex(',')+1].replace('rgb(', 'rgba(')
-
-        def updateAlpha(t):
-            # another way of setting style on a specific element
-            attr = 'color: ' + prefix + str(int(t)) +');'
-            element.SetAttribute('style', attr)
-
-        alphaInterval = LerpFunc(updateAlpha,
-                             duration=time,
-                             fromData=255,
-                             toData=0,
-                             blendType='easeIn')
-
-        return alphaInterval
-
-    def showStarting(self):
-        """ Models are loaded, so update the dialog,
-        fade out, then transition to the console. """
-        self.loadingText.text = 'Starting...'
-
-        alphaInterval = self.fadeOut(self.loadingText, 0.5)
-        alphaInterval.setDoneEvent('fadeOutFinished')
-
-        def fadeOutFinished():
-            if self.loadingDocument:
-                self.loadingDocument.Close()
-                self.loadingDocument = None
-                self.createConsole()
-
-        self.accept('fadeOutFinished', fadeOutFinished)
-
-        alphaInterval.start()
-
-    def createConsole(self):
-        """ Create the in-world console, which displays
-        a RocketRegion in a GraphicsBuffer, which appears
-        in a Texture on the monitor model. """
-
-        self.monitorNP.reparentTo(self.render)
-        self.monitorNP.setScale(1.5)
-
-        self.keyboardNP.reparentTo(self.render)
-        self.keyboardNP.setHpr(-90, 0, 15)
-        self.keyboardNP.setScale(20)
-
-        self.placeItems()
-
-        self.setupRocketConsole()
-
-        # re-enable mouse
-        mat=Mat4(self.camera.getMat())
-        mat.invertInPlace()
-        self.mouseInterfaceNode.setMat(mat)
-        self.enableMouse()
-
-    def placeItems(self):
-        self.camera.setPos(0, -20, 0)
-        self.camera.setHpr(0, 0, 0)
-        self.monitorNP.setPos(0, 0, 1)
-        self.keyboardNP.setPos(0, -5, -2.5)
-
-
-    def setupRocketConsole(self):
-        """
-        Place a new rocket window onto a texture
-        bound to the front of the monitor.
-        """
-        self.win.setClearColor(Vec4(0.5, 0.5, 0.8, 1))
-
-        faceplate = self.monitorNP.find("**/Faceplate")
-        assert faceplate
-
-        mybuffer = self.win.makeTextureBuffer("Console Buffer", 1024, 512)
-        tex = mybuffer.getTexture()
-        tex.setMagfilter(Texture.FTLinear)
-        tex.setMinfilter(Texture.FTLinear)
-
-        faceplate.setTexture(tex, 1)
-
-        self.rocketConsole = RocketRegion.make('console', mybuffer)
-        self.rocketConsole.setInputHandler(self.inputHandler)
-
-        self.consoleContext = self.rocketConsole.getContext()
-        self.console = console.Console(self, self.consoleContext, 40, 13, self.handleCommand)
-
-        self.console.addLine("Panda DOS")
-        self.console.addLine("type 'help'")
-        self.console.addLine("")
-
-        self.console.allowEditing(True)
-
-    def handleCommand(self, command):
-        if command is None:
-            # hack for Ctrl-Break
-            self.spewInProgress = False
-            self.console.addLine("*** break ***")
-            self.console.allowEditing(True)
-            return
-
-        command = command.strip()
-        if not command:
-            return
-
-        tokens = [x.strip() for x in command.split(' ')]
-        command = tokens[0].lower()
-
-        if command == 'help':
-            self.console.addLines([
-                "Sorry, this is utter fakery.",
-                "You won't get much more",
-                "out of this simulation unless",
-                "you program it yourself. :)"
-            ])
-        elif command == 'dir':
-            self.console.addLines([
-                "Directory of C:\\:",
-                "HELP     COM    72 05-06-2015 14:07",
-                "DIR      COM   121 05-06-2015 14:11",
-                "SPEW     COM   666 05-06-2015 15:02",
-                "   2 Files(s)  859 Bytes.",
-                "   0 Dirs(s)  7333 Bytes free.",
-                ""])
-        elif command == 'cls':
-            self.console.cls()
-        elif command == 'echo':
-            self.console.addLine(' '.join(tokens[1:]))
-        elif command == 'ver':
-            self.console.addLine('Panda DOS v0.01 in Panda3D ' + PandaSystem.getVersionString())
-        elif command == 'spew':
-            self.startSpew()
-        elif command == 'exit':
-            self.console.setPrompt("System is shutting down NOW!")
-            self.terminateMonitor()
-        else:
-            self.console.addLine("command not found")
-
-    def startSpew(self):
-        self.console.allowEditing(False)
-        self.console.addLine("LINE NOISE 1.0")
-        self.console.addLine("")
-
-        self.spewInProgress = True
-
-        # note: spewage always occurs in 'doMethodLater';
-        # time.sleep() would be pointless since the whole
-        # UI would be frozen during the wait.
-        self.queueSpew(2)
-
-    def queueSpew(self, delay=0.1):
-        self.taskMgr.doMethodLater(delay, self.spew, 'spew')
-
-    def spew(self, task):
-        # generate random spewage, just like on TV!
-        if not self.spewInProgress:
-            return
-
-        def randchr():
-            return chr(int(random.random() < 0.25 and 32 or random.randint(32, 127)))
-
-        line = ''.join([randchr() for _ in range(40) ])
-
-        self.console.addLine(line)
-        self.queueSpew()
-
-    def terminateMonitor(self):
-        alphaInterval = self.fadeOut(self.console.getTextContainer(), 2)
-
-        alphaInterval.setDoneEvent('fadeOutFinished')
-
-        def fadeOutFinished():
-            sys.exit(0)
-
-        self.accept('fadeOutFinished', fadeOutFinished)
-
-        alphaInterval.start()
-
-app = MyApp()
-app.run()