Using MyGUI in Non OGRE App?

Scorcher24

31-01-2011 01:18:06

Hi Guys.
I have taken a look at your library and I like it so far. But I have issues starting out. I looked through the OGRE wiki but I cannot get it to work in my own app.
Is there any chance for a more detailed Documentation in the future?
Or can you give me more Hints where to start?
I am trying to integrate MyGUI into an existing SDL Game.
But whats needed to initalise MyGUI in Detail?
According to the log, the library does not find core.xml in the folder I pointed it to, but it is there.
Also, I got a crash when deleting the GUI Pointer:


m_myPlatform = new MyGUI::OpenGLPlatform();
m_myPlatform->initialise();

m_myGui = new MyGUI::Gui();
m_myGui->initialise("./MyGUI_Media/core.xml");

// [..]
delete m_myPlatform;
delete m_myGui; // <- Assert here. Message: mInitialise


Any Help would be appreciated.

Altren

31-01-2011 09:40:28

Try to do it next way:
m_myPlatform = new MyGUI::OpenGLPlatform();
m_myPlatform->initialise();

m_myPlatform->getDataManagerPtr()->addResourceLocation("MyGUI_Media", false);

m_myGui = new MyGUI::Gui();
m_myGui->initialise("core.xml");

VeTaL

23-03-2011 22:52:08

Stuck with the same problem


MyGUI::Gui* mGUI;

MyGUI::OpenGLPlatform* mPlatform = new MyGUI::OpenGLPlatform();
mPlatform->initialise(); //(mWindow, mSceneManager); // mWindow is Ogre::RenderWindow*, mSceneManager is Ogre::SceneManager*
mPlatform->getDataManagerPtr()->addResourceLocation("MyGUI_Media", false);

mGUI = new MyGUI::Gui();
mGUI->initialise("MyGUI_Core.xml");

delete mPlatform;
delete mGUI;


