CEGUI初學者指南1——使用CEGUI渲染

來源:互聯網
上載者:User

使用CEGUI渲染的初學者指南
From CEGUIWiki

無論使用哪個引擎,使用CEGUI渲染GUI必須有三個步驟

  1. 建立一個CEGUI::Renderer基底物件.
  2. 建立CEGUI::System對象.
  3. 調用相關方法渲染GUI

很明顯在此之前必須裝載一些基本的檔案,這些將會在下面的裝載資料檔案和初始化中介紹到。另外你必須獲得系統輸入,這些將會在插入輸入的初學者指南中介紹到
 

1 建立一個CEGUI::Renderer基底物件.

必須include你使用渲染器的標頭檔。

基本的建立代碼:

Direct3D 8.1

CEGUI::DirectX81Renderer* myRenderer =
 new CEGUI::DirectX81Renderer(myD3D8Device);

Direct3D 9

CEGUI::DirectX9Renderer* myRenderer =
 new CEGUI::DirectX9Renderer(myD3D9Device);

OpenGL

CEGUI::OpenGLRenderer* myRenderer =
 new CEGUI::OpenGLRenderer(0);

Ogre3D

CEGUI::OgreCEGUIRenderer* myRenderer =
 new CEGUI::OgreCEGUIRenderer(myRenderWindow);

Irrlicht Engine

CEGUI::IrrlichtRenderer* myRenderer =
 new CEGUI::IrrlichtRenderer(myIrrlichtDevice, true);

 

2 建立CEGUI::System對象.

傳遞一個剛才建立的渲染器指標
new CEGUI::System(myRenderer);

 

3 調用相關方法渲染GUI

這個是唯一和你的渲染器相關的步驟,因此要根據情況分開調用。你必須在渲染迴圈的最後調用CEGUI::System::renderGUI。Ogre3D引擎的使用者不需要做這個。例子如下

Direct3D 8.1 / 9

// Start the scene
myD3DDevice->BeginScene();
// clear display
myD3DDevice->Clear(0, 0, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
// user function to draw 3D scene
draw3DScene();
// draw GUI
CEGUI::System::getSingleton().renderGUI();
// end the scene
myD3DDevice->EndScene();
// finally present the frame.
myD3DDevice->Present(0, 0, 0, 0);

OpenGL

// user function to draw 3D scene
draw3DScene();
// draw GUI (should not be between glBegin/glEnd pair)
CEGUI::System::getSingleton().renderGUI();

Irrlicht

// start the scene
myIrrlichtDriver->beginScene(true, true, irr::video::SColor(150,50,50,50));
// draw main scene
myIrrlichtSceneManager->drawAll();
// draw gui
CEGUI::System::getSingleton().renderGUI();
// end the scene
myIrrlichtDriver->endScene();

4 結論
這是CEGUI最基礎的教程。一些話題沒有在這裡介紹,例如在OGER3D中使用不同的情境管理器;以及一些進階話題,例如使用者選擇資源提供者,等等

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.