MyGUI starter question

Nihon

04-04-2013 10:47:42

Hi, I am trying to use MyGui in my Ogre Project, I am using Ogre 1.8.2 and MyGUI 3.2.0, so far I wanted to create a test project just to play around with MyGui before doing the major implementation in my project, I used the LowLevelOgre example available in the frameworks package created in this post::

http://www.ogre3d.org/forums/viewtopic.php?t=69274

I followed the instructions in the MyGUI wiki page::

http://www.ogre3d.org/tikiwiki/MyGUI+quickstart

So far my code is pretty much the same as the framework but I am getting an error in the ::
mPlatform->initialise(mWindow, mSceneMgr); // mWindow is Ogre::RenderWindow*, mSceneManager is Ogre::SceneManager*

/*
-----------------------------------------------------------------------------
Filename: LowLevelOgre.cpp
-----------------------------------------------------------------------------

This source file is part of the
___ __ __ _ _ _
/___\__ _ _ __ ___ / / /\ \ (_) | _(_)
// // _` | '__/ _ \ \ \/ \/ / | |/ / |
/ \_// (_| | | | __/ \ /\ /| | <| |
\___/ \__, |_| \___| \/ \/ |_|_|\_\_|
|___/
Tutorial Framework
http://www.ogre3d.org/tikiwiki/
-----------------------------------------------------------------------------
*/
#include "LowLevelOgre.h"

#include <OgreLogManager.h>
#include <OgreViewport.h>
#include <OgreEntity.h>
#include <OgreWindowEventUtilities.h>
#include <OgrePlugin.h>
#include "MyGUI.h"
#include "MyGUI_OgrePlatform.h"


//-------------------------------------------------------------------------------------
LowLevelOgre::LowLevelOgre(void)
: mRoot(0),
mCamera(0),
mSceneMgr(0),
mWindow(0)
{
}
//-------------------------------------------------------------------------------------
LowLevelOgre::~LowLevelOgre(void)
{
delete mRoot;
}

bool LowLevelOgre::go(void)
{
// construct Ogre::Root : no plugins filename, no config filename, using a custom log filename
mRoot = new Ogre::Root("", "", "LowLevelOgre.log");

// A list of required plugins
Ogre::StringVector required_plugins;
#if OGRE_VERSION > ((1 << 16) | (8 << 8) | 1)
required_plugins.push_back("Octree Scene Manager");
#else
required_plugins.push_back("Octree & Terrain Scene Manager");
#endif

// List of plugins to load
Ogre::StringVector plugins_toLoad;
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
plugins_toLoad.push_back("RenderSystem_Direct3D9");
plugins_toLoad.push_back("RenderSystem_Direct3D11");
#endif
plugins_toLoad.push_back("RenderSystem_GL");
plugins_toLoad.push_back("RenderSystem_GL3Plus");
plugins_toLoad.push_back("Plugin_OctreeSceneManager");

// List of usable renderer
Ogre::StringVector renderer_toUse;
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
renderer_toUse.push_back("Direct3D9 Rendering Subsystem");
renderer_toUse.push_back("Direct3D11 Rendering Subsystem");
#endif
renderer_toUse.push_back("OpenGL Rendering Subsystem");
renderer_toUse.push_back("OpenGL 3+ Rendering Subsystem");

// Load the OpenGL RenderSystem and the Octree SceneManager plugins
for (Ogre::StringVector::iterator j = plugins_toLoad.begin(); j != plugins_toLoad.end(); j++)
{
try
{
#ifdef _DEBUG
mRoot->loadPlugin(*j + Ogre::String("_d"));
#else
mRoot->loadPlugin(*j);
#endif;
}
catch(Ogre::Exception& e)
{
Ogre::LogManager::getSingletonPtr()->logMessage("Plugin " + *j + " not found!");
}
}

// Check if the required plugins are installed and ready for use
// If not: exit the application
Ogre::Root::PluginInstanceList ip = mRoot->getInstalledPlugins();
for (Ogre::StringVector::iterator j = required_plugins.begin(); j != required_plugins.end(); j++)
{
bool found = false;
// try to find the required plugin in the current installed plugins
for (Ogre::Root::PluginInstanceList::iterator k = ip.begin(); k != ip.end(); k++)
{
if ((*k)->getName() == *j)
{
found = true;
break;
}
}
if (!found) // return false because a required plugin is not available
{
return false;
}
}

//-------------------------------------------------------------------------------------
// setup resources
// Only add the minimally required resource locations to load up the Ogre head mesh
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../../media/materials/programs", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../../media/materials/scripts", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../../media/materials/textures", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../../media/models", "FileSystem", "General");