Crashes on delete mPlatform;, but log shows that everything is ok *where is spoiler button? :)*
00:49:42 | Platform | Info | * Initialise: RenderManager | .\src\MyGUI_OpenGLRenderManager.cpp | 31
00:49:42 | Platform | Info | RenderManager successfully initialized | .\src\MyGUI_OpenGLRenderManager.cpp | 42
00:49:42 | Platform | Info | * Initialise: DataManager | .\src\MyGUI_OpenGLDataManager.cpp | 24
00:49:42 | Platform | Info | DataManager successfully initialized | .\src\MyGUI_OpenGLDataManager.cpp | 26
00:49:42 | Core | Info | * Initialise: Gui | .\src\MyGUI_Gui.cpp | 75
00:49:42 | Core | Info | * MyGUI version 3.2.0.4245 | .\src\MyGUI_Gui.cpp | 82
00:49:42 | Core | Info | * Initialise: ResourceManager | .\src\MyGUI_ResourceManager.cpp | 48
00:49:42 | Core | Info | ResourceManager successfully initialized | .\src\MyGUI_ResourceManager.cpp | 56
00:49:42 | Core | Info | * Initialise: LayerManager | .\src\MyGUI_LayerManager.cpp | 49
00:49:42 | Core | Info | LayerManager successfully initialized | .\src\MyGUI_LayerManager.cpp | 57
00:49:42 | Core | Info | * Initialise: WidgetManager | .\src\MyGUI_WidgetManager.cpp | 67
00:49:42 | Core | Info | WidgetManager successfully initialized | .\src\MyGUI_WidgetManager.cpp | 98
00:49:42 | Core | Info | * Initialise: InputManager | .\src\MyGUI_InputManager.cpp | 58
00:49:42 | Core | Info | InputManager successfully initialized | .\src\MyGUI_InputManager.cpp | 76
00:49:42 | Core | Info | * Initialise: SubWidgetManager | .\src\MyGUI_SubWidgetManager.cpp | 49
00:49:42 | Core | Info | SubWidgetManager successfully initialized | .\src\MyGUI_SubWidgetManager.cpp | 69
00:49:42 | Core | Info | * Initialise: SkinManager | .\src\MyGUI_SkinManager.cpp | 53
00:49:42 | Core | Info | SkinManager successfully initialized | .\src\MyGUI_SkinManager.cpp | 61
00:49:42 | Core | Info | * Initialise: FontManager | .\src\MyGUI_FontManager.cpp | 48
00:49:42 | Core | Info | FontManager successfully initialized | .\src\MyGUI_FontManager.cpp | 57
00:49:42 | Core | Info | * Initialise: ControllerManager | .\src\MyGUI_ControllerManager.cpp | 46
00:49:42 | Core | Info | ControllerManager successfully initialized | .\src\MyGUI_ControllerManager.cpp | 56
00:49:42 | Core | Info | * Initialise: PointerManager | .\src\MyGUI_PointerManager.cpp | 60
00:49:42 | Core | Info | PointerManager successfully initialized | .\src\MyGUI_PointerManager.cpp | 78
00:49:42 | Core | Info | * Initialise: ClipboardManager | .\src\MyGUI_ClipboardManager.cpp | 87
00:49:42 | Core | Info | ClipboardManager successfully initialized | .\src\MyGUI_ClipboardManager.cpp | 101
00:49:42 | Core | Info | * Initialise: LayoutManager | .\src\MyGUI_LayoutManager.cpp | 45
00:49:42 | Core | Info | LayoutManager successfully initialized | .\src\MyGUI_LayoutManager.cpp | 50
00:49:42 | Core | Info | * Initialise: DynLibManager | .\src\MyGUI_DynLibManager.cpp | 41
00:49:42 | Core | Info | DynLibManager successfully initialized | .\src\MyGUI_DynLibManager.cpp | 45
00:49:42 | Core | Info | * Initialise: PluginManager | .\src\MyGUI_PluginManager.cpp | 45
00:49:42 | Core | Info | PluginManager successfully initialized | .\src\MyGUI_PluginManager.cpp | 49
00:49:42 | Core | Info | * Initialise: LanguageManager | .\src\MyGUI_LanguageManager.cpp | 45
00:49:42 | Core | Info | LanguageManager successfully initialized | .\src\MyGUI_LanguageManager.cpp | 49
00:49:42 | Core | Info | * Initialise: FactoryManager | .\src\MyGUI_FactoryManager.cpp | 40
00:49:42 | Core | Info | FactoryManager successfully initialized | .\src\MyGUI_FactoryManager.cpp | 42
00:49:42 | Core | Info | * Initialise: ToolTipManager | .\src\MyGUI_ToolTipManager.cpp | 48
00:49:42 | Core | Info | ToolTipManager successfully initialized | .\src\MyGUI_ToolTipManager.cpp | 60
00:49:42 | Core | Info | Load ini file 'MyGUI_Fonts.xml' | .\src\MyGUI_ResourceManager.cpp | 130
00:49:42 | Core | Info | ResourceTrueTypeFont 'DejaVuSansFont.17' using texture size 512 x 256 | .\src\MyGUI_ResourceTrueTypeFont.cpp | 209
00:49:42 | Core | Info | ResourceTrueTypeFont 'DejaVuSansFont.17' using real height 17 pixels | .\src\MyGUI_ResourceTrueTypeFont.cpp | 210
00:49:42 | Core | Info | Load ini file 'MyGUI_Images.xml' | .\src\MyGUI_ResourceManager.cpp | 130
00:49:42 | Core | Info | Load ini file 'MyGUI_CommonSkins.xml' | .\src\MyGUI_ResourceManager.cpp | 130
00:49:42 | Core | Info | Register value : 'HCenter' = 0 | z:\mygui\myguiengine\include\MyGUI_Align.h | 238
00:49:42 | Core | Info | Register value : 'VCenter' = 0 | z:\mygui\myguiengine\include\MyGUI_Align.h | 239
00:49:42 | Core | Info | Register value : 'Center' = 0 | z:\mygui\myguiengine\include\MyGUI_Align.h | 240
00:49:42 | Core | Info | Register value : 'Left' = 2 | z:\mygui\myguiengine\include\MyGUI_Align.h | 241
00:49:42 | Core | Info | Register value : 'Right' = 4 | z:\mygui\myguiengine\include\MyGUI_Align.h | 242
00:49:42 | Core | Info | Register value : 'HStretch' = 6 | z:\mygui\myguiengine\include\MyGUI_Align.h | 243
00:49:42 | Core | Info | Register value : 'Top' = 8 | z:\mygui\myguiengine\include\MyGUI_Align.h | 244
00:49:42 | Core | Info | Register value : 'Bottom' = 16 | z:\mygui\myguiengine\include\MyGUI_Align.h | 245
00:49:42 | Core | Info | Register value : 'VStretch' = 24 | z:\mygui\myguiengine\include\MyGUI_Align.h | 246
00:49:42 | Core | Info | Register value : 'Stretch' = 30 | z:\mygui\myguiengine\include\MyGUI_Align.h | 247
00:49:42 | Core | Info | Register value : 'Default' = 10 | z:\mygui\myguiengine\include\MyGUI_Align.h | 248
00:49:42 | Core | Info | Load ini file 'MyGUI_BlueWhiteTheme.xml' | .\src\MyGUI_ResourceManager.cpp | 130
00:49:42 | Core | Info | Load ini file 'MyGUI_BlueWhiteImages.xml' | .\src\MyGUI_ResourceManager.cpp | 130
00:49:42 | Core | Info | Load ini file 'MyGUI_BlueWhiteSkins.xml' | .\src\MyGUI_ResourceManager.cpp | 130
00:49:43 | Core | Info | Load ini file 'MyGUI_BlueWhiteTemplates.xml' | .\src\MyGUI_ResourceManager.cpp | 130
00:49:43 | Core | Info | Load ini file 'MyGUI_Pointers.xml' | .\src\MyGUI_ResourceManager.cpp | 130
00:49:43 | Core | Info | Load ini file 'MyGUI_Layers.xml' | .\src\MyGUI_ResourceManager.cpp | 130
00:49:43 | Core | Info | Load ini file 'MyGUI_Settings.xml' | .\src\MyGUI_ResourceManager.cpp | 130
00:49:43 | Core | Info | Gui successfully initialized | .\src\MyGUI_Gui.cpp | 133

