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


C++ IVideoDriver::getFPS方法代码示例

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


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

示例1: drawDocument

// drawDocument
// draw documen by frame
void CDocument::drawDocument()
{
	// draw document
	IVideoDriver* driver = getIView()->getDriver();
	ISceneManager* smgr = getIView()->getSceneMgr();

	// draw 3d scene
	driver->beginScene( true, true, SColor(255,30,30,30), getIView()->getVideoData() );
		
	// draw all scene
	smgr->drawAll();

	// controller draw imp
	CControllerManager::getInstance()->getCurrentController()->render();
	
	int fps = driver->getFPS();
	core::stringw text(L"fps: ");
	text += fps;
	text += L" frame/second \n";

	int primitiveDraw =	driver->getPrimitiveCountDrawn();
	text += L"primitive: ";
	text += primitiveDraw;

	irr::gui::IGUIFont* font = smgr->getGUIEnvironment()->getBuiltInFont();
	font->draw( text.c_str(), core::recti( 10, 10, 200, 20), video::SColor(255, 255,0,0) );

	// end scene
	driver->endScene();
}
开发者ID:codeman001,项目名称:gsleveleditor,代码行数:32,代码来源:CDocument.cpp

示例2: irrUpdate

void CIrrWindow::irrUpdate()
{
	// draw document
	IVideoDriver* driver = m_driver;
	ISceneManager* smgr = m_smgr;

	// tick device
	m_device->getTimer()->tick();

	// update particle
	m_particleObject->updateObject();

	// draw 3d scene
	driver->beginScene( true, true, 0, getIView()->getVideoData() );
		
	// draw all scene
	smgr->drawAll();	
	
	int fps = driver->getFPS();
	core::stringw text(L"fps: ");
	text += fps;
	text += L" frame/second";

	irr::gui::IGUIFont* font = smgr->getGUIEnvironment()->getBuiltInFont();
	font->draw( text.c_str(), core::recti( 10, 10, 200, 20), video::SColor(255, 255,0,0) );

	// end scene
	driver->endScene();

}
开发者ID:codeman001,项目名称:gsleveleditor,代码行数:30,代码来源:CIrrWindow.cpp

示例3: main

int main()
{
    // we'll use the OGL driver
	IrrlichtDevice *device =
		createDevice(EDT_OPENGL, dimension2du(640, 480), 16,
			false, false, false, 0);

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();

    // load sydney
	IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
    // squash her!
	CSquashingMeshSceneNode* node = new CSquashingMeshSceneNode( mesh->getMesh(0), 0, smgr, 0 );


	if (node)
	{
		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setPosition( vector3df(0,0,50));
		node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
	}

	smgr->addCameraSceneNodeFPS();

    int lastFPS = -1;

	while(device->run())
	{
		driver->beginScene(true, true, SColor(255,100,101,140));

        node->render();
        node->OnPostRender(device->getTimer()->getTime());

		smgr->drawAll();
		guienv->drawAll();

		driver->endScene();

		int fps = driver->getFPS();
		if (lastFPS != fps)
		{
			core::stringw str = L"Irrlicht Mesh Deformation Contest [";
			str += driver->getName();
			str += "] FPS:";
			str += fps;

			device->setWindowCaption(str.c_str());
			lastFPS = fps;
		}


	}

	device->drop();

	return 0;
}
开发者ID:tecan,项目名称:IrrlichtDemos,代码行数:59,代码来源:main.cpp

示例4: render

		bool render() 
		{
			static s32 lastFPS = -1;

			if (irrDevice == NULL)
			{
				return false;
			}

			if (!irrDevice->run())
			{
				irrDevice->drop();
				irrDevice = NULL;
				return false;
			}

            getGameSceneMgr()->update(getTime());
       
			driver->beginScene(true, true, video::SColor(255,113,113,133));

			smgr->drawAll();
			guienv->drawAll();

			driver->endScene();

			const s32 fps = driver->getFPS();

			if (lastFPS != fps)
			{
                const char * camName = irrDevice->getSceneManager()->getActiveCamera()->getName();
				core::stringw str = L"stat: cam - ";
				str += camName;
				str += " FPS:";
				str += fps;

				irrDevice->setWindowCaption(str.c_str());
				lastFPS = fps;
			}

			return true;
		}
开发者ID:xiaofeme,项目名称:tt,代码行数:41,代码来源:cirr3dengine.hpp

示例5: run


