It runs triumphantly.
Then I try to add a cegui's mouse in the project.
After I spend some time to search the forums,I get some code which is half-baked.
However,I'm confused about loading cegui's resource.
For example,it always occurs error that "TaharezLook.scheme" can not be found.
So I think my code which loads cegui's resource is not correct.
But I don't know where is not correct.
By the way,I had built the ogre1.7 and cegui0.7.1 triumphantly and run the cegui's
sample triumphantly.
At the same time,copy all .dll and .lib in my project.
my project's frame:
E:\ogrework\samples1\testCegui // my project
E:\ogrework\datafiles // cegui's resource
E:\ogrework\samples1\Include\CEGUI // cegui's include
E:\ogrework\samples1\lib\debug // cegui's lib
E:\ogrework\bin\debug // cegui's and ogre's .dll
E:\ogrework\bin\media // ogre's resource
my project's include path:
"$(OGRE_HOME)\OgreMain\include";
"$(OGRE_HOME)\include";
"$(OGRE_HOME)\Dependencies\include";
..\Include\cegui
my project's lib path:
"$(OGRE_HOME)\lib\$(ConfigurationName)";
"$(OGRE_HOME)\Dependencies\lib\$(ConfigurationName)";
"..\lib\$(ConfigurationName)";
my project's lib:
OgreMain_d.lib
OIS_d.lib
CEGUIBase_d.lib
CEGUIOgreRenderer_d.lib
my project's code:
Code: Select all
#include "ExampleApplication.h"
#include "CEGUI.h"
#include "RendererModules/Ogre/CEGUIOgreRenderer.h"
class MyListener : public ExampleFrameListener
{
public:
SceneManager* mSceneMgr;
public:
MyListener(SceneManager *sceneMgr, RenderWindow* win, Camera* cam)
: ExampleFrameListener(win, cam)
, mSceneMgr(sceneMgr)
{
}
bool frameStarted(const FrameEvent& evt)
{
if (!ExampleFrameListener::frameStarted(evt))
return false;
return true;
}
};
class test : public ExampleApplication
{
public:
test()
{}
~test()
{
unloadCEGUIResoure();
}
void loadCEGUIResource()
{
// initialise the required dirs for the DefaultResourceProvider
CEGUI::DefaultResourceProvider* rp = (CEGUI::DefaultResourceProvider*)
(CEGUI::System::getSingleton().getResourceProvider());
rp->setResourceGroupDirectory("schemes", "../datafiles/schemes/");
rp->setResourceGroupDirectory("imagesets", "../datafiles/imagesets/");
rp->setResourceGroupDirectory("fonts", "../datafiles/fonts/");
rp->setResourceGroupDirectory("layouts", "../datafiles/layouts/");
rp->setResourceGroupDirectory("looknfeels", "../datafiles/looknfeel/");
rp->setResourceGroupDirectory("lua_scripts", "../datafiles/lua_scripts/");
// set the default resource groups to be used
CEGUI::Imageset::setDefaultResourceGroup("imagesets");
CEGUI::Font::setDefaultResourceGroup("fonts");
CEGUI::Scheme::setDefaultResourceGroup("schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
CEGUI::WindowManager::setDefaultResourceGroup("layouts");
CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");
}
void unloadCEGUIResource()
{
}
void createScene(void)
{
mSceneMgr->setAmbientLight( ColourValue( 1.0, 1.0, 1.0) );
// camera
mCamera->setPosition(Vector3(0,200,200));
mCamera->lookAt(Vector3(0,0,0));
// ground
Plane plane(Vector3::UNIT_Y, 0);
MeshManager::getSingleton().createPlane("ground",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
400,400,20,20,true,1,5,5,Vector3::UNIT_Z);
Entity *ent3 = mSceneMgr->createEntity("GroundEntity", "ground");
SceneNode *node3 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node3", Vector3( 0, 0, 0 ));
node3->attachObject(ent3);
ent3->setMaterialName("Examples/Rockwall");
// load CEGUI resource
loadCEGUIResource();
// CEGUI setup
CEGUI::OgreRenderer& mGUIRender = CEGUI::OgreRenderer::create();
CEGUI::System::create(mGUIRender);
CEGUI::Window* mEditorGuiSheet = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow","Sheet");
// Mouse
CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
// add window
CEGUI::System::getSingleton().setGUISheet(mEditorGuiSheet);
}
void createFrameListener(void)
{
mFrameListener = new MyListener(mSceneMgr, mWindow, mCamera);
mRoot->addFrameListener(mFrameListener);
}
};
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
test app;
try {
app.go();
} catch( 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
fprintf(stderr, "An exception has occured: %s\n",
e.getFullDescription().c_str());
#endif
}
return 0;
}