当前位置: 首页>>代码示例>>C++>>正文


C++ Timer::getMicroseconds方法代码示例

本文整理汇总了C++中ogre::Timer::getMicroseconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::getMicroseconds方法的具体用法?C++ Timer::getMicroseconds怎么用?C++ Timer::getMicroseconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ogre::Timer的用法示例。


在下文中一共展示了Timer::getMicroseconds方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: go

//-------------------------------------------------------------------------------------
void App::go(void)
{
#ifdef _DEBUG
    mResourcesCfg = "resources_d.cfg";
    mPluginsCfg = "plugins_d.cfg";
#else
    mResourcesCfg = "resources.cfg";
    mPluginsCfg = "plugins.cfg";
#endif

    if (!setup())
        return;
	
	Ogre::Timer timer;
	//mRoot->startRendering();
	float lastTime = timer.getMicroseconds()/1000000.0f;
	float curTime = timer.getMicroseconds()/1000000.0f;
	while(update(curTime - lastTime))
	{
		lastTime = curTime;
		curTime = timer.getMicroseconds()/1000000.0f;
		//timer.reset();
	}

    // clean up
    destroyScene();
}
开发者ID:mileswhiticker,项目名称:gam301-assessment02,代码行数:28,代码来源:App.cpp

示例2: renderThreadApp

//---------------------------------------------------------------------
unsigned long renderThreadApp(Ogre::ThreadHandle* threadHandle) {
	LeDernierMorkid::LeDernierMorkidThreadData* threadData     = reinterpret_cast<LeDernierMorkid::LeDernierMorkidThreadData*>(threadHandle->getUserParam());
	GraphicsSystem*                             graphicsSystem = threadData->graphicsSystem;
	Ogre::Barrier*                              barrier        = threadData->barrier;

	graphicsSystem->initialize("Le Dernier Morkid");
	graphicsSystem->getInputHandler()->setGrabMousePointer(true);
	graphicsSystem->getInputHandler()->setMouseVisible(false);
	barrier->sync();

	if (graphicsSystem->getQuit()) {
		graphicsSystem->deinitialize();
		return 0; // User cancelled config
	}

	graphicsSystem->createScene();
	barrier->sync();

	Ogre::RenderWindow* renderWindow = graphicsSystem->getRenderWindow();

	Ogre::Timer   timer;
	unsigned long startTime     = timer.getMicroseconds();
	double        timeSinceLast = 1.0 / 60.0;

	while (!graphicsSystem->getQuit()) {
		graphicsSystem->beginFrameParallel();
		graphicsSystem->update(timeSinceLast);
		graphicsSystem->finishFrameParallel();

		if (!renderWindow->isVisible()) {
			// Don't burn CPU cycles unnecessary when we're minimized.
			Ogre::Threads::Sleep(500);
		}

		unsigned long endTime = timer.getMicroseconds();
		timeSinceLast         = (endTime - startTime) / 1000000.0;
		timeSinceLast         = std::min(1.0, timeSinceLast); // Prevent from going haywire.
		startTime             = endTime;
	}

	barrier->sync();

	graphicsSystem->destroyScene();
	barrier->sync();

	graphicsSystem->deinitialize();
	barrier->sync();

	return 0;
}
开发者ID:Swarthon,项目名称:LeDernierMorkid,代码行数:51,代码来源:GraphicsThread.cpp

示例3: initializeCEGUI

void Application::initializeCEGUI()
{
    Ogre::Timer timer;
    timer.reset();

    CEGUI::OgreRenderer::bootstrapSystem(*mOgreWindow);

    mUIRoot = static_cast<CEGUI::GUISheet*>(CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "Root"));
    mUIRoot->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
    mUIRoot->setSize(CEGUI::UVector2(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0)));
    mUIRoot->setVisible(true);

    CEGUI::System::getSingleton().setGUISheet(mUIRoot);

    CEGUI::SchemeManager::getSingleton().create("OISBDemo.scheme");
	CEGUI::System::getSingleton().setDefaultMouseCursor("OgreTrayImages", "MouseArrow");
    CEGUI::MouseCursor::getSingleton().hide();

    //mUIRoot->addChildWindow(CEGUI::WindowManager::getSingleton().loadWindowLayout("Introduction.layout"));
    mUIRoot->addChildWindow(CEGUI::WindowManager::getSingleton().loadWindowLayout("HUD.layout"));
    mUIHUDThrottle = static_cast<CEGUI::ProgressBar*>(CEGUI::WindowManager::getSingleton().getWindow("HUD/Throttle"));
    mUIHUDVelocity = CEGUI::WindowManager::getSingleton().getWindow("HUD/Velocity");
    mUIHUDAltitude = CEGUI::WindowManager::getSingleton().getWindow("HUD/Altitude");

    std::stringstream sstr;
    sstr << timer.getMicroseconds();

    CEGUI::Logger::getSingleton().logEvent("Time to start CEGUI: " + sstr.str());
}
开发者ID:svn2github,项目名称:oois,代码行数:29,代码来源:Application.cpp