//.........这里部分代码省略.........
			if (camera[1]){
				smgr->setActiveCamera(camera[1]);
				rect<s32> offset = rect<s32>(ResX/2,0,ResX,ResY/2);
				driver->setViewPort(offset);
				smgr->drawAll();

				if (GetState()->Mode())
					GetState()->Mode()->viewportTick(EVIEW_XZ, driver, offset);
			}

			// Draw Camera 2
			if (camera[2]){
				smgr->setActiveCamera(camera[2]);
				rect<s32> offset = rect<s32>(0,ResY/2,ResX/2,ResY);
				driver->setViewPort(offset);
				smgr->drawAll();

				if (GetState()->Mode())
					GetState()->Mode()->viewportTick(EVIEW_XY, driver, offset);

			}

			// Draw Camera 3
			if (camera[3]){
				smgr->setActiveCamera(camera[3]);
				rect<s32> offset = rect<s32>(ResX/2,ResY/2,ResX,ResY);
				driver->setViewPort(offset);
				smgr->drawAll();

				if (GetState()->Mode())
					GetState()->Mode()->viewportTick(EVIEW_ZY, driver, offset);
			}

			// Draw GUI
			driver->setViewPort(rect<s32>(0,0,driver->getScreenSize().Width,driver->getScreenSize().Height));
			driver->draw2DLine(vector2d<irr::s32>(0,ResY/2),vector2d<irr::s32>(ResX,ResY/2),SColor(175,255,255,255));
			driver->draw2DLine(vector2d<irr::s32>(0,ResY/2-1),vector2d<irr::s32>(ResX,ResY/2-1),SColor(175,255,255,255));
			driver->draw2DLine(vector2d<irr::s32>(ResX/2,0),vector2d<irr::s32>(ResX/2,ResY),SColor(175,255,255,255));
			driver->draw2DLine(vector2d<irr::s32>(ResX/2+1,0),vector2d<irr::s32>(ResX/2+1,ResY),SColor(175,255,255,255));
		}else if (camera[currentWindow]){
			smgr->setActiveCamera(camera[currentWindow]);
			driver->setViewPort(rect<s32>(0,0,ResX,ResY));
			smgr->drawAll();

			if (GetState()->Mode())
					GetState()->Mode()->viewportTick((VIEWPORT)currentWindow, driver, rect<s32>(0,0,ResX,ResY));

			driver->setViewPort(rect<s32>(0,0,driver->getScreenSize().Width,driver->getScreenSize().Height));
		}

		if (GetState()->Menu())
			GetState()->Menu()->draw(driver);
		if (GetState()->Mode())
			GetState()->Mode()->draw(driver);

		guienv->drawAll();
		driver->endScene();

		int fps = driver->getFPS();
        if (lastFPS != fps)
        {
            irr::core::stringw str = L"Nodebox Editor [FPS: ";
            str += fps;
			str += "]";

            GetDevice()->setWindowCaption(str.c_str());
            lastFPS = fps;
        }

		if (LastX != ResX || LastY != ResY){
			printf("Adjusting FOV to new screen size...\n");
			LastX = ResX;
			LastY = ResY;
			camera[0]->setAspectRatio((float)ResX/(float)ResY);

			// reset matrix
			matrix4 projMat;
			irr::f32 orth_w = (float)ResX / (float)ResY;
			orth_w = 3 * orth_w;
			projMat.buildProjectionMatrixOrthoLH(orth_w,3,1,100);

			for (int i=1;i<4;i++){
				if (camera[i]){
					camera[i]->remove();
					camera[i]=NULL;
				}
			}

			// Remake cameras
			camera[1]=smgr->addCameraSceneNode(target,vector3df(0,2,-0.01),vector3df(0,0,0));
			camera[1]->setProjectionMatrix(projMat,true);
			camera[2]=smgr->addCameraSceneNode(target,vector3df(0,0,-5),vector3df(0,0,0));
			camera[2]->setProjectionMatrix(projMat,true);
			camera[3]=smgr->addCameraSceneNode(target,vector3df(-5,0,0),vector3df(0,0,0));
			camera[3]->setProjectionMatrix(projMat,true);
		}
	}

	return true;
}
开发者ID:jmf,项目名称:The-NodeBox-Generator,代码行数:101,代码来源:Editor.cpp

示例6: main

int main()
{
	IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(1200, 800), 32, false, true, false, 0);
	PhysicsContext odeContext;
	std::vector<PlaceableObject> objects;

	odeContext.sceneWidth = 512;
	odeContext.sceneHeight = 512;

	lineWidth = odeContext.sceneWidth;

	SetupOde(odeContext);

	if (!device)
		return 1;

	device->setWindowCaption(L"REPO prototype");

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();
		
	SetupCamera(smgr, device);
	
	SetupGui(guienv);

	AddActors(smgr, driver, odeContext, objects );
	SetupLightsAndShadows(smgr, driver);

	//----------------
	auto scale = 80;
	AddTerrain(odeContext, driver, smgr, scale);
	//----------------

	auto infotext = guienv->addStaticText(L"Irrlicht",	rect<s32>(10, 10, 200, 40), true);	

	auto frameCounter = 0;

	while(device->run())
	{
		driver->beginScene(true, true, SColor(255, 0, 0, 0));

		smgr->drawAll();
		guienv->drawAll();
		driver->endScene();

		core::stringw strFps = L"FPS: ";
		strFps += (s32)driver->getFPS();       
		infotext->setText(strFps.c_str());

		if (frameCounter % 1 == 0)
		{
			SimulationStep(odeContext);
			UpdateActors(objects);
		}

		frameCounter++;
	}

	device->drop();

	return 0;
}
开发者ID:MyOwnClone,项目名称:irrlicht-ode,代码行数:63,代码来源:main.cpp

示例7: main