VeTaL

23-03-2011 23:00:58

Moreover, i hope that i would see some results on the screen? Its empty now.

PS: i really dislike string
mPlatform->initialise();
have an idea that i must throw there pointer to render window, or something like that.

Also, what about OIS? I initialized it separately, how can i now "connect" it with MyGUI?

Altren

23-03-2011 23:39:50

You always can look into Demos: BaseManager::createGui() in 'Common' project.
initialise require pointer to class that implements MyGUI::OpenGLImageLoader interface.

I wonder why developer of OpenGL platform made it optional. I fixed that, now you can't call initialise without parameters.

VeTaL

24-03-2011 09:40:19

You always can look into Demos: BaseManager::createGui() in 'Common' project.

Thanks, thats looking interesting. Just wonder, why Common is compiled like a .lib, not .exe.

Edited:
2 Scorcher24: you need to use another destruction, look at http://www.ogre3d.org/tikiwiki/MyGUI+quickstart

mGUI->shutdown();
delete mGUI;
mGUI = 0;
mPlatform->shutdown();
delete mPlatform;
mPlatform = 0;


This one works fine for me.

Altren

24-03-2011 10:32:07

Common contain code that used in all demos/tools/tests, it contain window creation/input/etc. It is not included to every to demo to speed up compilation process whenever you compile more than one exe for MyGUI solution.

VeTaL

24-03-2011 14:11:54

Common contain code that used in all demos/tools/tests, it contain window creation/input/etc. I

Ok, i see.

VeTaL

19-04-2011 14:17:04

Here i am again :)

Have 2 questions:
1) when i'm trying to render something (single button or simple example), i got this:

Is it familiar to you? What can be the reason?

