|
|
|
Return to Panda Features in Development
by rdb » Sat Jan 07, 2012 2:54 pm
Checked in experimental support. Please try it out and let me know how it goes.
Not all key events are supported yet, but text input and mouse input should work. Haven't tested that aspect extensively though.
Use it like this:
- Code: Select all
from panda3d.rocket import *
r = RocketRegion.make('pandaRocket', base.win) r.setActive(1)
ih = RocketInputHandler() base.mouseWatcher.attachNewNode(ih) r.setInputHandler(ih)
context = r.getContext()
The context returned by getContext() is a Boost::Python-wrapped libRocket context object, but you'll need to have libRocket built with Python bindings for it to work (otherwise it'll just return None). You can just go on to call context.LoadDocument() or so.
-
rdb
-
- Posts: 8543
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by powerpup118 » Sun Jan 08, 2012 6:03 pm
Hi rdb,
I'm attempting to play with and try your integration, I started off by installing the latest (today's) buildbot version of panda..
After that I downloaded the libRocket source package from their website, ran cmake.. make.. and then.. make install..
After that was all finished, I made a python script (with your code above, this is really non-important though)
while importing panda3d.rocket I get this error:
- Code: Select all
DirectStart: Starting the game. Known pipe types: glxGraphicsPipe (all display modules loaded.) Traceback (most recent call last): File "test.py", line 3, in <module> from panda3d.rocket import * File "/usr/share/panda3d/panda3d.py", line 193, in __getattr__ for obj in dir(self.__manager__.libimport(lib)): File "/usr/share/panda3d/panda3d.py", line 124, in libimport raise ImportError, message ImportError: DLL loader cannot find libp3rocket.
which to me says that libp3rocket.so is missing, meaning the buildbot version never compiled it, which is odd (I would think), I guess I dunno too much about this, could you advise me a bit?
OS is Ubuntu Natty, latest panda buildbot from today.
Thank you,
~powerpup118
-

