osg显示CEGUI界面

百度和google的好多例子都不能运行,贴一个自己试出来的。借鉴了cegui的自带例子。
#include "stdafx.h"
#include "CEGUIFirstWindow.h"
#include "CEGUI.h"
#include <CEGUIDefaultResourceProvider.h>


int main(int /*argc*/, char* /*argv*/[])
{
// This is a basic start-up for the sample application which is
// object orientated in nature, so we just need an instance of
// the CEGuiSample based object and then tell that sample application
// to run. All of the samples will use code similar to this in the
// main/WinMain function.
FirstWindowSample app;
return app.run();
}

/*************************************************************************
Sample specific initialisation goes here.
************************************************************************
*/
bool FirstWindowSample::initialiseSample()
{
using namespace CEGUI;
// Window* myRoot = WindowManager::getSingleton().loadWindowLayout( "test.layout" );
// System::getSingleton().setGUISheet( myRoot );
WindowManager& winMgr = WindowManager::getSingleton();

// load scheme and set up defaults
SchemeManager::getSingleton().create("TaharezLook.scheme");
System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
FontManager::getSingleton().create("DejaVuSans-10.font");

// load an image to use as a background
ImagesetManager::getSingleton().createFromImageFile("BackgroundImage", "GPN-2000-001437.tga");

// here we will use a StaticImage as the root, then we can use it to place a background image
Window* background = winMgr.createWindow("TaharezLook/StaticImage", "background_wnd");
/*********************************************************
* 设置地球背景
********************************************************
*/
// set position and size
background->setPosition(UVector2(cegui_reldim(0), cegui_reldim( 0)));
background->setSize(UVector2(cegui_reldim(1), cegui_reldim( 1)));
// disable frame and standard background
background->setProperty("FrameEnabled", "false");
background->setProperty("BackgroundEnabled", "false");
// set the background image
background->setProperty("Image", "set:BackgroundImage image:full_image");
/*********************************************************
* 设置地球背景
********************************************************
*/
// install this as the root GUI sheet
System::getSingleton().setGUISheet(background);

// load the windows for Demo7 from the layout file.
Window* sheet = winMgr.loadWindowLayout("bar_list.layout");
// attach this to the 'real' root
background->addChildWindow(sheet);
}
上一张截图


代码中bar_list.layout即为自己用CEGUIEditor编辑的。
其中要注意的是layout中的每个空间的属性要代码中设置的window的属性一致,不然会出错。layout中的很多属性还是没有搞清楚。其中的是否选择全屏幕的问题。总之,好好在研究研究。

posted on 2012-03-22 15:29  chateldon  阅读(1754)  评论(0编辑  收藏  举报

导航