int main()
{



	IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(1024, 768), 32, false, false, true, 0);
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();

	smgr->addCameraSceneNodeFPS();

    const s32 randLength = 1024;
    srand(device->getTimer()->getRealTime());


    //Creating the grid for unit measure, etc
    u32 tileNumber = 128;
	IAnimatedMesh* groundMesh = smgr->addHillPlaneMesh("", dimension2d<float>(8,8),dimension2d<u32>(tileNumber,tileNumber),0,0.0f,dimension2df(0,0),dimension2df(tileNumber,tileNumber));
    IAnimatedMeshSceneNode * groundNode = smgr->addAnimatedMeshSceneNode(groundMesh);
    groundNode->setMaterialTexture(0,driver->getTexture("../media/grid2.png"));
    groundNode->setMaterialFlag(EMF_LIGHTING,false);
    groundNode->setPosition(vector3df(0,-2,0));


    //obstacles for stuff
    EntityGroup obstacles;

    for(int i = 0; i < 20; i++)
    {
        ISceneNode* s = smgr->addSphereSceneNode(20);
        IrrlichtBaseEntity * e = new IrrlichtBaseEntity(s);
        s->setPosition(vector3df(rand()%randLength - (randLength/2),0,rand()%randLength - (randLength/2)));
        obstacles.push_back(e);
    }

    //Nodes for vehicles
    ISceneNode * cube = smgr->addCubeSceneNode(4);
    ISceneNode * cube2 = smgr->addCubeSceneNode(4);
    cube->setMaterialFlag(EMF_LIGHTING,false);
    cube->setMaterialTexture(0,driver->getTexture("../media/v1-solid.png"));
    cube2->setMaterialFlag(EMF_LIGHTING,false);
    cube2->setMaterialTexture(0,driver->getTexture("../media/v2-solid.png"));

    //Creating the actual vehicles
    IrrlichtMobileEntity * Entity1 = new IrrlichtMobileEntity(cube ,vector3df(0,0,0), 1, 90, 40);
    IrrlichtMobileEntity * Entity2 = new IrrlichtMobileEntity(cube2,vector3df(0,0,300), 1, 100, 50);

    //Creating the steering conrollers, constructor also sets steering on entity
    SimpleSteeringController* Entity1Steering = new SimpleSteeringController(Entity1);
    SimpleSteeringController * Entity2Steering = new SimpleSteeringController(Entity2);

    //Setting up other params for behaviors
    Entity1Steering->SetObstacles(obstacles);
    Entity1Steering->SetHideTarget(Entity2);
    Entity1Steering->SetBehaviorFlag(EBF_HIDE,true);
    Entity1Steering->SetBehaviorFlag(EBF_AVOID,true);

    Entity2Steering->SetObstacles(obstacles);
    Entity2Steering->SetPursuitTarget(Entity1);
    Entity2Steering->SetBehaviorFlag(EBF_PURSUIT,true);
    Entity2Steering->SetBehaviorFlag(EBF_AVOID,true);

    //vars for tracking time between frames. This allows framerate independent motion state updates.
    u32 then = device->getTimer()->getTime();
    float timeUpdate = 0;

    while(device->run())
	{
	    const u32 now = device->getTimer()->getTime();
        const float frameDeltaTime = (float)(now - then) / 1000.f; // Time in seconds
        then = now;
        timeUpdate += frameDeltaTime;

        if(timeUpdate > 1)
        {
            core::stringw str = L"desteer v0.0.1  FPS: ";
            str += (s32)driver->getFPS();
			device->setWindowCaption(str.c_str());
			timeUpdate = 0;
		}

        //Do behavior updates before the rendering.
        Entity1->Update(frameDeltaTime);
        Entity2->Update(frameDeltaTime);

        driver->beginScene(true, true, SColor(255,100,101,140));
            smgr->drawAll();
		driver->endScene();
	}
    //Clean up irrlicht.
	device->drop();

	return 0;
}
开发者ID:dennisferron,项目名称:desteer,代码行数:94,代码来源:main.cpp

示例8: main

