GLFW / glm / AngelScript integration

Help with integrating libRocket into your engine and game

GLFW / glm / AngelScript integration

Postby noizex on Sat May 05, 2012 8:05 pm

Hello,

I'm looking for a good UI library for my project and after having problems with Awesomium and not liking it being closed source I found librocket that also uses well established markup language + CSS.

I have few questions regarding integration with my engine - I use modern openGL with glm as my math lib, GLFW as window / contex creation lib and AngelScript as scripting language. Questions are:

Question 1
I saw librocket has headers like Math.h, Input.h - does it mean I comes with everything and I will have to use its own vector classes instead of glm etc? I dislike libs that are too big and do too many things, especially that in most engines there will be different libs coming into play and I don't want them to clash. So, am I forced by design to use librocket's math classes, or can I pass primitive values (like float x,y,z) or even better, define a wrapper that will take my own vector class (in this case glm::vec3) and make it possible to use it with librocket's classes?

Question 2
Is it possible to bind with any scripting language? I saw in FAQ that there are several bindings but none for AngelScript which I use, I'd be interested in making my own bindings if possible so I can use UI functionality from inside my scripts.

Thanks for anwering, it will really help me deciding which UI library to pick.

n.
noizex
 
Posts: 9
Joined: Sat May 05, 2012 7:54 pm

Re: GLFW / glm / AngelScript integration

Postby Gambini on Wed May 16, 2012 9:06 pm

To answer question 1:
You can use whatever math library and input library you want. If you notice the math library is in the Rocket::Core::Math namespace, so there should not be any name clashes as long as you don't put
Code: Select all
using namespace Rocket::Core::Math;
at the top of your file, and the other math library exists in the global namespace. So, you can use xnamath or glm along with Rocket no problem.

The input is actually a problem that needs to be solved, though it is solved easily. All you have to do is convert the key code (the integer representation of the key) that you get from your own input library to match the Input::KeyIdentifier enum in Input.h before you pass it to Rocket.

To answer question 2: Yes, but you'll have to do some of the legwork for AngelScript since nobody else has.
Gambini
 
Posts: 10
Joined: Sun Mar 25, 2012 4:34 pm

Re: GLFW / glm / AngelScript integration

Postby kezeali on Sun May 20, 2012 3:03 am

I have a shitty angelscript binding at https://github.com/Kezeali/RAS
You'll probably want to do a bit of work to it if you want to use it for anything commercial / serious, since I really put minimum effort into it :P
kezeali
 
Posts: 5
Joined: Sat Sep 18, 2010 12:06 am

Re: GLFW / glm / AngelScript integration

Postby noizex on Tue May 22, 2012 5:25 pm

Thanks, I will look into the code :)

And about Math library, I didn't mean name clashes, more like having to use Rocket::Core::Math when dealing with Rocket routines, and glm when dealing with rest of the code. I mean, passing vector arguments etc. - its all expected to be Rocket::Core::Math right? I can't make it use glm for example..
noizex
 
Posts: 9
Joined: Sat May 05, 2012 7:54 pm

Re: GLFW / glm / AngelScript integration

Postby Gambini on Tue May 22, 2012 11:42 pm

It looks like Math.h is for plain old data types, and doesn't have any vector math. In any of the cases that you would use Math.h, I'm sure that there is at least an equal implementation in the standard template library or glm, so you can pretend that it doesn't exist. The Vector class seems like it has its own math functions, and I'd imagine that it would be smart to use those when possible. Of course, you could always create some conversion function to grab the x and y from Rocket's vector and put it in a glm vector.

What I would suggest is to keep Rocket's types as isolated as they can be. Use glm's vector everywhere you can, except when dealing with GUI things. I may not be remembering correctly, but the only time that my GUI code had to interact with the underlying game logic with its own types was when dealing with mouse input. In those cases, there was enough work being done that it was worth it to make a conversion function. Most of the time though, it was inter-gui communication or button click events. It is just a suggestion, and I can't tell if that is even possible without knowing how you have your project set up.

Another suggestion with more work is to rewrite Rocket's vector code using glm. Vector2i and Vector2f are typedefs, and it might not be as hard as it sounds as long as you keep the same interface as Vector.h. Then all you have to do is find where vector2<int> and vector2<float> are used explicitly and change those to the typedef.

Short answer: Yes, you have to use Rocket's vector types when dealing with Rocket.
Gambini
 
Posts: 10
Joined: Sun Mar 25, 2012 4:34 pm

Re: GLFW / glm / AngelScript integration

Postby raniadoll on Mon Sep 09, 2013 8:50 am

The texture is set to pure white when its allocated (See TextureLayoutTexture.cpp:150). When we copy the font from TrueType its greyscale, we just load that straight into the alpha channel of the font.
rania
raniadoll
 
Posts: 1
Joined: Mon Sep 09, 2013 8:45 am


Return to Engine Integration


cron