//-------------------------------------------------------------------------------------
// configure
// Grab a RenderSystem, or exit
Ogre::RenderSystem* rs = NULL;
for (Ogre::StringVector::iterator j = renderer_toUse.begin(); j != renderer_toUse.end(); j++)
{
rs = mRoot->getRenderSystemByName(*j);
if(rs != NULL) break;
}
if(rs == NULL)
{
return false; //No RenderSystem found
}
// configure our RenderSystem
rs->setConfigOption("Full Screen", "No");
rs->setConfigOption("VSync", "No");
//rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit");

mRoot->setRenderSystem(rs);

mWindow = mRoot->initialise(true, "LowLevelOgre Render Window");
//-------------------------------------------------------------------------------------
// choose scenemanager
// Get the SceneManager, in this case the OctreeSceneManager
mSceneMgr = mRoot->createSceneManager("OctreeSceneManager", "DefaultSceneManager");
//-------------------------------------------------------------------------------------
// create camera
// Create the camera
mCamera = mSceneMgr->createCamera("PlayerCam");

// Position it at 500 in Z direction
mCamera->setPosition(Ogre::Vector3(0,0,80));
// Look back along -Z
mCamera->lookAt(Ogre::Vector3(0,0,-300));
mCamera->setNearClipDistance(5);

//-------------------------------------------------------------------------------------
// create viewports
// Create one viewport, entire window
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(
Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
//-------------------------------------------------------------------------------------
// Set default mipmap level (NB some APIs ignore this)
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
//-------------------------------------------------------------------------------------
// Create any resource listeners (for loading screens)
//createResourceListener();
//-------------------------------------------------------------------------------------
// load resources
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//-------------------------------------------------------------------------------------
// Create the scene
Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");

Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
headNode->attachObject(ogreHead);

// Set ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));

// Create a light
Ogre::Light* l = mSceneMgr->createLight("MainLight");
l->setPosition(20,80,50);
//-------------------------------------------------------------------------------------

MyGUI::Gui* mGUI;
MyGUI::OgrePlatform* mPlatform = new MyGUI::OgrePlatform();
mPlatform->initialise(mWindow, mSceneMgr); // mWindow is Ogre::RenderWindow*, mSceneManager is Ogre::SceneManager*
mGUI = new MyGUI::Gui();
mGUI->initialise();

//mRoot->startRendering();
while(true)
{
// Pump window messages for nice behaviour
Ogre::WindowEventUtilities::messagePump();

// Render a frame
mRoot->renderOneFrame();

if(mWindow->isClosed())
{
return false;
}
}

// We should never be able to reach this corner
// but return true to calm down our compiler
return true;
}


#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
// Create application object
LowLevelOgre app;

try {
app.go();
} catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "An exception has occured: " <<
e.getFullDescription().c_str() << std::endl;
#endif
}

return 0;
}

#ifdef __cplusplus
}
#endif


I am getting an error in the the file MyGUI_OgreRenderManager.cpp at the line 107
Ogre::VertexElementType vertex_type = mRenderSystem->getColourVertexElementType();

My LowLevelOgre.log doesn't show any errors but the MyGUI.log stops after the first line
10:39:45 | Platform | Info | * Initialise: RenderManager | ..\..\..\..\Platforms\Ogre\OgrePlatform\src\MyGUI_OgreRenderManager.cpp | 43

Did anyone have the same problem? I still cant figure out the problem but it must be something simple.

Nihon

09-04-2013 12:00:49

UPDATE:: Hi have been talking to Transporter because I use his work the [VS/Win] Snapshot's http://www.ogre3d.org/forums/viewtopic.php?f=4&t=69274 in my case I can not use the compiled MyGUI it gives the strange error described in the topic, I have build MyGUI separately and I found no error working with it. If someone else has the same error I hope this helps.