int main(int argc, char *argv[])
#endif
    {
		TRACE_APPNAME("Ogre_App");
		TRACE_CONNECT();
		TRACE_MSG(trace::e_Info, trace::CTX_Default, "Initialized main application");

		// redirect Ogre log to our listener
        LogRedir redir;
        Ogre::LogManager * mLogManager = OGRE_NEW Ogre::LogManager();
        Ogre::Log * log = Ogre::LogManager::getSingleton().createLog("", true, false, false);
        if (log)
            log->addListener(&redir);

        // Create application object
        TutorialApplication app;

        try {
            app.go();
        } catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
            MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
            std::cerr << "An exception has occured: " <<
                e.getFullDescription().c_str() << std::endl;
#endif
        }

        if (log)
            log->removeListener(&redir);
        return 0;
    }
bool OgreAndroidBaseFramework::initOgreRoot()
{
	try {
		// Create logs that funnel to android logs
		mLogManager = OGRE_NEW Ogre::LogManager();
		Ogre::Log *l = mLogManager->createLog("AndroidLog", true, true, true);
		mAndroidLogListener = new AndroidLogListener();
		l->addListener(mAndroidLogListener);

		
		// Create a root object
		mRoot = new Ogre::Root("", "", "");
		
		// Register the ES2 plugin
		mGles2Plugin = new Ogre::GLES2Plugin();
		Ogre::Root::getSingleton().installPlugin(mGles2Plugin);
		
		// Register particle plugin
		mPfxPlugin = new Ogre::ParticleFXPlugin();
		Ogre::Root::getSingleton().installPlugin(mPfxPlugin);
		
		// Grab the available render systems
		const Ogre::RenderSystemList &renderSystemList = mRoot->getAvailableRenderers();
		if(renderSystemList.empty())
			return false;
		
		// Set the render system and init
		Ogre::RenderSystem *system = renderSystemList.front();
		mRoot->setRenderSystem(system);
		mRoot->initialise(false);
		
		mLastTime = mTimer.getMilliseconds();
		
		mAndroidArchiveFactory = new AndroidArchiveFactory(mJni);
		Ogre::ArchiveManager::getSingletonPtr()->addArchiveFactory(mAndroidArchiveFactory);
		
		createResourceGroup("Essential");
		
		// From android assets
		addResourceLocation("RTShaderLib.mp3", "Essential", "Android");
		addResourceLocation("SdkTrays.mp3", "Essential", "Android");
		addResourceLocation("Sinbad.mp3", "Essential", "Android");
		
		// From filesystem
		addResourceLocation("/sdcard/ogre_media/textures", "Essential", "FileSystem");
		addResourceLocation("/sdcard/ogre_media/shaders", "Essential", "FileSystem");
		addResourceLocation("/sdcard/ogre_media/materials", "Essential", "FileSystem");
		addResourceLocation("/sdcard/ogre_media/meshes", "Essential", "FileSystem");
		
	    mRoot->addFrameListener(this);
		mKeyboard = new AndroidKeyboard();
		return true;
		
	} catch(Ogre::Exception &e) {
	}
	
	return false;
}
void
dmz::RenderModuleCoreOgreBasic::_init_root (Config &local) {

   String logName ("ogre.log");
   Boolean suppressLogFileOutput (True);

   Config logData;
   if (local.lookup_config ("log", logData)) {

      suppressLogFileOutput = False;
      logName = config_to_string ("name", logData, logName);
   }

   Ogre::LogManager *logManager = new Ogre::LogManager;

   Ogre::Log *log =
      Ogre::LogManager::getSingleton ().createLog (
         logName.get_buffer (), True, False, suppressLogFileOutput);

   if (suppressLogFileOutput) {

      //Ogre::LogManager::getSingleton ().setLogDetail(Ogre::LL_LOW);
      log->addListener (&_ogreLogger);
   }

   _root = new Ogre::Root("", "");

   ConfigIterator it;
   Config cd;

   Config pluginList;
   if (local.lookup_all_config ("plugins.plugin", pluginList)) {

      Boolean done (!pluginList.get_first_config (it, cd));
      while (!done)  {

         String name;
         if (cd.lookup_attribute ("name", name)) {

            try {

               _root->loadPlugin (name.get_buffer ());
            }
            catch (Ogre::Exception e) {

               String msg (e.getFullDescription ().c_str ());
               _log.error << msg << endl;
            }
         }

         done = !pluginList.get_next_config (it, cd);
      }
   }
}
示例#4
0
文件: ogreinit.cpp 项目: eroen/openmw
    Ogre::Root* OgreInit::init(const std::string &logPath)
    {
        // Set up logging first
        new Ogre::LogManager;
        Ogre::Log *log = Ogre::LogManager::getSingleton().createLog(logPath + std::string("Ogre.log"));

        // Disable logging to cout/cerr
        log->setDebugOutputEnabled(false);

        mRoot = new Ogre::Root("", "", "");

        #if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX)
        loadStaticPlugins();
        #else
        loadPlugins();
        #endif

        loadParticleFactories();

        return mRoot;
    }
