Ejemplo n.º 1
0
bool GameApp::Setup()
{
    //OGRE日志;
    Ogre::LogManager* logMgr = new Ogre::LogManager();
    m_pLog = Ogre::LogManager::getSingleton().createLog("OgreLogfile.log", true, true, false);
    m_pLog->setDebugOutputEnabled(true);

    m_pRoot = new Ogre::Root("plugins_d.cfg");

    //配置;
    if (!Configure())
        return false;

    //设置资源加载;
    SetupResources();

    //场景管理器的初始化;
    SceneMgrInit();

    //输入输出初始化;
    OISInit();

    //GUI管理器的初始化;
    GUIInit();

    //状态管理器的初始化;
    StateInit();

    m_pTimer = new Ogre::Timer();
    m_pTimer->reset();

    m_pRenderWnd->setActive(true);

    return true;
}
Ejemplo n.º 2
0
bool CsBaseApplication::Init() {
	Ogre::String pluginsCfg;
#ifdef _DEBUG
    pluginsCfg = "plugins_d.cfg";
#else
    pluginsCfg = "plugins.cfg";
#endif

    //create ogre root
    mRoot = new Ogre::Root(pluginsCfg);

	SetupResources();
    Ogre::ResourceGroupManager *rgm = Ogre::ResourceGroupManager::getSingletonPtr();

    // set a render system
    Ogre::RenderSystem* rSys;
    rSys = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
    mRoot->setRenderSystem(rSys);
    // end gracelessly if the preferred renderer is not available
    if (mRoot->getRenderSystem() == NULL) {
        delete mRoot;
        return false;
    }

    // create a window
    mRoot->initialise(false);
    mWindow = mRoot->createRenderWindow(
        "CsWindow",   // window name
        1366,                    // window width, in pixels
        768,                    // window height, in pixels
        false,                  // fullscreen or not
        0);                     // use defaults for all other values
    Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

    // extra init
    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

	// Startup the GUI section *******************************************************
	try {
		mRenderer = &CEGUI::OgreRenderer::bootstrapSystem(*mRoot->getRenderTarget("CsWindow"));
	} catch ( CEGUI::Exception& e) {
		MessageBoxA( NULL, e.getMessage().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
		return false;
	}
	//CEGUI::OgreRenderer::bootstrapSystem();

	CEGUI::Imageset::setDefaultResourceGroup("Imagesets");
	CEGUI::Font::setDefaultResourceGroup("Fonts");
	CEGUI::Scheme::setDefaultResourceGroup("Schemes");
	CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
	CEGUI::WindowManager::setDefaultResourceGroup("Layouts");
	
	CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
	CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
	// *******************************************************************************

	rgm->initialiseAllResourceGroups(); 
	// SceneManager and viewports created in the GameInterface component

	CsAudioManager::Create();
	mAudioManager = CsAudioManager::GetSingletonPtr();
	mAudioManager->Init();

    return true;
}