示例4: go

void Application::go()
{
	Ogre::Timer loopTimer;

	bool continueRunning = true;
	while ( continueRunning )
	{
		Ogre::WindowEventUtilities::messagePump();
		
		SimpleInputManager::capture();

		// Update logic stuff
		float elapsedSeconds = loopTimer.getMicroseconds() * 1.0 / 1000000;
		updateLogic( elapsedSeconds );

		// Update graphics stuff
		updateAnimations( elapsedSeconds );
		
		bool windowClosed = m_window->isClosed();
		continueRunning &= ! windowClosed;

		updateStats();

		loopTimer.reset();
		bool renderFrameSuccess = m_root->renderOneFrame();
		continueRunning &= renderFrameSuccess;

		continueRunning &= ! m_exitRequested;		
	}
}
开发者ID:juanjmostazo,项目名称:ouan-tests,代码行数:30,代码来源:Application.cpp

示例5: Run

//  Run
//-------------------------------------------------------------------------------------
void BaseApp::Run( bool showDialog )
{
	mShowDialog = showDialog;
	if (!setup())
		return;

	if (!pSet->limit_fps)
		mRoot->startRendering();  // default
	else
	{	Ogre::Timer tim;
		while (1)
		{
			Ogre::WindowEventUtilities::messagePump();
			if (tim.getMicroseconds() > 1000000.0 / pSet->limit_fps_val)
			{
				tim.reset();
				if (!mRoot->renderOneFrame())
					break;
			}else
			if (pSet->limit_sleep >= 0)
				boost::this_thread::sleep(boost::posix_time::milliseconds(pSet->limit_sleep));
	}	}

	destroyScene();
}
开发者ID:Mixone-FinallyHere,项目名称:stuntrally,代码行数:27,代码来源:BaseApp_Create.cpp

示例6: UpdThr

void App::UpdThr()
{
	Ogre::Timer gtim;
	//#ifdef _WIN32
	//DWORD af = 2;
	//gtim.setOption("QueryAffinityMask", &af);
	//#endif
	gtim.reset();

	while (!mShutDown)
	{
		///  step Game  **

		double dt = double(gtim.getMicroseconds()) * 0.000001;
		gtim.reset();
		
		if (pSet->multi_thr == 1 && !bLoading)
		{
			bSimulating = true;
			bool ret = pGame->OneLoop(dt);
			if (!ret)
				mShutDown = true;

			DoNetworking();
			bSimulating = false;
		}
		boost::this_thread::sleep(boost::posix_time::milliseconds(pSet->thread_sleep));
	}
}
开发者ID:bcraig108,项目名称:stuntrally,代码行数:29,代码来源:Update.cpp

示例7: update

void Application::update()
{
	Ogre::Timer loopTimer;

	bool continueRunning = true;
	
	while (continueRunning)
	{
		Ogre::WindowEventUtilities::messagePump();

		SimpleInputManager::capture();
		
		float elapsedSeconds = loopTimer.getMicroseconds() * 1.0 / 1000000;

		m_NXOgreTimeController->advance(elapsedSeconds);
	
		loopTimer.reset();

		updateOverlayInfo();

		bool renderFrameSuccess = m_root->renderOneFrame();
		
		if (!renderFrameSuccess || m_exitRequested)
		{
			continueRunning = false;
		}
	}
}
开发者ID:juanjmostazo,项目名称:ouan-tests,代码行数:28,代码来源:Application.cpp

示例8: yield

        unsigned long yield( double frameTime, unsigned long startTime )
        {
            unsigned long endTime = mExternalTimer->getMicroseconds();

            while( frameTime * 1000000.0 > (endTime - startTime) )
            {
                endTime = mExternalTimer->getMicroseconds();

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
                SwitchToThread();
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
                sched_yield();
#endif
            }

            return endTime;
        }
开发者ID:arpd,项目名称:ogre2-sample,代码行数:17,代码来源:YieldTimer.hpp

