Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am using OpenGL ES 2.0 to create a 2D game for Android 2.2 and was planning on using LibRocket for the GUI. Does anyone have any links or knowledge they would share on how to integrate LibRocket with the android platform? I know that it is a c++ library that would need to go through the NDK, however I rather not change my OpenGL rendering code to the NDK unless I have to.

share|improve this question

1 Answer 1

This might be tough and I'm not convinced that you will have acceptable performance on android devices at the end, but it seems that at least one game has been released on android using LibRocket.

You can write a few wrapper classes in c++ that allow LibRocket to use your own rendering functions. These classes can call back the proper java functions of your engine. You will also need, on the other hand, to forward input from java back to LibRocket using the provided method.

Here is a more straightforward description of the steps:

  • Build LibRocket for Android platform using the NDK (this already might be difficult, but LibRocket shouldn't have much external dependency. Iirc, it only requires the STL).
  • Write your interface between java and LibRocket as a second C++ lib. You must write three classes that inherit from Rocket::Core::RenderInterface, Rocket::Core::SystemInterface, and Rocket::Core::FileInterface. Each method of these classes should forward calls to an equivalent java method that can do the proper things in your engine. Here you can find some good help to do that.
  • Write some static functions that will be called by java (check any sample from the NDK to see how to call c++ from java) to forward inputs. Check Injecting Input from the official LibRocket doc to see what you'll need.

Then simply write an initializer in c++ that will instantiate each of the three interface and bind them to LibRocket. Call it from Java at the beginning:

Rocket::Core::SetRenderInterface(new MyRenderInterface(Width, Height));
Rocket::Core::SetSystemInterface(new MySystemInterface());
Rocket::Core::SetFileInterface(new MyFileInterface());

Hope this will help.

share|improve this answer
1  
I have implemented and actually use libRocket in my cross-platform engine, which means it runs well on Android, but everything is done from C++.. I don't think my use case applies well here but if you need something ask. –  Grimshaw Jun 10 '12 at 0:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.