#define SetWindowRect( window, x, y, width, height ) \ { \ window->setPosition( \ CEGUI::UVector2( CEGUI::UDim(0.0f, x), \ CEGUI::UDim(0.0f, y) ) \ ); \ window->setSize( \ CEGUI::UVector2( CEGUI::UDim(0.0f, width), \ CEGUI::UDim(0.0f, height) ) \ ); \ } CEGUI::Direct3D9Renderer* g_pRender = NULL; //初始化 g_pRender = &CEGUI::Direct3D9Renderer::create( lpDevice ); CEGUI::System& mGUISystem = CEGUI::System::create(*g_pRender); CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*> (CEGUI::System::getSingleton().getResourceProvider()); rp->setResourceGroupDirectory("schemes", "../Media/gui/"); rp->setResourceGroupDirectory("imagesets", "../Media/gui/"); rp->setResourceGroupDirectory("fonts", "../Media/fonts/"); rp->setResourceGroupDirectory("layouts", "../Media/gui/"); rp->setResourceGroupDirectory("looknfeels", "../Media/gui/"); CEGUI::Imageset::setDefaultResourceGroup("imagesets"); CEGUI::Font::setDefaultResourceGroup("fonts"); CEGUI::Scheme::setDefaultResourceGroup("schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels"); CEGUI::WindowManager::setDefaultResourceGroup("layouts"); CEGUI::SchemeManager::getSingleton().create( (CEGUI::utf8*)"TaharezLookSkin.scheme"); mGUISystem.setDefaultMouseCursor( (CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow"); mGUISystem.setDefaultFont((CEGUI::utf8*)"simkai"); CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window* sheet = wmgr.createWindow( "DefaultGUISheet", "Root" ); mGUISystem.setGUISheet(sheet); /// 创建主窗口 CEGUI::FrameWindow* frame = (CEGUI::FrameWindow*)wmgr.createWindow( "TaharezLook/FrameWindow", "Root/Frame"); SetWindowRect( frame, 0, 26, 200, 400 ); frame->setProperty( "Alpha", "0.0" ); frame->setProperty( "SizingEnabled", "False" ); frame->setProperty( "TitlebarEnabled", "False" ); sheet->addChildWindow( frame ); /// 创建按钮 CEGUI::PushButton* mQuitButton = (CEGUI::PushButton*)wmgr.createWindow( "TaharezLook/Button", "Root/Frame/QuitButton" ); SetWindowRect( mQuitButton, 80, 50, 100, 26 ); mQuitButton->setText( "ChangeModel" ); mQuitButton->setProperty( "InheritsAlpha", "False" ); frame->addChildWindow( mQuitButton ); /// 创建编辑框 CEGUI::MultiLineEditbox* mEditBox = (CEGUI::MultiLineEditbox*)wmgr.createWindow( "TaharezLook/MultiLineEditbox", "Root/Frame/MultiEditbox" ); SetWindowRect( mEditBox, 5, 150, 155, 80 ); mEditBox->setProperty( "InheritsAlpha", "False" ); mEditBox->setProperty( "Alpha", "0.5" ); frame->addChildWindow( mEditBox ); CEGUI::ImagesetManager::getSingleton().createFromImageFile("MyImage", "72.png"); CEGUI::Window* mImage = wmgr.createWindow( "TaharezLook/StaticImage", "Root/Frame/StaticImage"); SetWindowRect( mImage, 0, 30, 50, 50 ); mImage->setProperty( "Image", "set:MyImage image:full_image"); mImage->setProperty( "InheritsAlpha", "False" ); frame->addChildWindow( mImage ); //渲染GUI CEGUI::System::getSingleton().renderGUI(); //销毁 CEGUI::System::getSingleton().destroy(); CEGUI::Direct3D9Renderer::destroy(*g_pRender);