powerpup118
-
- Posts: 325
- Joined: Sat Apr 17, 2010 11:59 pm
by morgul » Sun Jan 08, 2012 9:44 pm
After I finally got the latest cvs compiling (thanks for the help, rdb), I started working on a little test application. Unfortunately, it seems that I'm running into a segfault.
Here's my test application:
- Code: Select all
from direct.showbase.ShowBase import ShowBase import rocket from panda3d.rocket import *
class MyApp(ShowBase):
def __init__(self): ShowBase.__init__(self)
app = MyApp() app.run()
I'm not even working with rocket; I'm just importing it. Curious, I tried the import on the commandline: - Code: Select all
[morgul:archbang] ~/d/rocketTest > python2 Python 2.7.2 (default, Nov 21 2011, 17:24:32) [GCC 4.6.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from panda3d.rocket import * fish: Job 1, “python2” terminated by signal SIGSEGV (Address boundary error)
I don't have rocket or panda built with debugging symbols, atm, so I can't give you a useful backtrace. This happens on Ubuntu 11.10 64bit and Arch 64bit. (I don't have any 32bit installs atm to test with.) librocket is the latest release, built by hand. (On arch, a little bit of tweaking to cmake needed to be performed in order to get it to install for python2 instead of python3. On ubuntu, it's absolute stock)
Let me know if there's anything else (besides a decent backtrace) you'd like for hunting this down.
--Morgul
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by morgul » Sun Jan 08, 2012 9:48 pm
powerpup118 wrote:...while importing panda3d.rocket I get this error...
I tried that this morning, and got the same error. I'm guessing it's related to the issues I reported over IRC today. (The latest cvs wasn't compiling for me with makepanda. It's just a guess, but I'd imagine that'd be why the buildbot didn't build support for it correctly.)
I'm guessing the one for tomorrow will be fixed, but then I think you're likely to run into the segfault I'm running into, atm.
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by whitelynx » Sun Jan 08, 2012 10:53 pm
I expanded morgul's test app and ran it in gdb, to try and figure out where it's failing. Here's my version of the app:
- Code: Select all
#!/usr/bin/env python2 from direct.showbase.ShowBase import ShowBase
print "Imported ShowBase."
import rocket
print "Imported rocket."
from panda3d.rocket import RocketRegion, RocketInputHandler
print "Imported panda3d.rocket."
class MyApp(ShowBase): def __init__(self): ShowBase.__init__(self)
print "ShowBase init finished."
r = RocketRegion.make('pandaRocket', self.win) r.setActive(1)
print "RocketRegion created."
ih = RocketInputHandler() self.mouseWatcher.attachNewNode(ih) r.setInputHandler(ih)
print "RocketInputHandler created."
context = r.getContext()
print "Got rocket context."
app = MyApp() app.run()
Here's the gdb session: - Code: Select all
# gdb --args python2 p3d-rocket-test.py GNU gdb (GDB) 7.3.1 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /usr/bin/python2...(no debugging symbols found)...done. (gdb) r Starting program: /usr/bin/python2 p3d-rocket-test.py [Thread debugging using libthread_db enabled] Imported ShowBase. Imported rocket.
Program received signal SIGSEGV, Segmentation fault. 0x0000edb6 in ?? () (gdb) bt #0 0x0000edb6 in ?? () #1 0xb78456f7 in initlibp3rocket () from /usr/lib/panda3d/libp3rocket.so #2 0xb7efb0ec in _PyImport_LoadDynamicModule () from /usr/lib/libpython2.7.so.1.0 #3 0xb7ef8df0 in load_module () from /usr/lib/libpython2.7.so.1.0 #4 0xb7ef9479 in import_submodule () from /usr/lib/libpython2.7.so.1.0 #5 0xb7ef96f9 in load_next () from /usr/lib/libpython2.7.so.1.0 #6 0xb7ef9ce6 in import_module_level.isra.9 () from /usr/lib/libpython2.7.so.1.0 #7 0xb7efa257 in PyImport_ImportModuleLevel () from /usr/lib/libpython2.7.so.1.0 #8 0xb7edeb33 in builtin___import__ () from /usr/lib/libpython2.7.so.1.0 #9 0xb7e8744d in PyCFunction_Call () from /usr/lib/libpython2.7.so.1.0 #10 0xb7ee6556 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0 #11 0xb7ee6a1b in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0 #12 0xb7ee7cf2 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0 #13 0xb7e71fac in function_call () from /usr/lib/libpython2.7.so.1.0 #14 0xb7e4b184 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0 #15 0xb7e5aa40 in instancemethod_call () from /usr/lib/libpython2.7.so.1.0 #16 0xb7e4b184 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0 #17 0xb7e4b6c7 in PyObject_CallFunctionObjArgs () from /usr/lib/libpython2.7.so.1.0 #18 0xb7e9fb25 in call_attribute () from /usr/lib/libpython2.7.so.1.0 #19 0xb7ea740d in slot_tp_getattr_hook () from /usr/lib/libpython2.7.so.1.0 #20 0xb7e8922f in PyObject_GetAttr () from /usr/lib/libpython2.7.so.1.0 #21 0xb7ee343a in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0 #22 0xb7ee7cf2 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0 #23 0xb7ee7e63 in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0 #24 0xb7f01b4c in run_mod () from /usr/lib/libpython2.7.so.1.0 #25 0xb7f02b0d in PyRun_FileExFlags () from /usr/lib/libpython2.7.so.1.0 #26 0xb7f036b9 in PyRun_SimpleFileExFlags () from /usr/lib/libpython2.7.so.1.0 #27 0xb7f0437c in PyRun_AnyFileExFlags () from /usr/lib/libpython2.7.so.1.0 #28 0xb7f15594 in Py_Main () from /usr/lib/libpython2.7.so.1.0 #29 0x08048547 in main () (gdb)
-

whitelynx
-
- Posts: 54
- Joined: Wed Dec 31, 2008 2:56 pm
- Location: Lubbock, TX
-
by rdb » Mon Jan 09, 2012 5:36 am
I haven't added the libRocket libraries to the buildbots' thirdparty directories yet. You'll need to compile from source to get libRocket support, until I get around to building the libRocket libraries for every platform.
About your code: there's no need to do "import rocket". Instead, the panda3d.rocket module internally loads the Rocket Python bindings, and exposes the libRocket classes under that module.
I don't think it can hurt to import it, though, but it's a good idea to rule out that that's not what's causing the issue here.
And of course, make sure that libRocket is compiled with the exact same Python version as Panda is. Eg if Panda is compiled for Python 2.7, make sure that your libRocket build is, too. Python's x.x versions aren't ABI-compatible with each other.
I'm also interested in whether or not the issue also comes up when you put "support-threads #f" in your Config.prc file.
-
rdb
-
- Posts: 8543
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by morgul » Mon Jan 09, 2012 10:46 am
rdb wrote:About your code: there's no need to do "import rocket". Instead, the panda3d.rocket module internally loads the Rocket Python bindings, and exposes the libRocket classes under that module. I don't think it can hurt to import it, though, but it's a good idea to rule out that that's not what's causing the issue here.
I can confirm that doesn't affect the issue. I pasted the wrong code; I'd added that for testing, and didn't mean to post the version with the 'import rocket' line. It still segfaults without that.
I'll test the threads config change shortly, and report back.
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by morgul » Mon Jan 09, 2012 12:00 pm
rdb wrote:I'm also interested in whether or not the issue also comes up when you put "support-threads #f" in your Config.prc file.
Just managed to get this tested, and it doesn't seem to make any difference. (What I can confirm is that this now happens on 4 different machines I've tested on.)
I'll try an find some time to debug later, and let you know what I find.
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by GrizzLyCRO » Tue Jan 10, 2012 4:31 pm
Could someone throw quick guide what goes where with makepanda and linux?
I have natty 64 (mint 11) and i would like to give it a shot, but i dont know which stuff from librocket source i need to copy, and where.
-

GrizzLyCRO
-
- Posts: 301
- Joined: Tue Dec 16, 2008 4:03 pm
- Location: Croatia
by rdb » Wed Jan 11, 2012 8:18 am
Just build libRocket with Python wrappers, and install it onto your system, and makepanda should be able to find it.
-
rdb
-
- Posts: 8543
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by GrizzLyCRO » Wed Jan 11, 2012 12:04 pm
Ok, that worked i think, now i dont get could not find rocket error (for example how i get for bullet in next code sample).
But there is other problem, od i need to checkout some other branch (i am using whatever is default)
- Code: Select all
makepanda/makepanda.py --nothing --use-python --use-gl --use-tinydisplay --installer --threads 4 --use-bullet --use-freetype --use-directcam --use-rocket Generating library cache... WARNING: Could not locate thirdparty package bullet, excluding from build Generating dependencies... Storing dependency cache. Elapsed Time: 1 sec Could not find source file: p3rocket_composite1.cxx Build terminated.
EDIT1: i am using librocket 1.2.1 source release, could not get latest github master to build
-

GrizzLyCRO
-
- Posts: 301
- Joined: Tue Dec 16, 2008 4:03 pm
- Location: Croatia
by rdb » Wed Jan 11, 2012 12:38 pm
You're not using the latest CVS version of Panda3D. Update the panda/src/rocket directory.
-
rdb
-
- Posts: 8543
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by morgul » Thu Jan 19, 2012 12:18 am
Just wanted to pop a quick note: I'm still struggling with the segfault; it appears that nothing in init_librocket() in config_rocket.cxx is being called. (Even put a printf as the first line in that; doesn't ever print.)
Now I'm tracing back through some of the interogate/dtools code... (just don't have as much time to poke this as I would like). Also, I should note that I don't have debug symbols built; that's proving to be annoyingly time consuming.
I'm pretty sure that in 'built/tmp/libp3rocket_module.cxx'(generated interogate code)
- Code: Select all
Dtool_PyModuleInitHelper( defs, "libp3rocket");
isn't getting called. Which puts the segfault in: - Code: Select all
LibrayDef *defs[] = {&libp3rocket_moddef, NULL };
Here's the full generated file: - Code: Select all
#include "dtoolbase.h" #include "interrogate_request.h"
#undef _POSIX_C_SOURCE #include "py_panda.h"
extern LibrayDef libp3rocket_moddef ; #ifdef _WIN32 extern "C" __declspec(dllexport) void initlibp3rocket(); #else extern "C" void initlibp3rocket(); #endif
void initlibp3rocket() { LibrayDef *defs[] = {&libp3rocket_moddef, NULL }; Dtool_PyModuleInitHelper( defs, "libp3rocket");
}
Any suggestions on where to look next would be appreciated.
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by drwr » Thu Jan 19, 2012 1:05 am
Sometimes a segfault will cause printf statements that already happened not to print (because the printf output is still cached and hasn't yet been written to the output stream), so you have to be careful. You should use fprintf(stderr) instead of printf(), in general, because stderr is flushed automatically, so this problem is less likely with fprintf(stderr). Or, using C++ interfaces, use cerr instead of cout.
But assuming you're not getting tricked by printf caching, and that init_librocket() really isn't getting called, that doesn't necessarily mean that the crash is occurring earlier in init_libp3rocket(). Perhaps the crash is occurring even before that function is getting called (in some static init operation, for instance). This is common when running against a slightly different version than the one that was compiled against, for instance, as structures end up different sizes and memory gets written to incorrectly. To really prove that the crash is occurring in init_libp3rocket(), you need to put an fprintf() in the beginning of that function, and an fprintf() at the end of that function.
David
-
drwr
-
- Posts: 11253
- Joined: Fri Feb 13, 2004 12:42 pm
- Location: Glendale, CA
by morgul » Thu Jan 19, 2012 1:11 am
I was actually using fflush(stdout); after the printfs, to flush the cache, just in case that was happening.
Whitelynx got debug symbols built on his machine, and we're looking through gdb now. It definitely seems to be segfaulting on
- Code: Select all
LibrayDef *defs[] = {&libp3rocket_moddef, NULL };
We'll post the backtrace shortly.
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by whitelynx » Thu Jan 19, 2012 3:21 am
Here's the backtrace (bt full) from the segfault on my laptop:
http://paste.skewedaspect.com/show/88/
And here's the code I'm using for the test: (probably not the same as what morgul was running, but it demonstrates the same issue)
- Code: Select all
#!/usr/bin/env python2 from direct.showbase.ShowBase import ShowBase
print "Imported ShowBase."
import rocket
print "Imported rocket."
from panda3d.rocket import RocketRegion, RocketInputHandler
print "Imported panda3d.rocket."
class MyApp(ShowBase): def __init__(self): ShowBase.__init__(self)
print "ShowBase init finished."
r = RocketRegion.make('pandaRocket', self.win) r.setActive(1)
print "RocketRegion created."
ih = RocketInputHandler() self.mouseWatcher.attachNewNode(ih) r.setInputHandler(ih)
print "RocketInputHandler created."
context = r.getContext()
print "Got rocket context."
app = MyApp() app.run()
EDIT: New backtrace after recompiling Panda: http://paste.skewedaspect.com/show/89/
As far as I'm aware no actual code was changed here, so I'm not sure why it's segfaulting in a different spot than before.
-

whitelynx
-
- Posts: 54
- Joined: Wed Dec 31, 2008 2:56 pm
- Location: Lubbock, TX
-
by rdb » Thu Jan 19, 2012 4:49 am
Hmm, I'm still baffled. What happens if you do this (on Linux only):
- Code: Select all
import libp3rocket print "imported libp3rocket" import rocket print "imported rocket" from panda3d.rocket import *
At which line does it fail?
-
rdb
-
- Posts: 8543
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by morgul » Thu Jan 19, 2012 9:21 am
Well, this is interesting:
- Code: Select all
[morgul:narayana] ~ > python Python 2.7.2+ (default, Oct 4 2011, 20:06:09) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import libp3rocket Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: /usr/lib64/panda3d/libp3rocket.so: undefined symbol: _ZN5boost6python23throw_error_already_setEv
So, import libp3rocket fails, with an error about a missing symbol... Any ideas?
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by rdb » Thu Jan 19, 2012 10:38 am
Oh, I suppose that is to be expected if your librocket is compiled as a static library instead of a shared one. Bah, this is a mess.
-
rdb
-
- Posts: 8543
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by morgul » Thu Jan 19, 2012 10:50 pm
Well, still no success. I've decided to stop banging my head against this wall. However, I've instead pulled the RocketInputHandler out of the current repo, and have been having some success in integrating it in my standalone solution (pyrokit, mentioned above).
In doing so, I've found some bugs in RocketInputHandler. I'll list them, and then provide a patch.
- libRocket's mouse buttons are 0 based, not 1 based.
- _keys was not being cleared properly. (copy/paste error. _mouse_buttons was being cleared instead.)
- function keys were not being passed through.
- modifiers should also send key up/down events.
- libRocket accepts/expects key up/down events for 0-9 and a-z, in addition to the text input. (Not required, but allows for listening for keypress events)
Here is the patch:
- Code: Select all
Index: panda/src/rocket/rocketInputHandler.cxx =================================================================== RCS file: /cvsroot/panda3d/panda/src/rocket/rocketInputHandler.cxx,v retrieving revision 1.1 diff -u -r1.1 rocketInputHandler.cxx --- panda/src/rocket/rocketInputHandler.cxx 7 Jan 2012 19:02:41 -0000 1.1 +++ panda/src/rocket/rocketInputHandler.cxx 20 Jan 2012 03:53:40 -0000 @@ -176,6 +176,83 @@ _keys[KI_INSERT] = down; } else if (be._button == KeyboardButton::del()) { _keys[KI_DELETE] = down; + } else if (be._button == KeyboardButton::caps_lock()) { + _keys[KI_CAPITAL] = down; + } else if (be._button == KeyboardButton::f1()) { + _keys[KI_F1] = down; + } else if (be._button == KeyboardButton::f10()) { + _keys[KI_F10] = down; + } else if (be._button == KeyboardButton::f11()) { + _keys[KI_F11] = down; + } else if (be._button == KeyboardButton::f12()) { + _keys[KI_F12] = down; + } else if (be._button == KeyboardButton::f13()) { + _keys[KI_F13] = down; + } else if (be._button == KeyboardButton::f14()) { + _keys[KI_F14] = down; + } else if (be._button == KeyboardButton::f15()) { + _keys[KI_F15] = down; + } else if (be._button == KeyboardButton::f16()) { + _keys[KI_F16] = down; + } else if (be._button == KeyboardButton::f2()) { + _keys[KI_F2] = down; + } else if (be._button == KeyboardButton::f3()) { + _keys[KI_F3] = down; + } else if (be._button == KeyboardButton::f4()) { + _keys[KI_F4] = down; + } else if (be._button == KeyboardButton::f5()) { + _keys[KI_F5] = down; + } else if (be._button == KeyboardButton::f6()) { + _keys[KI_F6] = down; + } else if (be._button == KeyboardButton::f7()) { + _keys[KI_F7] = down; + } else if (be._button == KeyboardButton::f8()) { + _keys[KI_F8] = down; + } else if (be._button == KeyboardButton::f9()) { + _keys[KI_F9] = down; + } else if (be._button == KeyboardButton::help()) { + _keys[KI_HELP] = down; + } else if (be._button == KeyboardButton::lalt()) { + _keys[KI_LMENU] = down; + } else if (be._button == KeyboardButton::lcontrol()) { + _keys[KI_LCONTROL] = down; + } else if (be._button == KeyboardButton::lshift()) { + _keys[KI_LSHIFT] = down; + } else if (be._button == KeyboardButton::meta()) { + // Not sure which of these is correct... + //_keys[KI_LWIN] = down; + _keys[KI_LMETA] = down; + } else if (be._button == KeyboardButton::num_lock()) { + _keys[KI_NUMLOCK] = down; + } else if (be._button == KeyboardButton::page_down()) { + _keys[KI_NEXT] = down; + } else if (be._button == KeyboardButton::page_up()) { + _keys[KI_PRIOR] = down; + } else if (be._button == KeyboardButton::pause()) { + _keys[KI_PAUSE] = down; + } else if (be._button == KeyboardButton::print_screen()) { + _keys[KI_SNAPSHOT] = down; + } else if (be._button == KeyboardButton::ralt()) { + _keys[KI_RMENU] = down; + } else if (be._button == KeyboardButton::rcontrol()) { + _keys[KI_RCONTROL] = down; + } else if (be._button == KeyboardButton::rshift()) { + _keys[KI_RSHIFT] = down; + } else if (be._button == KeyboardButton::scroll_lock()) { + _keys[KI_SCROLL] = down; + /* What is shift_lock? It's not caps_lock apparently... + } else if (be._button == KeyboardButton::shift_lock()) { + _keys[KI_SHIFT_LOCK] = down; + */ + } else { + // libRocket accepts/expects keypress events + // as well as text input + char asciiChar = be._button.get_ascii_equivalent(); + if ('0' <= asciiChar && asciiChar <= '9') { + _keys[asciiChar - '0' + KI_0] = down; + } else if ('a' <= asciiChar && asciiChar <= 'z') { + _keys[asciiChar - 'a' + KI_A] = down; + } } } } @@ -204,9 +281,9 @@ ButtonActivityMap::const_iterator it; for (it = _mouse_buttons.begin(); it != _mouse_buttons.end(); ++it) { if (it->second) { - context->ProcessMouseButtonDown(it->first, _modifiers); + context->ProcessMouseButtonDown(it->first - 1, _modifiers); } else { - context->ProcessMouseButtonUp(it->first, _modifiers); + context->ProcessMouseButtonUp(it->first - 1, _modifiers); } } _mouse_buttons.clear(); @@ -226,7 +303,7 @@ context->ProcessKeyUp((KeyIdentifier) it->first, _modifiers); } } - _mouse_buttons.clear(); + _keys.clear(); } if (_text_input.size() > 0) {
I tried to match the code styling as much as I could, and I've verified this code works in pyrokit; can't test it in panda. Let me know if there's anything you need clarification on.
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by Burstaholic » Tue Jan 24, 2012 10:08 pm
Working with Morgul I've tried this on my computer (Ubuntu 11.10) and got a good bit farther, but ran into another indecipherable error.
Note: Morgul's patch above has been accepted and merged with the libRocket tree on GitHub.
I found that I can reproduce the segfault issue by calling:
- Code: Select all
from panda3d.rocket import *
but if I use: - Code: Select all
from panda3d import rocket
this succeeds without incident. Where I run into trouble is trying to make any calls to rocket. This results in an Undefined Symbol error. Here's my current test app: - Code: Select all
from direct.showbase.ShowBase import ShowBase from panda3d import rocket
class MyApp(ShowBase):
def __init__(self): ShowBase.__init__(self) r = rocket.RocketRegion.make('pandaRocket', self.win) r.setActive(1)
ih = rocket.RocketInputHandler() self.mouseWatcher.attachNewNode(ih) r.setInputHandler(ih)
context = r.getContext() app = MyApp() app.run()
And he's the error I receive: - Code: Select all
Known pipe types: glxGraphicsPipe (all display modules loaded.) :audio(error): load_dso(libp3openal_audio.so) failed, will use NullAudioManager :audio(error): No error. Traceback (most recent call last): File "test.py", line 16, in <module> app = MyApp() File "test.py", line 8, in __init__ r = rocket.RocketRegion.make('pandaRocket', base.win) File "/usr/share/panda3d/panda3d.py", line 202, in __getattr__ mod = self.__manager__.libimport(lib) File "/usr/share/panda3d/panda3d.py", line 107, in libimport return __import__(name) ImportError: /usr/lib64/panda3d/libp3rocket.so: undefined symbol: _ZN5boost6python23throw_error_already_setEv
So, I am able to actually import libRocket and attempt to use it, but then that attempt immediately fails. Suggestions, anyone? Thanks in advance.
-

Burstaholic
-
- Posts: 5
- Joined: Fri Jan 20, 2012 10:51 am
by rdb » Wed Jan 25, 2012 5:33 am
@morgul: thanks for the patch, I'll review and check it in shortly.
I don't understand why you're mapping lalt and ralt to LMENU and RMENU. The menu key is different from the alt key, isn't it?
libRocket handles modifier keys using a separate bitmask, I think these extra definitions are for specialised keyboards.
@Burstaholic: Interesting that the other import method (which uses lazy loading) does work. Maybe it has something to do with ShowBase being initialised before the library is actually being loaded, the first time you create a RocketRegion?
As for the error, sorry, that's my fault. I forgot to add boost_python to the libraries to link to in makepanda.
What do you mean with "GitHub"? I wasn't aware that there was any git repository for my libRocket implementation?
Oh, and welcome to the forums! 
-
rdb
-
- Posts: 8543
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by morgul » Wed Jan 25, 2012 9:10 am
rdb wrote:I don't understand why you're mapping lalt and ralt to LMENU and RMENU. The menu key is different from the alt key, isn't it? libRocket handles modifier keys using a separate bitmask, I think these extra definitions are for specialised keyboards.
Rocket actually seems a bit dumb about, well, everything. (I don't mean dumb as in 'this is stupid', rather, dumb as in 'simple'.) From what I can tell, the only way to, say, pop a menu when the user pressed the windows key, is to also send the keydown for the windows key. Once I realized that, I decided to be as all-inclusive as I could. Why you'd want to trigger logic on the ALT keypress, I don't know, but I figured, why not allow it?
As for R/LALT => R/LMENU... some of the define names are weird in Rocket. I don't have the code infront of me, atm, but I remember trying to puzzle out what alt was, and thinking that since 'Application key' was apparently different from 'menu', R/LMENU must be ALT. I could be dead wrong, but it made sense at the time.
On the subject of input, I've got another patch for you, which I'll be sending as soon as I get in to work. This one fixes issues with text input (The current implementation sends characters for delete and backspace, which royally mess up text input in forms), and adds auto-repeat support for some keys. (Panda's smart about when it sends text, so letters/numbers auto-repeat. Delete/Backspace/Left/Right/Up/Down currently don't, since librocket leaves auto-repeat up to the user.)
And as for Burst's mention of GitHub, I'm pretty sure he got confused; I had a patch fixing librocket's python bindings (the ones in git have been broken since october, it looks like), and that got accepted while he and I were working on things together. I think he thought my patch to input was the patch to rocket, not to panda.
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by Burstaholic » Wed Jan 25, 2012 9:33 am
Yup, got my patches confused. Carry on citizen, nothing to see here 
-

Burstaholic
-
- Posts: 5
- Joined: Fri Jan 20, 2012 10:51 am
by morgul » Wed Jan 25, 2012 11:53 am
EDIT: Just realized this includes my previous patch; sorry about that. Apply this one instead of the previous one.
Here's the new patch:
- Code: Select all
Index: panda/src/rocket/rocketInputHandler.cxx =================================================================== RCS file: /cvsroot/panda3d/panda/src/rocket/rocketInputHandler.cxx,v retrieving revision 1.1 diff -u -r1.1 rocketInputHandler.cxx --- panda/src/rocket/rocketInputHandler.cxx 7 Jan 2012 19:02:41 -0000 1.1 +++ panda/src/rocket/rocketInputHandler.cxx 25 Jan 2012 16:51:25 -0000 @@ -111,6 +111,20 @@ break; case ButtonEvent::T_repeat: + // TODO: More may need to be added later. + if (be._button == KeyboardButton::backspace()) { + _repeated_keys[KI_BACK] = true; + } else if (be._button == KeyboardButton::del()) { + _repeated_keys[KI_DELETE] = true; + } else if (be._button == KeyboardButton::left()) { + _repeated_keys[KI_LEFT] = true; + } else if (be._button == KeyboardButton::up()) { + _repeated_keys[KI_UP] = true; + } else if (be._button == KeyboardButton::right()) { + _repeated_keys[KI_RIGHT] = true; + } else if (be._button == KeyboardButton::down()) { + _repeated_keys[KI_DOWN] = true; + } // end if break; case ButtonEvent::T_up: @@ -126,7 +140,10 @@ break; case ButtonEvent::T_keystroke: - _text_input.push_back(be._keycode); + // Ignore control characters; otherwise, they actually get added to strings in the UI. + if (be._keycode > 0x1F and (be._keycode < 0x7F or be._keycode > 0x9F)){ + _text_input.push_back(be._keycode); + } break; case ButtonEvent::T_resume_down: @@ -176,6 +193,83 @@ _keys[KI_INSERT] = down; } else if (be._button == KeyboardButton::del()) { _keys[KI_DELETE] = down; + } else if (be._button == KeyboardButton::caps_lock()) { + _keys[KI_CAPITAL] = down; + } else if (be._button == KeyboardButton::f1()) { + _keys[KI_F1] = down; + } else if (be._button == KeyboardButton::f10()) { + _keys[KI_F10] = down; + } else if (be._button == KeyboardButton::f11()) { + _keys[KI_F11] = down; + } else if (be._button == KeyboardButton::f12()) { + _keys[KI_F12] = down; + } else if (be._button == KeyboardButton::f13()) { + _keys[KI_F13] = down; + } else if (be._button == KeyboardButton::f14()) { + _keys[KI_F14] = down; + } else if (be._button == KeyboardButton::f15()) { + _keys[KI_F15] = down; + } else if (be._button == KeyboardButton::f16()) { + _keys[KI_F16] = down; + } else if (be._button == KeyboardButton::f2()) { + _keys[KI_F2] = down; + } else if (be._button == KeyboardButton::f3()) { + _keys[KI_F3] = down; + } else if (be._button == KeyboardButton::f4()) { + _keys[KI_F4] = down; + } else if (be._button == KeyboardButton::f5()) { + _keys[KI_F5] = down; + } else if (be._button == KeyboardButton::f6()) { + _keys[KI_F6] = down; + } else if (be._button == KeyboardButton::f7()) { + _keys[KI_F7] = down; + } else if (be._button == KeyboardButton::f8()) { + _keys[KI_F8] = down; + } else if (be._button == KeyboardButton::f9()) { + _keys[KI_F9] = down; + } else if (be._button == KeyboardButton::help()) { + _keys[KI_HELP] = down; + } else if (be._button == KeyboardButton::lalt()) { + _keys[KI_LMENU] = down; + } else if (be._button == KeyboardButton::lcontrol()) { + _keys[KI_LCONTROL] = down; + } else if (be._button == KeyboardButton::lshift()) { + _keys[KI_LSHIFT] = down; + } else if (be._button == KeyboardButton::meta()) { + // Not sure which of these is correct... + //_keys[KI_LWIN] = down; + _keys[KI_LMETA] = down; + } else if (be._button == KeyboardButton::num_lock()) { + _keys[KI_NUMLOCK] = down; + } else if (be._button == KeyboardButton::page_down()) { + _keys[KI_NEXT] = down; + } else if (be._button == KeyboardButton::page_up()) { + _keys[KI_PRIOR] = down; + } else if (be._button == KeyboardButton::pause()) { + _keys[KI_PAUSE] = down; + } else if (be._button == KeyboardButton::print_screen()) { + _keys[KI_SNAPSHOT] = down; + } else if (be._button == KeyboardButton::ralt()) { + _keys[KI_RMENU] = down; + } else if (be._button == KeyboardButton::rcontrol()) { + _keys[KI_RCONTROL] = down; + } else if (be._button == KeyboardButton::rshift()) { + _keys[KI_RSHIFT] = down; + } else if (be._button == KeyboardButton::scroll_lock()) { + _keys[KI_SCROLL] = down; + /* What is shift_lock? It's not caps_lock apparently... + } else if (be._button == KeyboardButton::shift_lock()) { + _keys[KI_SHIFT_LOCK] = down; + */ + } else { + // libRocket accepts/expects keypress events + // as well as text input + char asciiChar = be._button.get_ascii_equivalent(); + if ('0' <= asciiChar && asciiChar <= '9') { + _keys[asciiChar - '0' + KI_0] = down; + } else if ('a' <= asciiChar && asciiChar <= 'z') { + _keys[asciiChar - 'a' + KI_A] = down; + } } } } @@ -204,9 +298,9 @@ ButtonActivityMap::const_iterator it; for (it = _mouse_buttons.begin(); it != _mouse_buttons.end(); ++it) { if (it->second) { - context->ProcessMouseButtonDown(it->first, _modifiers); + context->ProcessMouseButtonDown(it->first - 1, _modifiers); } else { - context->ProcessMouseButtonUp(it->first, _modifiers); + context->ProcessMouseButtonUp(it->first - 1, _modifiers); } } _mouse_buttons.clear(); @@ -226,7 +320,17 @@ context->ProcessKeyUp((KeyIdentifier) it->first, _modifiers); } } - _mouse_buttons.clear(); + _keys.clear(); + } + + if (_repeated_keys.size() > 0) { + ButtonActivityMap::const_iterator it; + + for (it = _repeated_keys.begin(); it != _repeated_keys.end(); ++it) { + context->ProcessKeyUp((KeyIdentifier) it->first, _modifiers); + context->ProcessKeyDown((KeyIdentifier) it->first, _modifiers); + } + _repeated_keys.clear(); } if (_text_input.size() > 0) { Index: panda/src/rocket/rocketInputHandler.h =================================================================== RCS file: /cvsroot/panda3d/panda/src/rocket/rocketInputHandler.h,v retrieving revision 1.1 diff -u -r1.1 rocketInputHandler.h --- panda/src/rocket/rocketInputHandler.h 7 Jan 2012 19:02:41 -0000 1.1 +++ panda/src/rocket/rocketInputHandler.h 25 Jan 2012 16:51:25 -0000 @@ -57,6 +57,7 @@ typedef pmap<int, bool> ButtonActivityMap; ButtonActivityMap _mouse_buttons; ButtonActivityMap _keys; + ButtonActivityMap _repeated_keys; pvector<short> _text_input; public:
(Is there a better way to submit patches? I suspect this won't be the last one I submit...)
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by Burstaholic » Thu Jan 26, 2012 7:57 pm
Edit: Backtrace - http://pastebin.com/HdNtrwDr
Full Backtrace: http://pastebin.com/xDLR8nwB
Latest debug output from libRocket:
- Code: Select all
Starting program: /usr/bin/python test.py [Thread debugging using libthread_db enabled] Known pipe types: glxGraphicsPipe (all display modules loaded.) :audio(error): load_dso(libp3openal_audio.so) failed, will use NullAudioManager :audio(error): No error. rocket 0x2682828
Program received signal SIGSEGV, Segmentation fault. 0x00007fffea02ef27 in Rocket::Core::Context::GetElementAtPoint(Rocket::Core::Vector2<float> const&, Rocket::Core::Element const*, Rocket::Core::Element*) () from /usr/local/lib/libRocketCore.so.1
-

Burstaholic
-
- Posts: 5
- Joined: Fri Jan 20, 2012 10:51 am
by rdb » Sat Jan 28, 2012 7:00 am
OK, I just made a big commit. Burstaholic's crash should be fixed now, it was happening because his Python context object was getting destroyed before his C++ context was, and because it used a borrowed reference, this led to the C++ context being destroyed prematurely.
I've included morgul's changes (thanks!), I've adapted them a little bit because I switched to using a lookup table for key translations, for better performance.
Everything seems to be working in the Invaders sample for me, except that I'm still working on a font issue:
http://rdb.name/librocket_font_problem.png
-
rdb
-
- Posts: 8543
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by rdb » Sat Jan 28, 2012 7:20 am
Ah, never mind, I've got fonts working now:

-
rdb
-
- Posts: 8543
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by morgul » Sat Jan 28, 2012 1:13 pm
Looks good! (I haven't had a chance to try it, I will later tonight.)
Out of curiosity, rdb, did you have to do anything special to get librocket building on OSX? I'm running Lion on one of my machines, and the python bindings won't compile. (Searching around, it looks like it's a problem with boost python, and include order, but I haven't had much time to mess with that.)
-

morgul
-
- Posts: 38
- Joined: Sun Dec 28, 2008 1:49 pm
- Location: Lubbock, TX
-
by rdb » Sat Jan 28, 2012 5:40 pm
I had no issues on Snow Leopard. Tomorrow I'll make sure the OSX buildbot contains libRocket support.
Make sure that you compile it for i386 arch with Python 2.5 if you use the default SDK.
-
rdb
-
- Posts: 8543
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
Return to Panda Features in Development
Who is online
Users browsing this forum: No registered users and 0 guests
| | |