![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/*
-----------------------------------------------------------------------------
Filename: cegui.h
-----------------------------------------------------------------------------
This source file is generated by the Ogre AppWizard.
Check out: http://conglomerate.berlios.de/wiki/doku.php?id=ogrewizards
Based on the Example Framework for OGRE
(Object-oriented Graphics Rendering Engine)
Copyright (c) 2000-2007 The OGRE Team
For the latest info, see http://www.ogre3d.org/
You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the OGRE engine.
-----------------------------------------------------------------------------
*/
#ifndef __cegui_h_
#define __cegui_h_
#include "BaseApplication.h"
#include <CEGUI.h>
#include <CEGUISystem.h>
#include <CEGUISchemeManager.h>
#include <OgreCEGUIRenderer.h>
#include <CEGUI/CEGUIImageset.h>
#include <CEGUI/CEGUISystem.h>
#include <CEGUI/CEGUILogger.h>
#include <CEGUI/CEGUISchemeManager.h>
#include <CEGUI/CEGUIWindowManager.h>
#include <CEGUI/CEGUIWindow.h>
#include <CEGUI/CEGUIPropertyHelper.h>
#include <CEGUI/elements/CEGUICombobox.h>
#include <CEGUI/elements/CEGUIListbox.h>
#include <CEGUI/elements/CEGUIListboxTextItem.h>
#include <CEGUI/elements/CEGUIPushButton.h>
#include <CEGUI/elements/CEGUIScrollbar.h>
#include "OgreCEGUIRenderer.h"
#include "OgreCEGUIResourceProvider.h"
class ceguiApp : public BaseApplication
{
public:
ceguiApp(void);
virtual ~ceguiApp(void);
CEGUI::Window* mEditorGuiSheet;
CEGUI::Scrollbar* mRed;
CEGUI::Scrollbar* mGreen;
CEGUI::Scrollbar* mBlue;
CEGUI::Window* mPreview; // StaticImage
CEGUI::Window* mTip;
CEGUI::Listbox* mList;
CEGUI::Window* mEditBox;
protected:
virtual void createScene(void);
public:
void update();
};
#endif // #ifndef __cegui_h_
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/*
-----------------------------------------------------------------------------
Filename: cegui.cpp
-----------------------------------------------------------------------------
This source file is generated by the Ogre AppWizard.
Check out: http://conglomerate.berlios.de/wiki/doku.php?id=ogrewizards
Based on the Example Framework for OGRE
(Object-oriented Graphics Rendering Engine)
Copyright (c) 2000-2007 The OGRE Team
For the latest info, see http://www.ogre3d.org/
You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the OGRE engine.
-----------------------------------------------------------------------------
*/
#include "stdafx.h"
#include "cegui.h"
//-------------------------------------------------------------------------------------
ceguiApp::ceguiApp(void)
{
}
//-------------------------------------------------------------------------------------
ceguiApp::~ceguiApp(void)
{
}
void ceguiApp::update()
{
mRoot->renderOneFrame();
}
//-------------------------------------------------------------------------------------
void ceguiApp::createScene(void)
{
// setup GUI system
mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow,
Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
mGUISystem = new CEGUI::System(mGUIRenderer);
CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
// load scheme and set up defaults
CEGUI::SchemeManager::getSingleton().loadScheme(
(CEGUI::utf8*)"TaharezLookSkin.scheme");
mGUISystem->setDefaultMouseCursor(
(CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
mGUISystem->setDefaultFont((CEGUI::utf8*)"BlueHighway-12");
CEGUI::MouseCursor::getSingleton().setImage("TaharezLook", "MouseArrow");
CEGUI::MouseCursor::getSingleton().show( );
setupEventHandlers();
Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
headNode->attachObject(ogreHead);
// Set ambient light
mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
// Create a light
Light* l = mSceneMgr->createLight("MainLight");
l->setPosition(20,80,50);
CEGUI::Window* sheet =
CEGUI::WindowManager::getSingleton().loadWindowLayout(
(CEGUI::utf8*)"ogregui.layout");
mGUISystem->setGUISheet(sheet);
CEGUI::Combobox* objectComboBox = (CEGUI::Combobox*)CEGUI::WindowManager::getSingleton().getWindow("OgreGuiDemo/TabCtrl/Page2/ObjectTypeList");
CEGUI::ListboxTextItem* item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"FrameWindow", 0);
objectComboBox->addItem(item);
item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"Horizontal Scrollbar", 1);
objectComboBox->addItem(item);
item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"Vertical Scrollbar", 2);
objectComboBox->addItem(item);
item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"StaticText", 3);
objectComboBox->addItem(item);
item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"StaticImage", 4);
objectComboBox->addItem(item);
item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"Render to Texture", 5);
objectComboBox->addItem(item);
}
吧以上四个文件创建好后,加入自己的工程,然后
定义 ceguiApp* app; 在 对话框或者窗口的头文件中,
然后在在对话框或者窗口的初始化函数中增加
app = new ceguiApp();
app->SetWnd(this->m_hWnd);
app->go();
最后在 OnPaint()函数中加上
if(app !=NULL)
{
app->update();
}
不出意外就可以看到CEGUI界面了,要注意这些都是在 OGRE1.4.9下的bin\debug\运行,注意路径问题