示例#5
0
void SoundManager::initialize()
{
	Ogre::Log* log = GameEngine::getSingleton().getLog();

	log->logMessage("Creating FMOD system", Ogre::LML_NORMAL);
	checkFmodResult(FMOD::System_Create(&fmodSystem));
	
	log->logMessage("Checking FMOD version", Ogre::LML_NORMAL);
	
	unsigned int version;
	checkFmodResult(fmodSystem->getVersion(&version));
	
	if(version < FMOD_VERSION)
	{
		log->logMessage("You are using an old version of FMOD. This program requires FMOD >= 4.08.07.");
		throw std::runtime_error("You are using an old version of FMOD. This program requires FMOD >= 4.08.07.");
	}
	
	log->logMessage("Setting FMOD output type", Ogre::LML_NORMAL);
	
#ifdef WIN32
	checkFmodResult(fmodSystem->setOutput(FMOD_OUTPUTTYPE_DSOUND));
#else
	checkFmodResult(fmodSystem->setOutput(FMOD_OUTPUTTYPE_ALSA));
#endif

	log->logMessage("Initializing FMOD system", Ogre::LML_NORMAL);
	checkFmodResult(fmodSystem->init(32, FMOD_INIT_NORMAL, 0));
}
示例#6
0
bool initOgreRoot(){
	try{
		// Create logs that funnel to android logs
		Ogre::LogManager *lm = OGRE_NEW Ogre::LogManager();
		Ogre::Log *l = lm->createLog("AndroidLog", true, true, true);
		g_ll = OGRE_NEW AndroidLogListener();
		l->addListener(g_ll);
		
		// Create a root object
		g_root = OGRE_NEW Ogre::Root("", "", "");
		
		// Register the ES2 plugin
		g_gles2Plugin = OGRE_NEW Ogre::GLES2Plugin();
		Ogre::Root::getSingleton().installPlugin(g_gles2Plugin);
		
		// Register particle plugin
		g_pfxPlugin = OGRE_NEW Ogre::ParticleFXPlugin();
		Ogre::Root::getSingleton().installPlugin(g_pfxPlugin);
		
		// Grab the available render systems
		const Ogre::RenderSystemList &renderSystemList = g_root->getAvailableRenderers();
		if(renderSystemList.empty())
		{
			return false;
		}
		
		// Set the render system and init
		Ogre::RenderSystem *system = renderSystemList.front();
		g_root->setRenderSystem(system);
		g_root->initialise(false);
		
		g_lastTime = g_timer.getMilliseconds();
		
		return true;
	}catch(Ogre::Exception &e){
	}
	return false;
}
示例#7
0
int main(int argc, char **argv)
#endif
{
    int ret = 0;
    Ogre::Log * log = NULL;
    Ogre::Root * root = NULL;
    GameManager* game = NULL;
    Ogre::LogManager * logMgr = NULL;
    bool configCreated = false;
    std::string ogreLogPath, ogreCfgPath;
    
    srand(time(NULL));
    
    using namespace boost::filesystem;
    // Creates the Lost Marbles directory to write to
    path lostMarblesDir(utils::getLostMarblesWriteDir());
    
    try {
        if(! exists(lostMarblesDir))
            create_directories(lostMarblesDir);
    } catch(const filesystem_error& ex) {
        #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBoxA(NULL, ex.what(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
        #else
        std::cerr << "An exception has occured: " << ex.what() << std::endl;
        #endif
        ret = 1;
        goto gracefulexit;
    }
    

    ogreLogPath = (lostMarblesDir / "Ogre.log").string();
    logMgr = new Ogre::LogManager();
    log = logMgr->createLog(ogreLogPath, true, true, false);
    
    ogreCfgPath = (lostMarblesDir / "Ogre.cfg").string();
    root = new Ogre::Root("Plugins.cfg",ogreCfgPath);

    log->logMessage("Main Lost Marbles write directory " + lostMarblesDir.string());
    log->logMessage("Log Path: " + ogreLogPath);
    log->logMessage("Config Path: " + ogreCfgPath);

    if(!root->restoreConfig()) {
        configCreated = root->showConfigDialog();
        root->saveConfig();
    } else
        configCreated = true;

    if(configCreated) {
        game = new GameManager();

        try {
            // initialize the game and switch to the first state
            game->start(LogoState::getInstance());
        } catch (Ogre::Exception& e) {
            #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
            MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
            #else
            std::cerr << "An exception has occured: " << e.getFullDescription() << std::endl;
            #endif
            ret = 1;
            goto gracefulexit;
        } 
    }

gracefulexit:
    if(game) delete game;
    if(root) delete root;
    if(logMgr) delete logMgr;
    return ret;
}
示例#8
0
/*!
 * Initialize the application, in particular initialize OGRE and OIS
 * (the input system, see \ref InputHandler).
 *
 * \return TRUE on success, otherwise FALSE. The application should be
 * quit, if initializing failed.
 */
