Topic: GUI clarification

When will 2D drawing functions be available?
I'm not sure if MGui will be used for games too or not.
In any case I wanted to know if there is an approximate release date for 2D drawing stuff (for e.g. game menus).

Re: GUI clarification < why not just use this for now...GUIDEMO at bottom of screen.

Re: GUI clarification

Of course, I've written myself this: … ng_GUIDemo

Still, all these workarounds are temporary and inefficient ways to do something while waiting for the true thing.

Re: GUI clarification

I started rewriting MGui to be able to use it as dynamic library,
see this post :

but it's still experimental and seems to compile good on osx only (but it uses premake)
I didn't have time to check the linux and win compilation errors yet.

But, except if you need an interface with text editing and a classic GUI, as it's 2d only and doesn't use meshs,
I don't believe MGui is the best for game, it's use it to handle software GUI (like Maratis editor).

I still think that the good step would be to create a set of Behaviors to attach to entities,
a 'Button' behavior, a "Slide" behavior etc. But it sure depend of the final use.

Re: GUI clarification

So what external library do you suggest for doing game menus and debug windows?
Anyone can suggest their preferences.

Re: GUI clarification

If you want, you can try to use the new experimental MGui in c++ in your game plugin,
use the sources directly, the new version is stand-alone.

You will find everything in branches/Experimental/

Here are the headers : … 2FIncludes

You will also need tinyutf8 (one header lib) : … 2Ftinyutf8

To use it, create a MWindow :
- to send input events, use onKeyDown, onKeyUp etc
- use addNewWindow() to create MGuiWindow sub-windows
- call draw() in your custom game class to draw the GUI

To add an editable text with MGuiWindow :

MGuiEditText * text = guiwin->addNewEditText();
text->setPosition(MVector2(100, 100));
text->setText("Hello world !");
text->setTextColor(MVector4(1, 1, 1, 1));

ps : fontRef is a font, you can get it from your current level :
MFontRef * fontRef = level->loadFont("/Library/Fonts/Arial.ttf");

Re: GUI clarification

Thanks I'll try that.

Last edited by 255 (2013-10-01 11:07:23)

Re: GUI clarification

Ok it took a while to compile correctly but now it works.
I see a white square which I enlarged using setScale();
I don't see the text though, even changing the color and setting up the font.
I also tried a button, but no luck, I don't see anything even after doing setText().
So I'm not sure how to actually use this. tongue

Re: GUI clarification

Did you create the MGuiWindow and set the size ?

MWindow * rootWindow = new MWindow();

MGuiWindow * guiwin = rootWindow->addNewWindow();
guiwin->setScale(MVector2(800, 600));
guiwin->setColor(MVector3(0.5f, 0.5f, 0.5f));

be sure also that the path to your font is correct
use a full path with c:/
or make a local path global using :

MEngine * engine = MEngine::getInstance();
MSystemContext * system = engine->getSystemContext();

char globalFilename[256];
getGlobalFilename(globalFilename, system->getWorkingDirectory(), "fonts/myFont.ttf"); // font is in project/fonts directory


Re: GUI clarification

Oh I didn't know it wanted the full path, I used local.
Now it works, thanks.


Re: GUI clarification

But... it's in 3D.
As I move the camera it moves. *scratches his head*
The text I mean. The window is fine.

Images and buttons backgrounds are also fine (still 2d objects), but the text is rendering in 3d with all the perspective in relation to camera view.

Also, I wonder how to load an image, for example to do a cursor.
I tried

MGuiImage* img = guiwin->addNewImage();
MTextureRef* myTexture = MTextureRef::getNew(0,"C:/blahblah/cursor.jpg",false);

Last edited by 255 (2013-10-01 16:26:00)

Re: GUI clarification

To load a texture, use "level->loadTexture" like for level->loadFont.

For the text moving with the camera, is it working if you use the fixed renderer instead of the standard renderer ?
Is yes, I know what it is but I have to modify some code.


Re: GUI clarification

Yes with fixed renderer it works.

Re: GUI clarification

ok, I'm modifying something in the renderer,
you'll just have to recompile maratis editor with the svn sources.


Re: GUI clarification

No problem, had to do it anyway (as in other thread).

Re: GUI clarification

A fix (to be tested) is on svn.


Re: GUI clarification

Woah game now crashes. Maybe because of other things due to modifications in trunk/, because MGui is not even ON at the start of my scene; I could try with a more basic project. I'll let you know.
Other projects (maratis demos) work so the compilation is fine.

Last edited by 255 (2013-10-01 18:39:41)

Re: GUI clarification

you have to recompile the game.dll


Re: GUI clarification

Yes I did "clean solution" and then rebuild from scratch, it's not that.

Last edited by 255 (2013-10-01 19:38:59)


Re: GUI clarification

Looks like if the plugin is compiled with VC 2010 it doesn't work with Maratis build with VC 2008.
Can you confirm that?

Re: GUI clarification

mh, I'm not sure, it's possible.

Did you use the new MCore.lib/dll and MEngine.lib/dll to rebuild the game.dll ?


Re: GUI clarification

anael wrote:

Did you use the new MCore.lib/dll and MEngine.lib/dll to rebuild the game.dll ?


I tried again compiling Maratis with VS2010, finished right now. I tested my game plugin and it works.
I'm puzzled though: shouldn't a user be allowed to write a plugin DLL for Maratis regardless of how it was compiled?
This is what I would expect.

BTW, I confirm that your fix works. Now I see 2D text.
Thank you.


Re: GUI clarification

How does MGuiButton work?
I've created my eventButtonTest() function which does work if called manually.
Then I've done


But clicking on the button does anything.

Re: GUI clarification

You have to feed your MWindow with events,
we have to find a better way, but for now you can do this in your game update :

MSystemContext * system = engine->getSystemContext();
MInputContext * input = engine->getInputContext();

unsigned int width, height;
system->getScreenSize(&width, &height);

// mouse button


// and mouse move
int mx = input->getAxis("MOUSE_X")*width;
int my = input->getAxis("MOUSE_Y")*height;

window->onMouseMove(MVector2(mx, my)); // [EDIT] : sorry for the bad example

I'll start to think of a semi automatic way to send events to MWindow


Re: GUI clarification

Hrm... it still doesn't work.

Debugging in old style (putting while(1) loops around) I've seen that the event actually reaches the button, so it's a problem with the callback. It's like if m_eventCallback is null, despite me having assigned it.
I think this is due to the fact that my class is assigning the callback function to a function outside its class. I'm obliged to do this otherwise the compiler will throw an error though.
Maybe I should change that method to static and create an handle, etc., how the internet suggests regarding this messy topic.


Tried, no luck even with a static method which retrieves the class doing

MEngine * engine = MEngine::getInstance();
MyGame* my_game = (MyGame*)engine->getGame();

Last edited by 255 (2013-10-02 16:52:53)