int main()
{
    // ask user for driver
    video::E_DRIVER_TYPE driverType=driverChoiceConsole();
    if (driverType==video::EDT_COUNT)
        return 1;

    // create device and exit if creation failed

    Device = createDevice(driverType, core::dimension2d<u32>(640, 480));
    if(Device == NULL)
        return 1;

    IVideoDriver *Driver = Device->getVideoDriver();
    IGUIEnvironment* env = Device->getGUIEnvironment();
    ISceneManager *Scene = Device->getSceneManager();

    Scene->addCameraSceneNode(0, vector3df(0,10,-40), vector3df(0,0,0));

    MyEventReceiver receiver;
    Device->setEventReceiver(&receiver);

    // Load fonts
    fonts[0] = env->getFont(FONTPATH1, SIZE_FONT_NORMAL);
    fonts[1] = env->getFont(FONTPATH1, SIZE_FONT_BIG);
    fonts[2] = env->getFont(FONTPATH2, SIZE_FONT_NORMAL);
    fonts[3] = env->getFont(FONTPATH2, SIZE_FONT_BIG);
    fonts[4] = env->getFont(FONTPATH3, SIZE_FONT_NORMAL);
    fonts[5] = env->getFont(FONTPATH3, SIZE_FONT_BIG);

    for( int i = 0; i < 6; ++i ) {
        fonts[i]->setBatchLoadSize(1);
        fonts[i]->setMaxPageTextureSize( dimension2du(512, 512) );
    }

    font = fonts[0];
    font2 = fonts[1];

    skin = env->getSkin();
    skin->setFont(font);

    txtTrans = env->addStaticText(L"Transparency:", rect<s32>(50,20,250,40), true);
    IGUIScrollBar* scrollbar = env->addScrollBar(true, rect<s32>(50, 45, 250, 60), 0, 104);
    scrollbar->setMax(255);
    SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)0);
    scrollbar->setPos(col.getAlpha());

    txtLog = env->addStaticText(L"Logging ListBox:", rect<s32>(50,80,250,100), true);
    listbox = env->addListBox(rect<s32>(50, 110, 250, 180));

    btnQuit = env->addButton(rect<s32>(10,210,100,240), 0, 101, L"Quit");
    btnNew = env->addButton(rect<s32>(10,250,100,290), 0, 102, L"New Window");
    btnFile = env->addButton(rect<s32>(10,300,100,340), 0, 103, L"Open File");

    edtName = env->addEditBox(L"",rect<s32>(300,60,580,80));
    edtName->setMax(40);
    edtMemo = env->addEditBox(L"",rect<s32>(300,100,580,450));
    edtMemo->setMultiLine(true);
    edtMemo->setTextAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);

    lstLang = env->addListBox(rect<s32>(10, 400, 250, 470),0,120);
    lstLang->addItem(L"Arial");
    lstLang->addItem(L"Times Roman");
    lstLang->addItem(L"MS-Gothic(Japanese)");
    lstLang->setSelected(0);

    int lastFPS = -1;

    while(Device->run())
    {
        Driver->beginScene(true, true, SColor(0,64,64,128));

        Scene->drawAll();
        env->drawAll();

        if (!lang){
            font2->draw(L"Hello TrueType",rect<s32>(250,20,640,100),SColor(255,255,64,64),true);
        } else {
            //font2->draw(jtxtHello,rect<s32>(250,20,640,100),SColor(255,255,64,64),true);
            font2->draw(zhtwHello,rect<s32>(100,100,640,100),SColor(255,255,64,64),false);
        }

        Driver->endScene();

        int fps = Driver->getFPS();
        if (lastFPS != fps)
        {
            wchar_t tmp[1024];
            swprintf(tmp, L"Irrlicht TrueType Demo (fps:%d)", fps);
            Device->setWindowCaption(tmp);
            lastFPS = fps;
        }

    }

    Device->drop();
    return 0;
}
开发者ID:jsj2008,项目名称:cubeat,代码行数:98,代码来源:test_font_input_method_main.cpp

示例9: run


//.........这里部分代码省略.........
			return true;
		}

		driver->beginScene(true, true, irr::video::SColor(255, 150, 150, 150));

		int ResX = driver->getScreenSize().Width;
		if (!state->settings->getBool("hide_sidebar"))
			ResX -= 256;

		int ResY = driver->getScreenSize().Height;

		if (currentWindow == -1) {
			bool newmoused = (state->mousedown && !click_handled);
			viewportTick(VIEW_TL, rect<s32>(0,      0,      ResX/2, ResY/2),
					newmoused, !middle_click_handled);
			viewportTick(VIEW_TR, rect<s32>(ResX/2, 0,      ResX,   ResY/2),
					newmoused, !middle_click_handled);
			viewportTick(VIEW_BL, rect<s32>(0,      ResY/2, ResX/2, ResY  ),
					newmoused, !middle_click_handled);
			viewportTick(VIEW_BR, rect<s32>(ResX/2, ResY/2, ResX,   ResY  ),
					newmoused, !middle_click_handled);

			// Draw separating lines
			driver->setViewPort(rect<s32>(0, 0, driver->getScreenSize().Width,
					driver->getScreenSize().Height));
			driver->draw2DLine(vector2d<irr::s32>(0, ResY/2),
					vector2d<irr::s32>(ResX, ResY/2), SColor(175,255,255,255));
			driver->draw2DLine(vector2d<irr::s32>(0, ResY/2-1),
					vector2d<irr::s32>(ResX, ResY/2-1), SColor(175,255,255,255));
			driver->draw2DLine(vector2d<irr::s32>(ResX/2, 0),
					vector2d<irr::s32>(ResX/2, ResY), SColor(175,255,255,255));
			driver->draw2DLine(vector2d<irr::s32>(ResX/2+1, 0),
					vector2d<irr::s32>(ResX/2+1, ResY), SColor(175,255,255,255));
		} else if (camera[currentWindow]) {
			viewportTick((Viewport)currentWindow, rect<s32>(0, 0, ResX, ResY),
					(state->mousedown && !click_handled), !middle_click_handled);
		}

		if (state->menu) {
			state->menu->draw(driver);
		}
		if (state->Mode()) {
			state->Mode()->draw(driver);
		}

		if (state->project && state->project->GetCurrentNode()) {
			vector3df pos = vector3df(
				(f32)state->project->GetCurrentNode()->position.X,
				(f32)state->project->GetCurrentNode()->position.Y,
				(f32)state->project->GetCurrentNode()->position.Z
			);
			target->setPosition(pos);
		}

		guienv->drawAll();

		if (state->menu->dialog)
			state->menu->dialog->draw(driver);

		driver->endScene();

		#ifdef _DEBUG
		int fps = driver->getFPS();
		if (lastFPS != fps) {
			irr::core::stringw str = L"Node Box Editor [FPS: ";
			str += fps;
			str += "]";

			device->setWindowCaption(str.c_str());
			lastFPS = fps;
		}
		#endif

		if (LastX != ResX || LastY != ResY) {
			LastX = ResX;
			LastY = ResY;
			recreateCameras();
		}

		// Update
		if (state->Mode()) {
			state->Mode()->update(dtime);
		}

		// Do sleep
		unsigned int now = std::clock();
		if (dosleep) {
			u32 sleeptime = int(double(1000) / double(60)) - (now - last);
			if (sleeptime > 0 && sleeptime < 200)
				device->sleep(sleeptime);
		}
		dtime = double(now - last) / 1000;
		last = now;

		click_handled = true;
		middle_click_handled = true;
	}

	return true;
}
开发者ID:asl97,项目名称:NodeBoxEditor,代码行数:101,代码来源:Editor.cpp