示例9: run

void Application::run()
{
    initialize();
    setupScene();

    Ogre::Timer timer;
    timer.reset();

    mRunning = true;
    while (mRunning)
    {
        const Ogre::Real delta=
            timer.getMicroseconds() * static_cast<Ogre::Real>(0.000001f);
        timer.reset();

        runOneFrame(delta);
    }

    finalize();
}
开发者ID:svn2github,项目名称:oois,代码行数:20,代码来源:Application.cpp

示例10: Play

void Client::Play() {
    OgreEasy::SimpleOgreInit lOgreInit;
    if(!lOgreInit.initOgre()) {
        std::cout<<"Could not init ogre"<<std::endl;
        return;
    }
    Ogre::Root* lRoot = lOgreInit.mRoot.get();
    Ogre::RenderWindow* lWindow = lOgreInit.mWindow;
    World* w = new World();
    w->SetDebugMode(false);
    GameObject camObject = w->AddObject("camera");
    camObject.AddCameraComponent("camera");
    camObject.SetPosition(Ogre::Vector3(0,0,0));
    camObject.LookAt(Ogre::Vector3(0,0,0));

    GameObject& light2 = w->AddObject("point_light");
    light2.AddLightComponent(Ogre::Light::LT_DIRECTIONAL);
    light2.SetPosition(Ogre::Vector3(0,0,40));
    light2.LookAt(Ogre::Vector3(0,100,0));

    GameObject& c = w->AddPhysicsObject("esine", "cube/Cube.mesh");
    c.SetPosition(Ogre::Vector3(0,0,0));
    c.AddBoxCollider(1,1,1);
    PhysicsComponent phys = c.GetPhysicsComponent();
    phys.SetMass(1.0);
    c.SetMaterial("tex");

    GameObject& c2 = w->AddPhysicsObject("esine2", "cube/Cube.mesh");
    c2.SetPosition(Ogre::Vector3(1,2,1));
    c2.AddBoxCollider(1,1,1);
    PhysicsComponent phys2 = c2.GetPhysicsComponent();
    phys2.SetMass(1.0);
    c2.SetMaterial("tex");

    GameObject& taso = w->AddPhysicsObject("taso", "cube/other/Cube.mesh");
    taso.SetPosition(Ogre::Vector3(0, -10, 0));
    taso.AddBoxCollider(10,0.1,10);
    taso.SetMaterial("plane");
    PhysicsComponent phys3 = taso.GetPhysicsComponent();
    phys3.SetMass(0.0);

    GameObject& anim = w->AddObject("anim"  , "second_anim/Cube.mesh");
    anim.SetPosition(Ogre::Vector3(0, -5, 0));
    anim.SetMaterial("tex");

    lRoot->clearEventTimes();
    float f=0.0;
    unsigned long t=0;
    double d;
    Ogre::Timer* a = new Ogre::Timer();
    while(!lWindow->isClosed()) {
        t=a->getMicroseconds();

        camObject.SetPosition(Ogre::Vector3(cos(f)*15.0, -5, sin(f)*15.0));
        camObject.LookAt(Ogre::Vector3(-0,-10,-0), Ogre::Vector3::UNIT_Y);
        w->Update(d);

        f+=d*.5;
        d = (double)(a->getMicroseconds()-t)/1000000;
    }
    delete w;
}
开发者ID:Kilves,项目名称:ogretest,代码行数:62,代码来源:Client.cpp

