本文整理汇总了C++中ITimer::getRealTime方法的典型用法代码示例。如果您正苦于以下问题:C++ ITimer::getRealTime方法的具体用法?C++ ITimer::getRealTime怎么用?C++ ITimer::getRealTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITimer
的用法示例。
在下文中一共展示了ITimer::getRealTime方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
//-------------------------------------------------------------------------
// r u n
//-------------------------------------------------------------------------
void CApplication::run()
{
ITimer* timer = m_device->getTimer();
u32 current, last = timer->getRealTime();
u32 delta = 0;
m_running = true;
while(m_device->run() && m_running)
{
// calc seconds since last frame
current = timer->getRealTime();
delta = current-last;
last = current;
m_videoDriver->beginScene(true, true, SColor(255,100,101,140));
preRender(delta);
m_sceneManager->drawAll();
m_gui->drawAll();
postRender();
m_videoDriver->endScene();
}
logMessage("Exiting Run Loop");
stringc msg = "Frame Rate - Avg: ";
msg += m_fpsAvg;
msg += ", Min: ";
msg += m_fpsMin;
msg += ", Max: ";
msg += m_fpsMax;
logMessage(msg);
}
示例2: main
//.........这里部分代码省略.........
m_helpPanel = m_gui->addStaticText(L"",rect<s32>(2,0,202,200));
m_helpPanel->setBackgroundColor(SColor(128, 30, 30, 30));
m_helpPanel->setDrawBorder(true);
_addHelpText("F1 - Toggle Help");
_addHelpText("F3 - Cycle Wire, Points, Solid");
_addHelpText("F4 - Toggle Physics Debug");
_addHelpText("F5 - Warp To Start Position");
_addHelpText("F9 - Detach Camera");
// turn hardware cursor off
m_device->getCursorControl()->setVisible(false);
#if defined(USE_BULLET)
m_device->setWindowCaption(L"irrb Collision/Physics example - Using Bullet");
#elif defined(USE_IRRPHYSX)
m_device->setWindowCaption(L"irrb Collision/Physics example - Using IrrPhysx");
#else
m_device->setWindowCaption(L"irrb Collision/Physics example - Using Irrlicht");
#endif
m_camera = m_sceneManager->addCameraSceneNodeFPS(0, 100.0f, m_moveSpeed, -1, keyMap, 5, true, m_jumpSpeed);
m_camera->setPosition(vector3df(0,10,0));
m_camera->setFOV(core::PI / 2.5f);
m_camera->setNearValue(.1f);
m_camera->setFarValue(1000.f);
// save off animator
core::list<ISceneNodeAnimator*>::ConstIterator anims=m_camera->getAnimators().begin();
while(anims != m_camera->getAnimators().end())
{
if ((*anims)->getType() == ESNAT_CAMERA_FPS)
{
m_fpsAnimator = (ISceneNodeAnimatorCameraFPS*)*anims;
break;
}
++anims;
}
// init physics library
_initPhysicsLibrary();
m_displayPhysicsDebug = true;
_enablePhysicsDebug(true);
m_debugNode->setVisible(true);
// load scene
sceneFileName = argv[1];
sceneDirectory = m_fileSystem->getFileDir(sceneFileName);
saveDir = m_fileSystem->getWorkingDirectory();
m_fileSystem->changeWorkingDirectoryTo(sceneDirectory);
m_sceneManager->loadScene(sceneFileName.c_str(), &serializer);
m_fileSystem->changeWorkingDirectoryTo(saveDir);
// if the scene also contained a camera, set the active
// camera to our fps camera and update the fps pos/rot.
if(m_camera && (m_camera != m_sceneManager->getActiveCamera()))
{
ICameraSceneNode* anode = m_sceneManager->getActiveCamera();
m_camera->setPosition(anode->getPosition());
m_camera->setRotation(anode->getRotation());
m_sceneManager->setActiveCamera(m_camera);
m_startPos = m_camera->getPosition();
_warp(m_startPos);
}
ITimer* timer = m_device->getTimer();
u32 current, last = timer->getRealTime();
u32 delta = 0;
while(m_device->run() && m_running)
{
_clearDebugText();
m_videoDriver->beginScene(true, true, SColor(255,100,101,140));
// calc milliseconds since last frame
current = timer->getRealTime();
delta = current-last;
last = current;
// update collision/physics simulation
_stepSimulation(delta);
m_sceneManager->drawAll();
static char buf[64];
sprintf(buf, "FPS: %d", m_videoDriver->getFPS());
_updateDebugText(0, buf);
m_gui->drawAll();
m_videoDriver->endScene();
}
m_device->drop();
delete m_eventReceiver;
return 0;
}
示例3: update
/*
Update one frame
*/
bool CApp::update()
{
using namespace irr;
video::IVideoDriver* videoDriver = Device->getVideoDriver();
if ( !Device->run() )
return false;
// Figure out delta time since last frame
ITimer * timer = Device->getTimer();
u32 newTick = timer->getRealTime();
f32 deltaTime = RealTimeTick > 0 ? f32(newTick-RealTimeTick)/1000.0 : 0.f; // in seconds
RealTimeTick = newTick;
if ( Device->isWindowActive() || Config.RenderInBackground )
{
gui::IGUIEnvironment* guiEnv = Device->getGUIEnvironment();
scene::ISceneManager* smgr = Device->getSceneManager();
gui::IGUISkin * skin = guiEnv->getSkin();
// update our controls
MeshMaterialControl.update(SceneNode, SceneNode2T, SceneNodeTangents);
LightControl.update(NodeLight);
// Update vertices
if ( ControlVertexColors->isDirty() )
{
MeshManipulator->setVertexColors (SceneNode->getMesh(), ControlVertexColors->getColor());
MeshManipulator->setVertexColors (SceneNode2T->getMesh(), ControlVertexColors->getColor());
MeshManipulator->setVertexColors (SceneNodeTangents->getMesh(), ControlVertexColors->getColor());
ControlVertexColors->resetDirty();
}
// update ambient light settings
if ( GlobalAmbient->isDirty() )
{
smgr->setAmbientLight( GlobalAmbient->getColor() );
GlobalAmbient->resetDirty();
}
// Let the user move the light around
const float zoomSpeed = 10.f * deltaTime;
const float rotationSpeed = 100.f * deltaTime;
if ( KeysPressed[KEY_PLUS] || KeysPressed[KEY_ADD])
ZoomOut(NodeLight, zoomSpeed);
if ( KeysPressed[KEY_MINUS] || KeysPressed[KEY_SUBTRACT])
ZoomOut(NodeLight, -zoomSpeed);
if ( KeysPressed[KEY_RIGHT])
RotateHorizontal(NodeLight, rotationSpeed);
if ( KeysPressed[KEY_LEFT])
RotateHorizontal(NodeLight, -rotationSpeed);
UpdateRotationAxis(NodeLight, LightRotationAxis);
if ( KeysPressed[KEY_UP])
RotateAroundAxis(NodeLight, rotationSpeed, LightRotationAxis);
if ( KeysPressed[KEY_DOWN])
RotateAroundAxis(NodeLight, -rotationSpeed, LightRotationAxis);
// Let the user move the camera around
if (MousePressed)
{
gui::ICursorControl* cursorControl = Device->getCursorControl();
const core::position2d<s32>& mousePos = cursorControl->getPosition ();
RotateHorizontal(Camera, rotationSpeed * (MouseStart.X - mousePos.X));
RotateAroundAxis(Camera, rotationSpeed * (mousePos.Y - MouseStart.Y), CameraRotationAxis);
MouseStart = mousePos;
}
// draw everything
video::SColor bkColor( skin->getColor(gui::EGDC_APP_WORKSPACE) );
videoDriver->beginScene(true, true, bkColor);
smgr->drawAll();
guiEnv->drawAll();
if ( MeshMaterialControl.isLightingEnabled() )
{
// draw a line from the light to the target
video::SMaterial lineMaterial;
lineMaterial.Lighting = false;
videoDriver->setMaterial(lineMaterial);
videoDriver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
videoDriver->draw3DLine(NodeLight->getAbsolutePosition(), SceneNode->getAbsolutePosition());
}
videoDriver->endScene();
}
// be nice
Device->sleep( 5 );
return true;
}
示例4: fast_atof
//! Test both the accuracy and speed of Irrlicht's fast_atof() implementation.
bool fast_atof(void)
{
bool accurate = true;
accurate &= testCalculation("340282346638528859811704183484516925440.000000");
accurate &= testCalculation("3.402823466e+38F");
accurate &= testCalculation("3402823466e+29F");
accurate &= testCalculation("-340282346638528859811704183484516925440.000000");
accurate &= testCalculation("-3.402823466e+38F");
accurate &= testCalculation("-3402823466e+29F");
accurate &= testCalculation("34028234663852885981170418348451692544.000000");
accurate &= testCalculation("3.402823466e+37F");
accurate &= testCalculation("3402823466e+28F");
accurate &= testCalculation("-34028234663852885981170418348451692544.000000");
accurate &= testCalculation("-3.402823466e+37F");
accurate &= testCalculation("-3402823466e+28F");
accurate &= testCalculation(".00234567");
accurate &= testCalculation("-.00234567");
accurate &= testCalculation("0.00234567");
accurate &= testCalculation("-0.00234567");
accurate &= testCalculation("1.175494351e-38F");
accurate &= testCalculation("1175494351e-47F");
accurate &= testCalculation("1.175494351e-37F");
accurate &= testCalculation("1.175494351e-36F");
accurate &= testCalculation("-1.175494351e-36F");
accurate &= testCalculation("123456.789");
accurate &= testCalculation("-123456.789");
accurate &= testCalculation("0000123456.789");
accurate &= testCalculation("-0000123456.789");
accurate &= testCalculation("-0.0690462109446526");
if(!accurate)
{
logTestString("Calculation is not accurate, so the speed is irrelevant\n");
return false;
}
IrrlichtDevice* device = createDevice(video::EDT_NULL);
if (!device)
return false;
ITimer* timer = device->getTimer();
enum { ITERATIONS = 100000 };
int i;
f32 value;
u32 then = timer->getRealTime();
for(i = 0; i < ITERATIONS; ++i)
value = (f32)atof("-340282346638528859811704183484516925440.000000");
const u32 atofTime = timer->getRealTime() - then;
then += atofTime;
for(i = 0; i < ITERATIONS; ++i)
value = fast_atof("-340282346638528859811704183484516925440.000000");
const u32 fastAtofTime = timer->getRealTime() - then;
then += fastAtofTime;
for(i = 0; i < ITERATIONS; ++i)
value = old_fast_atof("-340282346638528859811704183484516925440.000000");
const u32 oldFastAtofTime = timer->getRealTime() - then;
logTestString(" atof time = %d\n fast_atof Time = %d\nold fast_atof time = %d\n",
atofTime, fastAtofTime, oldFastAtofTime);
device->drop();
if(fastAtofTime > (1.2f*atofTime))
{
logTestString("The fast method is slower than atof()\n");
return false;
}
return true;
}
示例5: test_strtol
//! Test both the accuracy and speed of Irrlicht's strtol10() implementation.
bool test_strtol(void)
{
bool accurate = true;
accurate &= testCalculation_strtol("340282346638528859811704183484516925440");
accurate &= testCalculation_strtol("3402823466");
accurate &= testCalculation_strtol("3402823466e+29F");
accurate &= testCalculation_strtol("-340282346638528859811704183484516925440");
accurate &= testCalculation_strtol("-3402823466");
accurate &= testCalculation_strtol("-3402823466e+29F");
accurate &= testCalculation_strtol("402823466385288598117");
accurate &= testCalculation_strtol("402823466");
accurate &= testCalculation_strtol("402823466e+28F");
accurate &= testCalculation_strtol("402823466385288598117");
accurate &= testCalculation_strtol("-402823466");
accurate &= testCalculation_strtol("-402823466e+28F");
accurate &= testCalculation_strtol(".00234567");
accurate &= testCalculation_strtol("-234567");
accurate &= testCalculation_strtol("234567");
accurate &= testCalculation_strtol("-234567");
accurate &= testCalculation_strtol("1175494351");
accurate &= testCalculation_strtol("11754943512");
accurate &= testCalculation_strtol("11754943513");
accurate &= testCalculation_strtol("11754943514");
accurate &= testCalculation_strtol("-1175494351");
accurate &= testCalculation_strtol("123456789");
accurate &= testCalculation_strtol("-123456789");
accurate &= testCalculation_strtol("123456.789");
accurate &= testCalculation_strtol("-123456.789");
accurate &= testCalculation_strtol("-109446526");
if(!accurate)
{
logTestString("Calculation is not accurate, so the speed is irrelevant\n");
return false;
}
IrrlichtDevice* device = createDevice(video::EDT_NULL);
if (!device)
return false;
ITimer* timer = device->getTimer();
const int ITERATIONS = 1000000;
int i;
s32 value;
u32 then = timer->getRealTime();
for(i = 0; i < ITERATIONS; ++i)
value = strtol("-3402823466", 0, 10);
const u32 strtolTime = timer->getRealTime() - then;
then += strtolTime;
for(i = 0; i < ITERATIONS; ++i)
value = strtol10("-3402823466");
const u32 strtol10Time = timer->getRealTime() - then;
then += strtol10Time;
for(i = 0; i < ITERATIONS; ++i)
value = old_strtol10("-3402823466");
const u32 oldstrtol10Time = timer->getRealTime() - then;
logTestString("Speed test\n strtol time = %d\n strtol10 time = %d\nold strtol10 time = %d\n",
strtolTime, strtol10Time, oldstrtol10Time);
device->closeDevice();
device->run();
device->drop();
if (strtol10Time > (1.2f*strtolTime))
{
logTestString("The fast method is slower than strtol()\n");
return false;
}
return true;
}
示例6: main
//.........这里部分代码省略.........
// if (node) node->setDebugDataVisible( scene::EDS_BBOX );
plot->addShape( "ADSR-Curve", node );
}
/// [main loop]
u32 timeLastWindowTitleUpate(0);
u32 timeWaitWindowTitleUpate(500);
while (device->run())
{
/// Resize-Event
if (screen != driver->getScreenSize() )
{
screen = driver->getScreenSize();
scene::ICameraSceneNode* camera = smgr->getActiveCamera();
if (camera)
{
f32 aspect = (f32)screen.Width / (f32)screen.Height;
camera->setAspectRatio( aspect );
}
}
/// if window is active ( can be minimized but still active )
if (device->isWindowActive())
{
/// if window is active ( can be minimized but still active )
if (device->isWindowFocused())
{
/// render all
driver->beginScene( true, true, video::SColor(255,225,225,225) );
smgr->drawAll();
env->drawAll();
driver->endScene();
/// window-title update
if ( timer->getRealTime() - timeLastWindowTitleUpate > timeWaitWindowTitleUpate )
{
core::stringw txt = core::stringw( MY_TITLE );
txt += L" | fps( ";
txt += driver->getFPS();
txt += L" ), poly( ";
txt += driver->getPrimitiveCountDrawn(); txt += L" / ";
txt += driver->getMaximalPrimitiveCount(); txt += L" ), ";
// scene::ICameraSceneNode* cam = smgr->getActiveCamera();
// if (cam)
// {
// const core::vector3df& pos = cam->getAbsolutePosition();
// txt += L"cam( pos(";
// txt += core::round32(pos.X); txt += L",";
// txt += core::round32(pos.Y); txt += L",";
// txt += core::round32(pos.Z); txt += L"), ";
//
// const core::vector3df& eye = cam->getTarget();
// txt += L"eye(";
// txt += core::round32(eye.X); txt += L",";
// txt += core::round32(eye.Y); txt += L",";
// txt += core::round32(eye.Z); txt += L"), ";
// txt += L"near(";
// txt += cam->getNearValue();
// txt += L"), far(";
// txt += core::round32(cam->getFarValue() ); txt += L")";
// txt += L" )";
// }
device->setWindowCaption( txt.c_str() );
timeLastWindowTitleUpate = timer->getRealTime();
}
}
else
{
device->yield();
}
}
else
{
device->yield();
}
}
if (device)
device->drop();
return 0;
}
示例7: main
//.........这里部分代码省略.........
/// main loop
while (device->run())
{
/// Resize-Event
if (screen != driver->getScreenSize() )
{
screen = driver->getScreenSize();
scene::ICameraSceneNode* camera = smgr->getActiveCamera();
if (camera)
{
f32 aspect = (f32)screen.Width / (f32)screen.Height;
camera->setAspectRatio( aspect );
}
}
/// run injected Application class
if (runable)
runable->run();
/// if window is active ( can be minimized but still active )
if (device->isWindowActive())
{
/// if window is active ( can be minimized but still active )
if (device->isWindowFocused())
{
/// render all
driver->beginScene( true, true, video::SColor(255,0,0,0) );
smgr->drawAll();
// render, if exist
if (customRenderer)
customRenderer->render();
env->drawAll();
driver->endScene();
/// window-title update
if ( timer->getRealTime() - timeLastWindowTitleUpate > timeWaitWindowTitleUpate )
{
core::stringw txt = MY_TITLE;
txt += L" | fps( ";
txt += driver->getFPS();
txt += L" ), poly( ";
txt += driver->getPrimitiveCountDrawn(); txt += L" / ";
txt += driver->getMaximalPrimitiveCount(); txt += L" ), ";
scene::ICameraSceneNode* cam = smgr->getActiveCamera();
if (cam)
{
const core::vector3df& pos = cam->getAbsolutePosition();
txt += L"cam( pos(";
txt += core::round32(pos.X); txt += L",";
txt += core::round32(pos.Y); txt += L",";
txt += core::round32(pos.Z); txt += L"), ";
const core::vector3df& eye = cam->getTarget();
txt += L"eye(";
txt += core::round32(eye.X); txt += L",";
txt += core::round32(eye.Y); txt += L",";
txt += core::round32(eye.Z); txt += L"), ";
txt += L"near(";
txt += cam->getNearValue();
txt += L"), far(";
txt += core::round32(cam->getFarValue() ); txt += L")";
txt += L" )";
}
device->setWindowCaption( txt.c_str() );
timeLastWindowTitleUpate = timer->getRealTime();
}
}
else
{
device->yield();
}
}
else
{
device->yield();
}
}
if (device)
device->drop();
return 0;
}