bool TestApp::initialize() {
    if (mOgreRoot) {
        // already initialized
        return true;
    }
    Ogre::String pluginFileName = "plugins.cfg"; // don't use any plugin config file
                                      // (we specify everything by code)
    Ogre::String configFileName = "ogre.cfg"; // don't use any config file
                                      // (we specify everything by code)

    // AB: we create our own logmanager - ogre will use that one.
    Ogre::String logFileName = "Ogre.log"; // AB: name to identify the log - won't necessarily write to a file!
    mOgreLogManager = new Ogre::LogManager();

    // create a default log that ogre itself is going to use.
    bool suppressFileOutput = false;
    bool outputToConsole = true;
    Ogre::Log* log = mOgreLogManager->createLog(logFileName, true, outputToConsole, suppressFileOutput);
    log->addListener(mMyOgreLogListener);

    // AB: atm we don't specify the 3rd parameter and thus use the default Ogre
    //     log filename (Ogre.log in the current dir)
    //     we could just use "" to disable the logfile.
    mOgreRoot = new Ogre::Root(pluginFileName, configFileName);

    // we use OpenGL
    //#if defined __APPLE__ || defined WIN32
    //    mOgreRoot->loadPlugin("RenderSystem_GL");
    //#else
    //    mOgreRoot->loadPlugin(DCOLLIDE_OGRE_PLUGIN_DIR "/RenderSystem_GL");
    //#endif

    Ogre::RenderSystemList* renderSystemList = mOgreRoot->getAvailableRenderers();
    if (renderSystemList->empty()) {
        std::cerr << "Could not load any renderers?!" << std::endl;
        return false;
    }
    Ogre::RenderSystem* renderSystem = renderSystemList->at(0);
    mOgreRoot->setRenderSystem(renderSystem);
    mOgreRoot->initialise(false);


    // Create a window
    int width = 1024;
    int height = 768;
    bool fullscreen = false;
    mRenderWindow = mOgreRoot->createRenderWindow("d-collide test application", width, height, fullscreen);
    if (!mUseGUI) {
        mRenderWindow->setVisible(false);
    }
    mWindowEventListener = new MyWindowEventListener(mRenderWindow);

    mOgreRoot->addResourceLocation("../resources/textures", "FileSystem", "DCollideMaterials");

    mOgreRoot->addResourceLocation("../resources/models", "FileSystem", "DCollideModels");

    // input
    int windowHandle = 0;
    mRenderWindow->getCustomAttribute("WINDOW", &windowHandle);
    mInputHandler = new InputHandler(windowHandle);
    mInputHandler->setTestApp(this);
    mInputHandler->setWindowSize(width, height);
    mWindowEventListener->setInputHandler(mInputHandler);

    // GUI
    mGui = new Gui(mOgreRoot, mRenderWindow);
    mGui->setInputHandler(mInputHandler);
    mGui->addFrameHistory(mFrameHistory, false);
    mGui->addFrameHistory(mGraphicFrameHistory, true);
    mGui->addFrameHistory(mSceneUpdateHistory, true);
    mGui->addFrameHistory(mPhysicsStepHistory, true);
    mGui->addFrameHistory(mCollisionFrameHistory, true);
    if (!mGui->initialize()) {
        std::cerr << "Could not initialize the GUI" << std::endl;
        return false;
    }

    // our actual scene
    changeCurrentScene("default");

    if (!mScene) {
        //error() << "NULL current scene: could not initialize default scene";
        return false;
    }

    mInputHandler->initActions();

    return true;
}
void BouwplaatsGameClient::loadLogin()
{
	Ogre::Log* log = Ogre::LogManager::getSingleton().getDefaultLog();
	log->logMessage("BOUW: Ogre loaded");

	// setup main window; hardcode some defaults for the sake of presentation
	Ogre::NameValuePairList opts;
	opts["resolution"] = "1024x700";
	opts["fullscreen"] = "false";
	opts["vsync"] = "false";

	// create a rendering window with the title "CDK"
	window = ogre->createRenderWindow("Bouwgame Client v0.1", 1024, 700, false, &opts);

	log->logMessage("BOUW: Window Created");

	
	// since this is basically a CEGUI app, we can use the ST_GENERIC scene manager for now; in a later article 
	// we'll see how to change this
	mainSceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC);
	ModelLibrary::Load(mainSceneMgr);
	
	//secSceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC);
	//secCamera = secSceneMgr->createCamera("secCamera");
	//secCamera->setNearClipDistance(5);


	mainCamera = mainSceneMgr->createCamera("mainCamera");
	mainCamera->setNearClipDistance(5);
	mainCamera->setFrustumOffset(0.125f);