2) i catch exception when shuting down MyGui.
Call stack:
> Test_d.exe!MyGUI::OpenGLVertexBuffer::create() Line 100 + 0x12d bytes C++
Test_d.exe!MyGUI::OpenGLVertexBuffer::setVertexCount(unsigned int _count=384) Line 40 C++
MyGUIEngine_d.dll!MyGUI::RenderItem::removeDrawItem(MyGUI::ISubWidget * _item=0x08bcd5b0) Line 123 + 0x1c bytes C++
MyGUIEngine_d.dll!MyGUI::EditText::destroyDrawItem() Line 386 C++
MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayerItemNode(bool _deep=true) Line 203 + 0x25 bytes C++
MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayerItemNode(bool _deep=true) Line 180 + 0x14 bytes C++
MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayerItemNode(bool _deep=true) Line 180 + 0x14 bytes C++
MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayer() Line 138 C++
MyGUIEngine_d.dll!MyGUI::LayerManager::detachFromLayer(MyGUI::Widget * _item=0x08bc9b38) Line 161 + 0x19 bytes C++
MyGUIEngine_d.dll!MyGUI::LayerManager::_unlinkWidget(MyGUI::Widget * _widget=0x08bc9b38) Line 132 C++
MyGUIEngine_d.dll!MyGUI::WidgetManager::unlinkFromUnlinkers(MyGUI::Widget * _widget=0x08bc9b38) Line 170 + 0x20 bytes C++
MyGUIEngine_d.dll!MyGUI::Gui::_destroyAllChildWidget() Line 258 C++
MyGUIEngine_d.dll!MyGUI::Gui::shutdown() Line 154 C++
Test_d.exe!MyGuiManager::~MyGuiManager() Line 61 + 0xe bytes C++
Test_d.exe!`Singleton<MyGuiManager>::getInstance'::`2'::`dynamic atexit destructor for '_instance''() + 0x28 bytes C++
msvcr90d.dll!doexit(int code=0, int quick=0, int retcaller=0) Line 591 C
msvcr90d.dll!exit(int code=0) Line 412 + 0xd bytes C
Test_d.exe!__tmainCRTStartup() Line 599 C
Test_d.exe!mainCRTStartup() Line 403 C
kernel32.dll!756bf4e8()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!7729af77()
ntdll.dll!7729af4a()

Altren

19-04-2011 15:48:29

1) Never seen this. Try to explain better what you do and what you got: "trying to render something (single button or simple example)" - create some MyGUI elements or what you "trying to render"? Also what's wrong in your picture and what should be there?

2) Your application crash with this exception and message in log "Data size is mismatch with input array". Next time post exception text please.
I guess glGetBufferParameterivARB returned something wrong, because you are trying to shut down MyGUI after render or in the middle of render process.

VeTaL

19-04-2011 15:58:45

1) i got something like that on my laptop even when i was trying to launch your examples. When i tried them on computer, examples works fine, but when i tried to launch mygui in my engine, this happens again.

Constructor is:
MyGuiManager::MyGuiManager(void)
{
Gdiplus::GdiplusStartupInput m_gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_pGdiToken, &m_gdiplusStartupInput, NULL);

mPlatform = new MyGUI::OpenGLPlatform();
mPlatform->initialise(this);
mPlatform->getDataManagerPtr()->addResourceLocation("..//Assets//MyGUI_Media", false);

mGUI = new MyGUI::Gui();
mGUI->initialise("MyGUI_Core.xml");

mInfo = new diagnostic::StatisticInfo();
mFocusInfo = new diagnostic::InputFocusInfo();


MyGUI::ButtonPtr button = mGUI->createWidget<MyGUI::Button>(
"Button", 10, 10, 300, 26, MyGUI::Align::Center, "Main");
button->setCaption("exit");
button->setVisible(true);

So i hope to see a simple button, not a halfly-blurred screen.

2)
Text of exception:
Test_d.exe has triggered a breakpoint

It happens here:
if (mSizeInBytes != (size_t)bufferSize)
{
destroy();
MYGUI_PLATFORM_EXCEPT("Data size is mismatch with input array");
}

MyGUI::OpenGLVertexBuffer::create()
Line 100
MyGUI_OpenGLVertexBuffer.cpp

//because you are trying to shut down MyGUI after render or in the middle of render process.
Quite strange.
the main structure is like this:

while(!AppTerminate() && !_isQuit)
{
TimeManager.Update();
InputManager.Update();
***
MyGUImanager.Render();
}

