嵌入CEGUI和 OGRE 到MFC界面中(二)

ContractedBlock.gif ExpandedBlockStart.gif Code
/*
-----------------------------------------------------------------------------
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 ExpandedBlockStart.gif Code
/*
-----------------------------------------------------------------------------
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, 
false3000, 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.50.50.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\运行,注意路径问题

 

 

 

 

转载于:https://www.cnblogs.com/bluebirdzx/archive/2008/08/12/1266027.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值