Seventh Demo of OGRE

Fame of CEGUI when used in OGRE

//mem probs without this next one #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 "OgreCEGUIRenderer.h" #include "OgreCEGUIResourceProvider.h" //regular mem handler #include "ExampleApplication.h" class GuiFrameListener : public ExampleFrameListener { private: CEGUI::Renderer* mGUIRenderer; public: GuiFrameListener(RenderWindow* win, Camera* cam, CEGUI::Renderer* renderer) : ExampleFrameListener(win, cam, false, false), mGUIRenderer(renderer) { } }; class FameApplication : public ExampleApplication { public: FameApplication(); ~FameApplication(); //Just override the mandatory create scene method void createScene(void); void destroyScene(void); void createFrameListener(void) { mFrameListener = new GuiFrameListener(mWindow, mCamera, mGUIRenderer); mRoot->addFrameListener(mFrameListener); } private: CEGUI::OgreCEGUIRenderer* mGUIRenderer; CEGUI::System* mGUISystem; CEGUI::Window* mEditorGuiSheet; }; FameApplication::FameApplication() { mGUIRenderer = 0; mGUISystem = 0; mEditorGuiSheet = 0; } FameApplication::~FameApplication() { if(mEditorGuiSheet) { CEGUI::WindowManager::getSingleton().destroyWindow(mEditorGuiSheet); } if(mGUISystem) { delete mGUISystem; mGUISystem = 0; } if(mGUIRenderer) { delete mGUIRenderer; mGUIRenderer = 0; } } void FameApplication::createScene() { // Set ambient light mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow,Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr); mGUISystem = new CEGUI::System(mGUIRenderer); CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative); CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme"); mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook",(CEGUI::utf8*)"MouseArrow"); CEGUI::MouseCursor::getSingleton().setImage("TaharezLook","MouseMoveCursor"); mGUISystem->setDefaultFont((CEGUI::utf8*)"BlueHighway-12"); mEditorGuiSheet=CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"DefaultWindow", (CEGUI::utf8*)"Sheet"); mGUISystem->setGUISheet(mEditorGuiSheet); } void FameApplication::destroyScene() { } INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT ) { // Create application object FameApplication app; try { app.go(); } catch( Ogre::Exception& e ) { MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL); } return 0; }

 

 

你可能感兴趣的:(exception,application,delete,System,CAM,winapi)