Creating contexts from Python

Discussion about using Python with libRocket.

Creating contexts from Python

Postby rcdailey on Thu May 29, 2008 7:37 pm

Hi,

I want to allow people scripting libRocket through Python to be able to create contexts from Python. However, I find if I do this I cannot start the libRocket debugger component or setup the input system for libRocket. It seems like right now the best thing to do is create a python binding named GetGUIContext() that is simply the equivalent of "rocket.contexts["MyContextName"]" in python.

What do you think? Should I even give control over context creation through Python? I see no reason to have more than one context.
rcdailey
 
Posts: 113
Joined: Mon Feb 04, 2008 8:04 pm

Re: Creating contexts from Python

Postby lloydw on Thu May 29, 2008 9:49 pm

You could create the context in python then expose a function in your game engine called SetRocketGameContext or similar that bound the debugger and input handlers to the named context.

If you have no reason to have more than one context, why go to the effort of allowing Python programmers to create them?
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: Creating contexts from Python

Postby rcdailey on Thu May 29, 2008 10:59 pm

lloydw wrote:You could create the context in python then expose a function in your game engine called SetRocketGameContext or similar that bound the debugger and input handlers to the named context.

If you have no reason to have more than one context, why go to the effort of allowing Python programmers to create them?


We don't need more than one context as of right now, I was more or less just wondering what you guys recommended. Thanks for the input. I think I'll just implement a python function that they can call to obtain the libRocket context, something like GetGameGUIContext().
rcdailey
 
Posts: 113
Joined: Mon Feb 04, 2008 8:04 pm

Re: Creating contexts from Python

Postby rcdailey on Tue Aug 19, 2008 5:29 pm

Bringing this topic up once more since I'm still a bit confused. Why do you allow contexts to be created from Python in the first place? It doesn't seem like something useful. What did you have in mind when you exposed context creation to python? Right now (Contrary to what I was originally planning), I do *not* want to allow users to create contexts from python. There's no reason for it. Contexts are very implementation specific in our case (Later on we'll want to apply a different RenderInterface to each context, when the ability to do so has been implemented in libRocket). The user can create a context but it really doesn't give them much. It's not giving them anything that a regular document couldn't, as far as I can tell.

Basically if you could just explain what is so important about creating contexts from python, I'd appreciate it. Thanks!
rcdailey
 
Posts: 113
Joined: Mon Feb 04, 2008 8:04 pm

Re: Creating contexts from Python

Postby lloydw on Wed Aug 20, 2008 1:12 am

Creating contexts from python allows you to control libRocket completely from python, which would allow you to create a game completely in python. For example you could take libRocket, grab a basic renderer and then never have to touch C++ again.

Its more about exposing as much of libRocket to python as possible, not limiting some parts to just C++.
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: Creating contexts from Python

Postby SpOOky on Fri Dec 10, 2010 8:05 pm

Hi,

I'm new to libRocket. From what i've seen now you can create contexts from python. (?)

Does that mean that a game can be made purely in python without c++? (With the aid of a pyglet renderer maybe?)

Thanks
SpOOky
 
Posts: 3
Joined: Fri Dec 10, 2010 5:58 pm

Re: Creating contexts from Python

Postby lloydw on Fri Dec 10, 2010 8:14 pm

Yes you can create contexts from python and manipulate the entire DOM from python, all functionality of libRocket is exposed to python except for the setting up of the render and system interfaces.
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: Creating contexts from Python

Postby SpOOky on Fri Dec 10, 2010 8:27 pm

Awesome. Is there a basic tutorial on how can I use libRocket with opengl in python?
SpOOky
 
Posts: 3
Joined: Fri Dec 10, 2010 5:58 pm

Re: Creating contexts from Python

Postby lloydw on Fri Dec 10, 2010 8:44 pm

Unfortunately there is no example for using libRocket this way.

You could take the pyinvaders sample and simply remove all the invaders related code, so the app just sets up libRocket and calls autoexec.py. This will mean your window has been created and gl initialised and libRocket is running, however this probably won't play nicely with pyglet.

If you have some C++ experience, the correct way to do it most likely would be to make a new python module called libRocketGL or something like that, that simply created the default GL renderer and initialises libRocket. This way you could use the normal pyglet initialisation code and once you have a GL context running in pyglet, invoke libRocketGL.
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: Creating contexts from Python

Postby SpOOky on Fri Dec 10, 2010 9:19 pm

Are there plans in the future to make the python development completely independent?
(Having both the render and system setup included)
SpOOky
 
Posts: 3
Joined: Fri Dec 10, 2010 5:58 pm

Next

Return to libRocket and Python


cron