/*
    The ratio between the x and y dimensions of the rectangular area 
	visible through the frustum is known as aspect ratio: aspect = width / height . 

    The default for most fullscreen windows is 1.3333 - this is also assumed by Ogre 
	unless you use this method to state otherwise. 
*/   
	mainVp = window->addViewport(mainCamera);
	mainVp->setBackgroundColour(Ogre::ColourValue(0.476f,0.550f,0.683f,0.0f));

	mainSceneMgr->setAmbientLight(Ogre::ColourValue(0.8, 0.8, 0.8));
	mainSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);

	log->logMessage("BOUW: Scene created");

	soundManager = new OgreAL::SoundManager();

	log->logMessage("BOUW: Sound Manager created");

	node = mainSceneMgr->getRootSceneNode()->createChildSceneNode("CameraNode");
	//node->setPosition(0, 15, 300);
	node = node->createChildSceneNode("PitchNode");
	node->attachObject(mainCamera);
	node->attachObject(soundManager->getListener());
	node->setPosition(0, 15, 300);

	// this next bit is for the sake of the input handler
	
	window->getCustomAttribute("WINDOW", &hWnd);
	
	log->logMessage("BOUW: Nodes created");
	gui = new GuiManager(soundManager);

	dataMan->gui = gui;

	// set up the input handlers
	sim = new Simulation();
	entityController = new EntityController(dataMan, mainSceneMgr, soundManager);
	dataMan->entityController = entityController;
	gameAI = new GameAI(dataMan, entityController);
	entityController->setGameAI(gameAI);
	//handler = new InputHandler(sim, hWnd, mainCamera, entityController, dataMan, mainSceneMgr);
	handler = new InputHandler(sim, hWnd, mainCamera, entityController);
	gui->setSimulation(sim);
	gui->init("", ogre, mainSceneMgr, window, dataMan, handler);
	gui->changeLayout(LOGINLAYOUT);

	//sim->requestStateChange(GUIKEYINPUT);
	// wat entities
	//entityController->createPersonel(3, gameAI, 10, 10);
	//entityController->createOnsite(4, 0, 0);
	//entityController->createOnsite(5, 0, 0);
	//gui->activate("main");
	log->logMessage("BOUW: Stuff set up");

	handler->setWindowExtents(window->getWidth(),window->getHeight());

	Ogre::WindowEventUtilities::addWindowEventListener(window, handler);

	if(node->getName() == "LogoNode")
	{
		node->setPosition(0,0,0);
	}
	else
	{
		ent = mainSceneMgr->createEntity( "LogoEntity", "logo.mesh" );
		node = mainSceneMgr->getRootSceneNode()->createChildSceneNode("LogoNode", Ogre::Vector3(0, 0, 0));
		node->attachObject(ent);
	}
	dataMan->sim = sim;

	try
	{
		sound = soundManager->createSound("LogoSound", "logo.wav", false);
	}
	catch(...)
	{
		log->logMessage("audio file not found");
		sound = 0;
	}

	if(sound)
	{
		sound->play();
	}

	log->logMessage("BOUW: Init done");
}
示例#10
0
	bool BaseManager::init()
	{
		Ogre::String pluginsPath;

		mFrameCount = 0;
		mPickFrameCount = 0;
		mPickX = 0;
		mPickY = 0;

		#ifndef OGRE_STATIC_LIB
			pluginsPath = mResourcePath + mPluginCfgName;
		#endif

		mFastReset = false;
		mReset = false;
		mExit = false;
		
		mInputFilter = new InputFilter();

		mRoot = new Ogre::Root(pluginsPath, mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");

		Ogre::Log* plog = Ogre::LogManager::getSingleton().getDefaultLog();
		if( plog ){
			mCoutSource = new CoutSource();
			plog->addListener( mCoutSource );
		}
        
		//恢复Ogre配置,如果第一次配置启动一个Ogre配置对话框
		if (!mRoot->restoreConfig())
		{
			if (!mRoot->showConfigDialog()) return false;
		}

		mWindow = mRoot->initialise(true);

		createSceneManager();

		// Set default mipmap level (NB some APIs ignore this)
		Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

		mRoot->addFrameListener(this);
		Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

		size_t handle = 0;
		mWindow->getCustomAttribute("WINDOW", &handle);

		mSceneQuery = mSceneManager->createRayQuery( Ogre::Ray() );

		createGui();
        
		createInput(handle);

		createPointerManager(handle);
        
		createScene();

		windowResized(mWindow);

		mRoot->getRenderSystem()->_initRenderTargets();

		setPointerVisible(false);

		return true;
	}
void NativeEnginePrivate::initOgre()
{
#if !defined(NDEBUG)
    Ogre::String pluginsCfg = "plugins_d.cfg";
#else
    Ogre::String pluginsCfg = "plugins.cfg";
#endif

    Ogre::LogManager * lm = new Ogre::LogManager();
    Ogre::Log *log = lm->createLog("", true, false, false);
    log->addListener(this);

    /* Initialize Ogre */
    ogreRoot = new Ogre::Root(pluginsCfg);

    /* Set OpenGL render system on Ogre */
    Ogre::RenderSystem *renderSystem = ogreRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
    if (!renderSystem)
        throw std::exception("Unable to find OpenGL Render System!");
    renderSystem->setConfigOption("Colour Depth", "32");
    renderSystem->setConfigOption("Fixed Pipeline Enabled", "Yes");
    renderSystem->setConfigOption("VSync", "No");
    ogreRoot->setRenderSystem(renderSystem);

    ogreRoot->initialise(false);

    /* Initialize the render window to use the GLWidget internally */
    Ogre::NameValuePairList params;
    params["externalGLControl"] = "true";
    params["externalGLContext"] = QString::number((uint)wglGetCurrentContext()).toStdString(); // TODO: Platform dependent
    params["externalWindowHandle"] = QString::number((uint)glWidget->winId()).toStdString();
    ogreWindow = ogreRoot->createRenderWindow("", glWidget->width(), glWidget->height(), false, &params);

    /* We don't use mip maps since our camera distance from all objects is fixed */
    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(0);

    /* here we could load "builtin" resources, but all other resources should be controlled by c# */
    /*Ogre::ResourceGroupManager &resourceManager = Ogre::ResourceGroupManager::getSingleton();
    resourceManager.addResourceLocation("C:/Users/Sebastian/AppData/Local/EvilTemple/data.zip", "Zip", "General", true);
    resourceManager.initialiseAllResourceGroups();*/

    /* Create the actual scene manager */
    ogreRoot->addSceneManagerFactory(new SceneFactory);
    ogreRoot->addMovableObjectFactory(new GroundDiscFactory);
    sceneManager = static_cast<Scene*>(ogreRoot->createSceneManager("Scene"));
    sceneManager->resizeWindow(glWidget->width(), glWidget->height());

    /* Create and initialize the main camera */
    camera = sceneManager->getMainCamera();

    /* Create the viewport */
    viewport = ogreWindow->addViewport(camera);
    viewport->setBackgroundColour(Ogre::ColourValue(0.5, 0.5, 0.5));

    sceneManager->setAmbientLight(Ogre::ColourValue(0, 0, 0));

    /* TEST */
    /*Ogre::Entity* model = sceneManager->createEntity("meshes/pcs/pc_human_male/pc_human_male.mesh");

    Ogre::SceneNode* headNode = sceneManager->getRootSceneNode()->createChildSceneNode();
    headNode->setPosition(0, 0, 0);
    headNode->attachObject(model);

    Ogre::AnimationState *animState = model->getAnimationState("unarmed_unarmed_idle");
    animState->setEnabled(true);
    animState->setLoop(true);
    animState->setWeight(1.0f);

    sceneManager->setAmbientLight(Ogre::ColourValue(0, 0, 0));

    // Create a light
    Ogre::Light* l = sceneManager->createLight("MainLight");
    l->setType(Ogre::Light::LT_DIRECTIONAL);
    l->setDirection(-0.6324093645670703858428703903848,
                    -0.77463436252716949786709498111783,
                    0);*/

    /* /TEST */
}