示例10: run

int App::run(std::tr1::function<void()> tester)
{
    using namespace irr;
    using namespace core;
    using namespace scene;
    using namespace video;

    using namespace ctrl;

    IVideoDriver* driver = IrrDevice::i().d()->getVideoDriver();
    int lastFPS = -1;
    time_t t0 = realtime(), t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;

    while( IrrDevice::i().run() && !quit_ ) {
        //if( IrrDevice::i().d()->isWindowActive() )                   //comment: temp for double tasking
        //{                                                            //comment: temp for double tasking
        //    if( global_timer_.lock()->isStopped() )        //comment: temp for double tasking
        //        global_timer_.lock()->start();             //comment: temp for double tasking
            //if( update_block() ) continue;

            MastEventReceiver::i().endEventProcess();

            t1 = realtime();
            InputMgr::i().updateAll();
            t2 = realtime();
            EventDispatcher::i().dispatch();
            t3 = realtime();
            driver->beginScene(true, true, video::SColor(0,0,0,0));
            t4 = realtime();
            if( tester ) tester();
            else master_presenter_->cycle();
            t5 = realtime();
            trans_->cycle();
            t6 = realtime();
            InputMgr::i().redrawAll();
            t7 = realtime();
            audio::Sound::i().cycle();
            t8 = realtime();
            view::SFX::i().cleanup(); //newly added, clean up effects pool every cycle.
            t9 = realtime();
            driver->endScene();
            t10 = realtime();

            MastEventReceiver::i().startEventProcess();

            //FPS for debug
            int fps = driver->getFPS();
            if( fps != lastFPS ) {
                core::stringw str(L"FPS: ");
                str += fps;
                IrrDevice::i().d()->setWindowCaption( str.c_str() );
                lastFPS = fps;
            }
            if( temp_presenter_ ) { //hand over master presenter here "safely."
                master_presenter_ = temp_presenter_;
                temp_presenter_.reset();
            }

            time_t elapsed_time = realtime() - t0;

            if( elapsed_time > 17 && elapsed_time < 500 ) {
                std::cout << "frame time spike: " << elapsed_time << "\n";
                printf(" -- App: event(%ld) maspre(%ld) %ld %ld %ld %ld %ld %ld %ld %ld\n", t3-t2, t5-t4, t1-t0, t2-t1, t4-t3, t6-t5, t7-t6, t8-t7, t9-t8, t10-t9);
            }
            if( elapsed_time < 16 ) { // temp: locked at 60 fps if possible
                #if defined(WIN32) || defined(_WIN32)
                //Sleep(15 - elapsed_time);
                Sleep(1);
                #else
                //usleep((15 - elapsed_time) * 1000);
                usleep(1);
                #endif
                while( realtime() - t0 <= 16 );
            }
            t0 = realtime();
            //printf("t0: %ld\n", t0);
        //}                                                      //comment: temp for double tasking
        //else                                                   //comment: temp for double tasking
            //if( !timer_->isStopped() ) //comment: temp for double tasking
                //timer_->stop();        //comment: temp for double tasking
    }

    std::cout << "App main loop has ended." << std::endl;
    if( master_presenter_ ) //hack: make the recollection of master_presenter_ faster.
        master_presenter_.reset();
    return 0;
}
开发者ID:Bloodknight,项目名称:cubeat,代码行数:87,代码来源:App.cpp

示例11: main