示例11: mouseReleased

 bool mouseReleased(const OIS::MouseEvent& evt, OIS::MouseButtonID id)
 {
  if (evt.state.buttonDown(OIS::MB_Left) == false)
   SdkSample::mouseReleased(evt, id);
  
  Ogre::Ray ray = mTrayMgr->getCursorRay(mCamera);

  beastie::ray_query result;
  
  Ogre::Timer timer;
  unsigned long rayTime = 0;
  
  timer.reset();
  bool ret = mTree->intersect(ray, 10000, result);
  rayTime = timer.getMicroseconds();
  
  mResultObject->beginUpdate(0);
  
  if (ret)
  {
   // Hit something.

   mResultObject->position(result.hitTriangle.a + (result.hitTriangle.n * 3.f));
   mResultObject->position(result.hitTriangle.b + (result.hitTriangle.n * 3.f));
   mResultObject->position(result.hitTriangle.c + (result.hitTriangle.n * 3.f));
   
   mHitPosLabelX->setCaption(Ogre::StringConverter::toString(result.globalPosition.x));
   mHitPosLabelY->setCaption(Ogre::StringConverter::toString(result.globalPosition.y));
   mHitPosLabelZ->setCaption(Ogre::StringConverter::toString(result.globalPosition.z));

  }
  else
  {
   // Didn't hit anything.
   
   // Try raycasting the ground plane.
   Ogre::Vector3 globalPosition;
  
   if (beastie::intersections::line( beastie::line(ray, 100000) , mPlane, globalPosition ))
   {
    mHitPosLabelX->setCaption(Ogre::StringConverter::toString(globalPosition.x));
    mHitPosLabelY->setCaption(Ogre::StringConverter::toString(globalPosition.y));
    mHitPosLabelZ->setCaption(Ogre::StringConverter::toString(globalPosition.z));

    float const radius = 50;
 
    // accuracy is the count of points (and lines).
    // Higher values make the circle smoother, but may slowdown the performance.
    // The performance also is related to the count of circles.
    float const accuracy = 15;
 
    for(float theta = 0; theta <= 2 * Math::PI; theta += Ogre::Math::PI / accuracy) {
      mResultObject->position(globalPosition.x + (radius * cos(theta)), 0, globalPosition.z + (radius * sin(theta)));
      mResultObject->position(globalPosition);
    }


   }
   else
   {
    
    // Really didn't click on anything at all.
    
    mHitPosLabelX->setCaption("-");
    mHitPosLabelY->setCaption("-");
    mHitPosLabelZ->setCaption("-");
    mResultObject->position(0,0,0);
    mResultObject->position(0,0,0);
    mResultObject->position(0,0,0);
    
   }
   
   
  }
  
  mResultObject->end();

  return true;
 }
开发者ID:betajaen,项目名称:beastie,代码行数:79,代码来源:beastie.example.cpp

示例12: Build