So it shouldn't want to destruct while rendering.

Destructor is:
MyGuiManager::~MyGuiManager(void)
{
mGUI->shutdown();
delete mGUI;
mGUI = 0;

mPlatform->shutdown();
delete mPlatform;
mPlatform = 0;

Gdiplus::GdiplusShutdown(m_pGdiToken);
}


Update function is:
void MyGuiManager::Render()
{
if (mPlatform)
mPlatform->getRenderManagerPtr()->drawOneFrame();
}

VeTaL

22-04-2011 00:23:15

Btw, this

const MyGUI::IntSize& siz = mPlatform->getRenderManagerPtr()->getViewSize();

returns 0,0 to me, is it okay?

VeTaL

22-04-2011 13:28:02

mPlatform->getRenderManagerPtr()->setViewSize(1024,768);
This solved previous problem, but i dont think that i need to set this manually as i didn find it in your example.

Now i'm trying devIL library ( http://www.ogre3d.org/tikiwiki/tiki-pri ... %20Library ), but still no result

Altren

22-04-2011 14:54:09

Hm, yes, looks like developer of OpenGL platform forgot to call setViewSize in initialise.

cuatro

01-12-2011 17:26:09

Here i am again :)
2) i catch exception when shuting down MyGui.
Call stack:
> Test_d.exe!MyGUI::OpenGLVertexBuffer::create() Line 100 + 0x12d bytes C++
Test_d.exe!MyGUI::OpenGLVertexBuffer::setVertexCount(unsigned int _count=384) Line 40 C++
MyGUIEngine_d.dll!MyGUI::RenderItem::removeDrawItem(MyGUI::ISubWidget * _item=0x08bcd5b0) Line 123 + 0x1c bytes C++
MyGUIEngine_d.dll!MyGUI::EditText::destroyDrawItem() Line 386 C++
MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayerItemNode(bool _deep=true) Line 203 + 0x25 bytes C++
MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayerItemNode(bool _deep=true) Line 180 + 0x14 bytes C++
MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayerItemNode(bool _deep=true) Line 180 + 0x14 bytes C++
MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayer() Line 138 C++
MyGUIEngine_d.dll!MyGUI::LayerManager::detachFromLayer(MyGUI::Widget * _item=0x08bc9b38) Line 161 + 0x19 bytes C++
MyGUIEngine_d.dll!MyGUI::LayerManager::_unlinkWidget(MyGUI::Widget * _widget=0x08bc9b38) Line 132 C++
MyGUIEngine_d.dll!MyGUI::WidgetManager::unlinkFromUnlinkers(MyGUI::Widget * _widget=0x08bc9b38) Line 170 + 0x20 bytes C++
MyGUIEngine_d.dll!MyGUI::Gui::_destroyAllChildWidget() Line 258 C++
MyGUIEngine_d.dll!MyGUI::Gui::shutdown() Line 154 C++
Test_d.exe!MyGuiManager::~MyGuiManager() Line 61 + 0xe bytes C++
Test_d.exe!`Singleton<MyGuiManager>::getInstance'::`2'::`dynamic atexit destructor for '_instance''() + 0x28 bytes C++
msvcr90d.dll!doexit(int code=0, int quick=0, int retcaller=0) Line 591 C
msvcr90d.dll!exit(int code=0) Line 412 + 0xd bytes C
Test_d.exe!__tmainCRTStartup() Line 599 C
Test_d.exe!mainCRTStartup() Line 403 C
kernel32.dll!756bf4e8()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!7729af77()
ntdll.dll!7729af4a()


A little late, but I ran into this issue when using GLFW and figured out the problem.

Basically you will get this exception "Data size is mismatch with input array" in OpenGLVertexBuffer::create() if the context/DC/window is destroyed before MyGUI->shutdown() is called because any OpenGL call will fail.

In GLFW world if you have a glfwSetWindowCloseCallback() callback set and in this callback return true, then the GLFW code will destroy the context, DC and window.

If you return false in the callback it will not destroy the window allowing you to exit your game loop, call MyGUI->shutdown(), delete MyGUI and then call glfwTerminate() which will then properly dispose of the window.