首先,在其官网下载windows版本的CEGUI-0.7.1.zip源码压缩包和vs编译用的依赖库CEGUI-DEPS-0.7.x-r1-vc71.zip(我的开发环境是vs2003,所以是vc71)。哎,干什么事情一定要细心,一不小心下了个CEGUI-DEPS-0.7.x-r1-vc9.zip ,结果编译的时候出现了莫名其妙的错误,更新成了VC71的就没问题了,可见欲速则不达的真理啊.....
下载网址:http://cegui.org.uk/api_reference/downloading.html
然后,解压CEGUI-0.7.1.zip,生成CEGUI-0.7.1文件夹,将CEGUI-DEPS-0.7.x-r1-vc71.zip解压产生的dependencies放入CEGUI-0.7.1目录中,在进入CEGUI-0.7.1\projects\premake目录,执行build_vs2003.bat批处理脚本,生成CEGUI.sln工程文件,就可以编译了,一般情况下编译非常顺利。
我遇到了点问题:运行的时候提醒我logo.png没有加载上,莫非工作目录不对? 去see see,所有例子的工作目录都为空,而资源文件夹datafiles路径是CEGUI-0.7.1\datafiles,
跟踪程序发现CEGuiD3D9BaseApplication的构造函数中调用了DefaultResourceProvider加载资源
void CEGuiBaseApplication::initialiseResourceGroupDirectories()
{
// initialise the required dirs for the DefaultResourceProvider
CEGUI::DefaultResourceProvider* rp =
static_cast<CEGUI::DefaultResourceProvider*>
(CEGUI::System::getSingleton().getResourceProvider());
const char* dataPathPrefix = getDataPathPrefix();
char resourcePath[PATH_MAX];
// for each resource type, set a resource group directory
sprintf(resourcePath, "%s/%s", dataPathPrefix, "schemes/");
rp->setResourceGroupDirectory("schemes", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "imagesets/");
rp->setResourceGroupDirectory("imagesets", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "fonts/");
rp->setResourceGroupDirectory("fonts", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "layouts/");
rp->setResourceGroupDirectory("layouts", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "looknfeel/");
rp->setResourceGroupDirectory("looknfeels", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "lua_scripts/");
rp->setResourceGroupDirectory("lua_scripts", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "xml_schemas/");
rp->setResourceGroupDirectory("schemas", resourcePath);
}
默认搜索的资源是../datafiles/schemes/ , ../datafiles/imagesets/, ../datafiles/fonts/, ........
以为着不用修改所有例子程序的工作目录,只需要将CEGUI-0.7.1\datafiles( 我这解压后就是这个路径 ),拷贝到CEGUI-0.7.1\projects\premake\Samples下就OK
但是执行的时候却遇到了问题,我运行所有的CEGUI Sample全部内存错误,后来我跟踪发现Window::setParent(Window* parent)函数有问题,在他的函数体内只保留d_parent = parent;transferChildSurfaces(); 这两行内容就可以了,再编译就一切正常了。 PS: 注释的函数不知道有没有潜在的错误
OK 编译正常,可以运行
参照Demo写一个简单的例子:
int main(int /**//*argc*/, char* /**//*argv*/[])
{
TDemo demo;
return demo.run();
}
bool TDemo::initialiseSample()
{
using namespace CEGUI;
WindowManager& winMgr = WindowManager::getSingleton();
SchemeManager::getSingleton().create( "WindowsLook.scheme" );
//Create cursor
System::getSingleton().setDefaultMouseCursor("WindowsLook", "MouseArrow" );
//Create font
FontManager::getSingleton().create( "Girl.font" );
//Create root window
DefaultWindow* root = (DefaultWindow*)winMgr.createWindow( "WindowsLook/StaticImage", "RootWindow" );
//Set GUI root window
System::getSingleton().setGUISheet( root );
//Create child window
Window* st = winMgr.createWindow( "WindowsLook/StaticText", "StaticText" );
root->addChildWindow( st );
st->setPosition( UVector2( cegui_reldim(0.45), cegui_reldim(0.23) ) );
st->setSize( UVector2( cegui_reldim(0.15), cegui_reldim(0.05) ) );
st->setText( "Hello world" );
return true;
}
void TDemo::cleanupSample()
{
}
go go go,虽然起步比较晚,但总比没有好,加油
posted on 2010-06-13 12:24
风轻云淡 阅读(1366)
评论(0) 编辑 收藏 引用 所属分类:
OGRE