int main()
{


/*		shadowDimen = dimension2du(1024,1024);
		shadowDimen = dimension2du(2048,2048);
		shadowDimen = dimension2du(4096,4096);
		shadowDimen = dimension2du(2048,2048);
		filterType = EFT_NONE;
		filterType = EFT_4PCF;
		filterType = EFT_8PCF;
		filterType = EFT_4PCF;
*/
	dimension2du shadowDimen = dimension2du(1024,1024);
    E_FILTER_TYPE filterType = EFT_4PCF;
    filterType = EFT_NONE;
////


IrrlichtDevice* device = createDevice(EDT_OPENGL,dimension2du(800,600),32);

ISceneManager* smgr = device->getSceneManager();
IVideoDriver* driver = device->getVideoDriver();

ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS(0,100,.5);
cam->setPosition(vector3df(0,10,0));

// Create the effect handler, passing the device and RTT size (as a dimension2d) .
effectHandler* effect = new effectHandler(device,shadowDimen);


ITerrainSceneNode* terrain = smgr->addTerrainSceneNode("media/terrain.bmp",0,-1,vector3df(0,0,0),vector3df(0,0,0),vector3df(1,1,1),SColor(255,255,255,255),1,ETPS_33);
terrain->setMaterialTexture(0,driver->getTexture("media/terrain.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("media/detailmap.jpg"));
terrain->scaleTexture(1,10);
terrain->setScale(core::vector3df(4, 0.01f, 4));
terrain->setPosition(vector3df(-120,-1.5f,-120));
terrain->setMaterialType(EMT_DETAIL_MAP);

// Make the terrain recieve a shadow with the specified filter type.
// (NOTE: 12PCF is only available in Direct3D9, all others work with OpenGL)
effect->addShadowToNode(terrain,filterType);

IAnimatedMeshSceneNode* sydney;
IAnimatedMesh* sydneymesh = smgr->getMesh("media/dwarf.x");

for(int g = 0;g < 1;g++)
{
	for(int v = 0;v < 3;v++)
	{
		sydney = smgr->addAnimatedMeshSceneNode(sydneymesh);
		sydney->setScale(vector3df(0.05f,0.05f,0.05f));
		sydney->setPosition(vector3df(g * 4,0.5f,v * 4));
		sydney->setMaterialFlag(EMF_NORMALIZE_NORMALS,true);

		sydney->setAutomaticCulling(EAC_FRUSTUM_BOX);

		sydney->setMaterialType(EMT_SOLID);

		// Add the nodes to the depth pass so that they cast a shadow.
		effect->addNodeToDepthPass(sydney);

	}
}


effect->getLightCamera()->addAnimator(smgr->createFlyCircleAnimator(sydney->getPosition() + vector3df(0,15,0),25,0.0002f));

effect->getLightCamera()->setNearValue(5);

effect->setMaxShadowDistanceFromLight(120);

smgr->addLightSceneNode(effect->getLightCamera());


MyEventReceiver receiver(cam);
device->setEventReceiver(&receiver);

// Parent a sphere to the light camera so we can see its position.
smgr->addSphereSceneNode(1,8,effect->getLightCamera())->setMaterialFlag(EMF_LIGHTING,false);



while(device->run())
{
	wchar_t tmp[255];
	swprintf(tmp,255,L"Shadow Map Demo (FPS: %d)",driver->getFPS());
	device->setWindowCaption(tmp);

	driver->beginScene(true,true,SColor(0,0,0,0));

	// Point the light camera at one of the nodes as it rotates around them.
	effect->setLightTarget(sydney->getPosition());

	// Update the effect  handler, remember to always do this BEFORE smgr->drawAll and AFTER beginscene!
	effect->update();

	smgr->drawAll();

	// If user wishes we can display the shadow map to the screen. (May not work in OpenGL)
//.........这里部分代码省略.........
开发者ID:tecan,项目名称:Luna,代码行数:101,代码来源:example.cpp

示例12: main


//.........这里部分代码省略.........

//-- robots ------------------------------------------------------------//

    //create robots
    Fly2D::Brain* brains[nRobots];


    //all to a default type
    //for ( int i=0; i<nRobots; i++ )
    //{
        //brains[i] = new Fly2D::BrainForward;
        ////brains[i] = new Fly2D::BrainCircle();
    //}

    brains[0] = new Fly2D::BrainForward;
    brains[1] = new Fly2D::BrainForward;

    //decide human control
        vector<Fly2D::BrainHuman*> hBrains;
        for (
            vector<int>::iterator i = humanBrainIds.begin();
            i != humanBrainIds.end();
            ++i
        )
        {
            if ( *i > nRobots )
            {
                cerr << "no such robot: " << *i << endl;
                exit(EXIT_FAILURE);
            }
            delete brains[*i];
            Fly2D::BrainHuman* hBrain = new Fly2D::BrainHuman;
            brains[*i] = hBrain;
            hBrains.push_back(hBrain);
        }
        Fly2D::ReceiverHuman hReceiver = Fly2D::ReceiverHuman( hBrains );
        device->setEventReceiver( &hReceiver );

    Robot* robots[nRobots];
    robots[0] = new Fly2D::Robot( *device, *meta, *brains[0], vector3df(0,0,-0.5f), vector3df(0,0, 0.5f),  0.01 );
    robots[1] = new Fly2D::Robot( *device, *meta, *brains[1], vector3df(0,0,0.5f),  vector3df(0,0, -0.5f), 0.01 );

    meta->drop(); // As soon as we're done with the selector, drop it.

//-- run ------------------------------------------------------------//
    //TEST
    vector3df oldpos, oldtarget;
    //END TEST
    
    int nFrames = 0;
    ITimer* timer = device->getTimer();
    int t0 = timer->getTime();
    int w = driver->getScreenSize().Width;
    int h = driver->getScreenSize().Height;
    int dh = h/nRobots;
    int observeRobot = 0;

	while(device->run())
	{
        //if (device->isWindowActive()) //only work if window has focus.

        //draw

        driver->setViewPort(rect<s32>(0,0,w,h));
        driver->beginScene(true,true,0);
        for(int i=0; i<nRobots; i++)
        {
            driver->setViewPort(rect<s32>(0,dh*i,w,dh*(i+1)));
            //only part of window gets drawn into

            smgr->setActiveCamera(robots[i]->camera);

            smgr->drawAll(); 
            //draws on window scene of active camera
 
            robots[i]->update();
        }
        driver->endScene();

        //TEST
        //if
        //(
            //robots[observeRobot].getPosition() != oldpos
            //|| robots[observeRobot].getTarget() != oldtarget
        //)
        //oldpos = robots[observeRobot].getPosition();
        //oldtarget = robots[observeRobot].getTarget();

        cout << robots[observeRobot]->str();

        //FPS info
            //cout << "frame no:" << endl << nFrames << endl;;
            //cout << "average fps:" << endl << 1000*nFrames/(float)(timer->getTime()-t0) << endl;
            //nFrames++;
            cout << "fps:" << endl << driver->getFPS() << endl;
        //END TEST
	}
	device->drop();
	return 0;
}
开发者ID:cirosantilli,项目名称:computer_vision2d,代码行数:101,代码来源:main.cpp

示例13: main

int main(int argc, char **argv) {
    BSPdungeon dun(50,50,5);
    
   IrrlichtDevice *device =createDevice( video::EDT_OPENGL, dimension2d<u32>(1280,720), 16,false, false, false, 0);

	if (!device)
		return 1;

	device->setWindowCaption(L"Pangolin Kwest");

	
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();
	
	smgr->setAmbientLight(video::SColorf(0.1,0.1,0.1,1));
	
	ILightSceneNode* mylight1 = smgr->addLightSceneNode( 0, core::vector3df(00,00,00), video::SColorf(0.3f,0.3f,0.3f), 30.0f, 1 ); 
	
	//IGUIFont* myfont=guienv->getFont("./myfont.xml");
	//if(myfont==0)exit(93);
	
	//guienv->addMessageBox(L"Alertz!",L"You pangolin are been createrized. You totalleh ready to bash monstaz etc.!");
	
	mylight1->enableCastShadow(true);
	
	//guienv->addStaticText(L"Pangolin Kwest 3D",rect<s32>(10,10,260,22), true);
	//-------------------------------------------	
	
	int x,y,z;
	for(x=0;x<50;x++){
		for(y=0;y<50;y++){
		  if(dun.map[x][y]==NIL){
		    for(z=0;z<3;z++){
		      ISceneNode* cueb=smgr->addCubeSceneNode(10);
		      cueb->setMaterialFlag(EMF_LIGHTING, true);
		      cueb->setMaterialTexture( 0, driver->getTexture("media/stdwall.jpg") );
		     // cueb->getMaterial(0).getTextureMatrix(0).setTextureTranslate(0.25,0.5);
		     // cueb->getMaterial(0).getTextureMatrix(0).setTextureScale(0.0625,0.0625);
		      cueb->setPosition(vector3df(x*10,z*10,y*10));
		    }
		  }
// 		   ISceneNode* cueb=smgr->addCubeSceneNode(10);
// 		   cueb->setMaterialFlag(EMF_LIGHTING, true);
// 		   cueb->setMaterialTexture( 0, driver->getTexture("media/stdfloor.jpg") );
// 		   cueb->setPosition(vector3df(x*10,-10,y*10));
		   
		   ISceneNode* cueb=smgr->addCubeSceneNode(10);
		   cueb->setMaterialFlag(EMF_LIGHTING, true);
		   cueb->setMaterialTexture( 0, driver->getTexture("media/stdup.jpg") );
		   cueb->setPosition(vector3df(x*10,30,y*10));
		   
		}
	}	

	
	
	ISceneNode* cueb=smgr->addCubeSceneNode(500);
	cueb->setMaterialFlag(EMF_LIGHTING, true);
	cueb->setMaterialTexture( 0, driver->getTexture("media/stdfloor.jpg") );
	cueb->setPosition(vector3df(250,-255,250));
	//cueb->getMaterial(0).getTextureMatrix(0).setTextureTranslate(0.25,0.5);
	cueb->getMaterial(0).getTextureMatrix(0).setTextureScale(50,50);
	//cueb->setScale(vector3df(0,-5,0));
	 //cueb->addshadowVolumeSceneNode();



	//-------------------------------------------	

	int lastFPS;

	//smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
	ICameraSceneNode* mycam;
	mycam=smgr->addCameraSceneNodeFPS(0,100.0f,0.025f);
	mycam->setFOV(45);
	mylight1->setParent(mycam);
	while(device->run())
	{
		//mylight1->setPosition();
		//mylight1->
		driver->beginScene(true, true, SColor(255,100,101,140));
  
		smgr->drawAll();
		guienv->drawAll();

		driver->endScene();
		
		int fps = driver->getFPS();

                if (lastFPS != fps)
                {
                        core::stringw str = L"Pangolin Kwest 3D [";
                        str += driver->getName();
                        str += "] FPS:";
                        str += fps;

                        device->setWindowCaption(str.c_str());
                        lastFPS = fps;
                }
//.........这里部分代码省略.........
开发者ID:antkazam,项目名称:PangolinKwest,代码行数:101,代码来源:main.cpp

示例14: main


//.........这里部分代码省略.........
		drv->beginScene();

		switch (state) {
			case MLAA_OFF:
				if (showpic) def->Render(false);
				else smgr->drawAll();
			break;
			case MLAA_ON:
				if (showpic) def->Render(rt1);
				else {
					drv->setRenderTarget(rt1);
					smgr->drawAll();
				}


				glClear(GL_STENCIL_BUFFER_BIT);
				glStencilFunc(GL_ALWAYS, 1, ~0);
				glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
				sq->Render(rt2);

				glStencilFunc(GL_EQUAL, 1, ~0);
				glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
				sq2->Render(rt3);
				drv->setRenderTarget(rt1, false, false);

				// Overlay the smoothed edges on the initial image
				sq3->Render(false);

				// Blit the final image to the framebuffer
				glStencilFunc(GL_ALWAYS, 1, ~0);
				norm->Render();

			break;
		}

		drv->endScene();

		if (state == MLAA_ON) {
			gettimeofday(&tick2, NULL);
			if (!firstrun) {
				tmplong = (tick2.tv_sec - tick1.tv_sec) * 10000;
				tmplong += (tick2.tv_usec - tick1.tv_usec) / 100;
				fxtimer += tmplong;

				onframes++;
			} else {
				firstrun = 0;

				glsltime = tick2.tv_sec - tick1.tv_sec;
				glsltime += (tick2.tv_usec - tick1.tv_usec) / 1000000.0;
			}
		}

		int fps = drv->getFPS();
		if (minfps > fps) minfps = fps;
		if (lastfps != fps) {
			swprintf(cap, 20, L"%d fps, MLAA %s", fps, state == MLAA_ON ? "on" : "off");
			dev->setWindowCaption(cap);
			lastfps = fps;
		}

		if (r->IsKeyDown(KEY_KEY_M)) {
			if (state == MLAA_ON) state = MLAA_OFF;
			else state = MLAA_ON;

			lastfps++;
		}

		usleep(1); // 16?
		total_frames++;
	}

	dev->drop();
	delete ncb;
	delete bcb;
	delete def;
	delete sq;
	delete sq2;
	delete sq3;
	delete norm;
	delete r;

	struct timeval endtime;
	gettimeofday(&endtime, NULL);
	float sec = endtime.tv_sec - starttime.tv_sec;
	sec += ((float) endtime.tv_usec - starttime.tv_usec) / 1000000;
	printf("\nRan %.3fs, ", sec);
	sec -= glsltime;

	printf("average fps %.2f, min %d\n", (float) total_frames/sec, minfps);

	if (onframes) {
		printf("\nAverage on fps %.2f, average off fps %.2f\n\n", (float) onframes/(fxtimer/10000.0),
					(float) (total_frames - onframes)/(sec - (fxtimer/10000.0)));

//		printf("MLAA took on average %.1fms\n", (float) (fxtimer / onframes) / 10.0);
	}

	return 0;
}
开发者ID:clbr,项目名称:MLAA-test-app,代码行数:101,代码来源:mlaatest.cpp

示例15: main


//.........这里部分代码省略.........

/*
Create a variable for counting the fps and hide the mouse:
*/
	//Hide mouse
	device->getCursorControl()->setVisible(false);
	//We want to count the fps
	int lastFPS = -1;

/*
There wasn't much new stuff - till now!
Only by defining four cameras, the game won't be splitscreen.
To do this you need several steps:
  - Set the viewport to the whole screen
  - Begin a new scene (Clear screen)

  - The following 3 steps are repeated for every viewport in the splitscreen
    - Set the viewport to the area you wish
    - Activate the camera which should be "linked" with the viewport
    - Render all objects

  - If you have a GUI:
    - Set the viewport the whole screen
    - Display the GUI
  - End scene

Sounds a little complicated, but you'll see it isn't:
*/

	while(device->run())
	{
		//Set the viewpoint to the whole screen and begin scene
		driver->setViewPort(rect<s32>(0,0,ResX,ResY));
		driver->beginScene(true,true,SColor(255,100,100,100));
		//If SplitScreen is used
		if (SplitScreen)
		{
			//Activate camera1
			smgr->setActiveCamera(camera[0]);
			//Set viewpoint to the first quarter (left top)
			driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
			//Draw scene
			smgr->drawAll();
			//Activate camera2
			smgr->setActiveCamera(camera[1]);
			//Set viewpoint to the second quarter (right top)
			driver->setViewPort(rect<s32>(ResX/2,0,ResX,ResY/2));
			//Draw scene
			smgr->drawAll();
			//Activate camera3
			smgr->setActiveCamera(camera[2]);
			//Set viewpoint to the third quarter (left bottom)
			driver->setViewPort(rect<s32>(0,ResY/2,ResX/2,ResY));
			//Draw scene
			smgr->drawAll();
			//Set viewport the last quarter (right bottom)
			driver->setViewPort(rect<s32>(ResX/2,ResY/2,ResX,ResY));
		}
		//Activate camera4
		smgr->setActiveCamera(camera[3]);
		//Draw scene
		smgr->drawAll();
		driver->endScene();

		/*
		As you can probably see, the image is rendered for every
		viewport seperately. That means, that you'll loose much performance.
		Ok, if you're aksing "How do I have to set the viewport
		to get this or that screen?", don't panic. It's really
		easy: In the rect-function you define 4 coordinates:
		- X-coordinate of the corner left top
		- Y-coordinate of the corner left top
		- X-coordinate of the corner right bottom
		- Y-coordinate of the corner right bottom

		That means, if you want to split the screen into 2 viewports
		you would give the following coordinates:
		- 1st viewport: 0,0,ResX/2,ResY
		- 2nd viewport: ResX/2,0,ResX,ResY

		If you didn't fully understand, just play arround with the example
		to check out what happens.

		Now we just view the current fps and shut down the engine,
		when the user wants to:
		*/
		//Get and show fps
		if (driver->getFPS() != lastFPS)
		{
			lastFPS = driver->getFPS();
			core::stringw tmp = L"Irrlicht SplitScreen-Example (FPS: ";
			tmp += lastFPS;
			tmp += ")";
			device->setWindowCaption(tmp.c_str());
		}
	}
	//Delete device
	device->drop();
	return 0;
}
开发者ID:gametechnology,项目名称:psi-old,代码行数:101,代码来源:main.cpp


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