librocket GUI support

I too would like librocket support - DirectGUI isn’t powerful enough for my purposes.

I contacted Gogg through the forums private messaging feature a few weeks ago, no response yet, I was hoping to be able to get hands on his current code for it, and then develop it further.

It seems like there could be a possibility that he is gone, or otherwise taking a break from hanging around here.

I would like to see anyone who knows C++ impliment a panda renderer for Rocket, I however, have no where near enough talent yet to do that.

I think someone needs to make a new public effort towards this project, and this could probably be one of the largest benefits IMO for panda

Hope this helps,
~powerpup118

Librocket popped in IRC discussion again, could someone (rdb,drwr) move it to 1.8 branch from p2?

Some people are interested in helping with python wrappers (DangerOnTheRangr and myself, and probably some others too).

It’s not in there either. I tried e-mailing Gogg, but no reply. Someone will probably have to make it from scratch.

Morgul and I started playing with a basic wrapper in Cython earlier today, and between some code from librocket’s pyinvaders sample, a bit of code from GrizzLyCRO’s p3d_rocket project, and Morgul’s pure Python CEGUI bindings (see the Snippets forum) we managed to get this far in one day:

The display works with the full animated panda scene in the background, and it stays correctly sized when resizing the window.

Our code can be found at: bitbucket.org/skewedaspect/pyrokit

Right now, librocket seems to have some issues loading the fonts, but other than that the display is mostly functional. However, there is no keyboard or mouse input yet - that will most likely be coming in the next few days, along with a lot of code cleanup.

I already made a native implementation a while ago, in C++. I’m polishing off the code and resolving any final issues before I check it in.

Great! Is there a chance you could point us at some code so we can test/lend a hand? We started writing this because we planned to start working with librocket in our panda app shortly… we don’t mind dealing with anything bleeding-edge, or broken, since we planned to put the time in already. It’d be really appreciated.

I’ll put more focus on it then. I’ll be checking it in within the next couple of days.

Wonderful, thanks a lot!

Will this be in 1.8 CVS?

It’ll be, when I check it in, yeah.

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:

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.

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:

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

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:

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:

[morgul] ~/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

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.

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:

#!/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:

# 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) 

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.

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.

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.

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.

Just build libRocket with Python wrappers, and install it onto your system, and makepanda should be able to find it.