bool NavMesher::Build()
{
  // ******* Only for OBJ Loading ****
 cleanup();
 const char * filepath = "../../media/models/";
 if (!m_geom || !m_geom->loadMesh(filepath))
 {
  delete m_geom;
  m_geom = 0;
  
  m_ctx->log(RC_LOG_ERROR, "Geom load log %s:");
 }
 assert(m_geom);
 if (!m_geom || !m_geom->getMesh())
 {
  m_ctx->log(RC_LOG_ERROR, "buildNavigation: Input mesh is not specified.");
  return false;
 }
 if(m_geom->getMesh()->getTriCount() <= 0 || m_geom->getMesh()->getVertCount()<=0)
  Ogre::Exception(0,Ogre::String("Bad verts or Triangle count. Verts: "+
  StringConverter::toString( m_geom->getMesh()->getVertCount()) + "/n"
  + "Triangles :" +StringConverter::toString(m_geom->getMesh()->getTriCount())),"NavMesher::Build");
 
 //reset timer
 Ogre::Timer tm;
 tm.reset();
 unsigned long stime = tm.getMicroseconds();
 //clear existing
 Clear();
  // ******* Only for OBJ Loading ****
 const float* bmin = m_geom->getMeshBoundsMin();
 const float* bmax = m_geom->getMeshBoundsMax();
 const float* verts = m_geom->getMesh()->getVerts();
 const int nverts = m_geom->getMesh()->getVertCount();
 const int *tris = m_geom->getMesh()->getTris();
 const int ntris = m_geom->getMesh()->getTriCount();

 if(sizeof(tris) <= 0 || ntris <= 0) {
  return false;
 }
 //
 // Step 1. Initialize build config.
 //
 
 // Init build configuration from GUI
 memset(&m_cfg, 0, sizeof(m_cfg));
 m_cfg.cs = m_cellSize;
 m_cfg.ch = m_cellHeight;
 m_cfg.walkableSlopeAngle = m_agentMaxSlope;
 m_cfg.walkableHeight = (int)ceilf(m_agentHeight / m_cfg.ch);
 m_cfg.walkableClimb = (int)floorf(m_agentMaxClimb / m_cfg.ch);
 m_cfg.walkableRadius = (int)ceilf(m_agentRadius / m_cfg.cs);
 m_cfg.maxEdgeLen = (int)(m_edgeMaxLen / m_cellSize);
 m_cfg.maxSimplificationError = m_edgeMaxError;
 m_cfg.minRegionArea = (int)rcSqr(m_regionMinSize);  // Note: area = size*size
 m_cfg.mergeRegionArea = (int)rcSqr(m_regionMergeSize); // Note: area = size*size
 m_cfg.maxVertsPerPoly = (int)m_vertsPerPoly;
 m_cfg.detailSampleDist = m_detailSampleDist < 0.9f ? 0 : m_cellSize * m_detailSampleDist;
 m_cfg.detailSampleMaxError = m_cellHeight * m_detailSampleMaxError;
 
 // Set the area where the navigation will be build.
 // Here the bounds of the input mesh are used, but the
 // area could be specified by an user defined box, etc.
 rcVcopy(m_cfg.bmin, bmin);
 rcVcopy(m_cfg.bmax, bmax);
 rcCalcGridSize(m_cfg.bmin, m_cfg.bmax, m_cfg.cs, &m_cfg.width, &m_cfg.height);
 // Reset build times gathering.
 m_ctx->resetTimers();
 // Start the build process. 
 m_ctx->startTimer(RC_TIMER_TOTAL);
 
 m_ctx->log(RC_LOG_PROGRESS, "Building navigation:");
 m_ctx->log(RC_LOG_PROGRESS, " - %d x %d cells", m_cfg.width, m_cfg.height);
 m_ctx->log(RC_LOG_PROGRESS, " - %.1fK verts, %.1fK tris", nverts/1000.0f, ntris/1000.0f);
 
 //
 // Step 2. Rasterize input polygon soup.
 //
 
 // Allocate voxel heightfield where we rasterize our input data to.
 m_solid = rcAllocHeightfield();
 if (!m_solid)
 {
  m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'solid'.");
  return false;
 }
 if (!rcCreateHeightfield(m_ctx, *m_solid, m_cfg.width, m_cfg.height, m_cfg.bmin, m_cfg.bmax, m_cfg.cs, m_cfg.ch))
 {
  m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not create solid heightfield.");
  return false;
 }
 
 // Allocate array that can hold triangle area types.
 // If you have multiple meshes you need to process, allocate
 // and array which can hold the max number of triangles you need to process.
 m_triareas = new unsigned char[ntris];
 if (!m_triareas)
 {
  m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", ntris);
  return false;
//.........这里部分代码省略.........
开发者ID:vincent,项目名称:poc-recast.js,代码行数:101,代码来源:ex_andrew_aspden.cpp

示例13: main


//.........这里部分代码省略.........
	if (graphicsSystem->getQuit())
	{
		if (logicSystem)
			logicSystem->deinitialize();
		graphicsSystem->deinitialize();

		if (graphicsSystem)
			delete graphicsSystem;
		if (graphicsGameState)
			delete graphicsGameState;

		return 0; //User cancelled config
	}

	Ogre::RenderWindow *renderWindow = graphicsSystem->getRenderWindow();

	graphicsSystem->createScene01();
	if (logicSystem)
		logicSystem->createScene01();

	graphicsSystem->createScene02();
	if (logicSystem)
		logicSystem->createScene02();

#if OGRE_USE_SDL2
	//Do this after creating the scene for easier the debugging (the mouse doesn't hide itself)
	OGraphics::SdlInputHandler *inputHandler = graphicsSystem->getInputHandler();
	inputHandler->setGrabMousePointer(true);
	inputHandler->setMouseVisible(false);
#endif

	Ogre::Timer timer;
#if KYLE_TUTORIAL_GAME_LOOP 1
	unsigned long startTime = timer.getMicroseconds();
	double accumulator = OGraphics::FRAMETIME;
	double timeSinceLast = OGraphics::FRAMETIME;

	while (!graphicsSystem->getQuit())
	{
		while (accumulator >= OGraphics::FRAMETIME && logicSystem)
		{
			logicSystem->beginFrameParallel();
			logicSystem->update(static_cast<float>(OGraphics::FRAMETIME));
			logicSystem->finishFrameParallel();

			logicSystem->finishFrame();
			graphicsSystem->finishFrame();

			accumulator -= OGraphics::FRAMETIME;
		}

		graphicsSystem->beginFrameParallel();
		graphicsSystem->update(static_cast<float>(timeSinceLast));
		graphicsSystem->finishFrameParallel();
		if (!logicSystem)
			graphicsSystem->finishFrame();

		if (!renderWindow->isVisible())
		{
			//Don't burn CPU cycles unnecessary when we're minimized.
			Ogre::Threads::Sleep(500);
		}

		unsigned long endTime = timer.getMicroseconds();
		timeSinceLast = (endTime - startTime) / 1000000.0; // Presumably puts it in milliseconds
		timeSinceLast  = std::min(1.0, timeSinceLast); //Prevent from going haywire.
开发者ID:fulletron,项目名称:BlockGame,代码行数:67,代码来源:main_OLD.cpp

示例14: mainApp

int mainApp()
#endif
{
    PbsMaterialsGameState pbsMaterialsGameState(
        "Shows how to use the PBS material system. There's nothing really fancy,\n"
        "it's just programmer art. The PBS materials can be setup from script or\n"
        "code. This sample does both. At the time being, not all settings from the\n"
        "PBS implementation can be tweaked with scripts. See PbsDatablock::PbsDatablock\n"
        "constructor documentation. Also see the Hlms section of the porting guide in\n"
        "the Docs/2.0 folder.\n"
        "\n"
        "The sphere palette shows what happens when tweaking the roughness around the\n"
        "X axis; and the fresnel term around the Z axis.\n"
        "The scene is being lit by a white directional light (3-split PSSM) and two spot\n"
        "lights, one of warm colour, one cold. Both are also shadowed."
        "\n"
        "Of all the features supported by the PBS implementation, perhaps the hardest to\n"
        "to understand is the Detail Weight Map. It allows you to 'paint' the detail maps\n"
        "over the mesh, by controlling weight of each of the 4 maps via the RGBA channels\n"
        "of the weight map. 'R' controls the detail map 0, 'G' the detail map 1,\n"
        "'B' the detail map 2, and 'A' the detail map 3.\n"
        "\n"
        "This sample depends on the media files:\n"
        "   * Samples/Media/2.0/scripts/Compositors/PbsMaterials.compositor\n"
        "   * Samples/Media/2.0/materials/PbsMaterials/PbsMaterials.material\n"
        "\n"
        "Known issues:\n"
        " * Non shadow casting point & spot lights require Forward3D to be enabled (on desktop).\n"
        "   This is by design (more implementations will come: Forward+ & Deferred; for now the\n"
        "   only one working is F3D).\n"
        " * Shadow casting point lights don't work or work poorly. (feature not implemented yet)\n"
        " * If PSSM shadow casting enabled, the system requires at least one shadow-casting\n"
        "   directional light (bug)\n"
        " * Mobile version only supports forward lighting.\n"
        "\n"
        "LEGAL: Uses Saint Peter's Basilica (C) by Emil Persson under CC Attrib 3.0 Unported\n"
        "See Samples/Media/materials/textures/Cubemaps/License.txt for more information.");
    PbsMaterialsGraphicsSystem graphicsSystem( &pbsMaterialsGameState );

    pbsMaterialsGameState._notifyGraphicsSystem( &graphicsSystem );

    graphicsSystem.initialize( "PBS Materials Sample" );

    if( graphicsSystem.getQuit() )
    {
        graphicsSystem.deinitialize();
        return 0; //User cancelled config
    }

    Ogre::RenderWindow *renderWindow = graphicsSystem.getRenderWindow();

    graphicsSystem.createScene01();
    graphicsSystem.createScene02();

	graphicsSystem.SetUpCustomContent();			// create my custom contents

    //Do this after creating the scene for easier the debugging (the mouse doesn't hide itself)
    SdlInputHandler *inputHandler = graphicsSystem.getInputHandler();
    inputHandler->setGrabMousePointer( true );
    inputHandler->setMouseVisible( false );

    Ogre::Timer timer;
    unsigned long startTime = timer.getMicroseconds();

    double timeSinceLast = 1.0 / 60.0;

    while( !graphicsSystem.getQuit() )
    {
		graphicsSystem.CustomUpdate();		// update my custom rtts
        graphicsSystem.beginFrameParallel();
        graphicsSystem.update( static_cast<float>( timeSinceLast ) );
        graphicsSystem.finishFrameParallel();
        graphicsSystem.finishFrame();

        if( !renderWindow->isVisible() )
        {
            //Don't burn CPU cycles unnecessary when we're minimized.
            Ogre::Threads::Sleep( 500 );
        }

        unsigned long endTime = timer.getMicroseconds();
        timeSinceLast = (endTime - startTime) / 1000000.0;
        timeSinceLast = std::min( 1.0, timeSinceLast ); //Prevent from going haywire.
        startTime = endTime;
    }

    graphicsSystem.destroyScene();
    graphicsSystem.deinitialize();

    return 0;
}
开发者ID:lygyue,项目名称:Sample_PbsMaterials,代码行数:91,代码来源:PbsMaterials.cpp


注:本文中的ogre::Timer::getMicroseconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。