本文整理汇总了C++中DTime::getElapsed方法的典型用法代码示例。如果您正苦于以下问题:C++ DTime::getElapsed方法的具体用法?C++ DTime::getElapsed怎么用?C++ DTime::getElapsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DTime
的用法示例。
在下文中一共展示了DTime::getElapsed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
/**
* \brief Draw, Call back from the GLMoblet.
*/
void draw()
{
mDTime.tick(); // update delta time ticker. our fps timer (resets for every tick call)
MoGraph::Scene &scene = mGraph->getScene(); // get scene information
const int iGridZ = scene.getGridZ(); // need to be able to read the grid size
const int iGridX = scene.getGridX();
const int sz = iGridX * iGridZ;
mGraph->setValues(mTables,sz); // set the value array to the Graph to read from
mGraph->setColors(mColors,sz); // set the color array to the Graph to read from
mGraph->draw(); // Draw the whole graph system
// DRAW ADDITIONAL TEXT ON SCREEN (Orthogonal projections)
//---------------------------------------------------------------------
glm::vec4 col(1.0f,1.0f,1.0f,1.0f); // White color
glm::vec3 pos(0.0f,0.0f,10.0f); // set screen position upper left corner 0,0.. note need z depth value for order.
float sy = (0.6f*(float)scene.getWidth())/320.0f; // scale size regardless to resolution our reference resolution is 320..
mText.setScale(sy,sy);
char buf[64]; // create text string
sprintf ( buf, "FPS=%.2f ms=%d",mDTime.currentFps(),mDTime.getElapsed());
mText.drawText(buf,pos,col); // call drawText
}
示例2: draw
/**
* \brief Draw, Call back from the GLMoblet.
*/
void draw()
{
mDTime.tick(); // update delta time ticker. our fps timer (resets for every tick call)
MoGraph::Scene &scene = mGraph->getScene(); // get scene information
const int iGridZ = scene.getGridZ(); // need to be able to read the grid size
const int iGridX = scene.getGridX();
const int sz = iGridX * iGridZ;
float dt = static_cast<float>(mDTime.getElapsed())*0.001f; // calculate a delta time factor for omega
mOmega += dt; // accumulate the omega used for sin/cos func
if (mOmega > M_PI*2.0f) // for high precision make sure omega 0..2*PI
mOmega -= M_PI*2.0f; // wrapping a x value is also faster not to use large values in sin(x).
const float f = 2.5f/255.0f; // prepare for a scale value of result being max 2.5f
for(int j=0; j<iGridZ; j++) // Build the data arrays for colors and for tables.
{
const float jcos = 2.0f + cos(j*0.3f+mOmega); // calculate the Depth Wave with cos
for(int i=0; i<iGridX; i++)
{
const int id = j*iGridX+i;
Color *c = (Color *)&mLogoH.getData()[id];
mTables[id] = (float)c->r * f + (sin(i*0.3f+mOmega) + jcos); // generate a sine wave and add depth wave
}
}
mGraph->setValues(mTables,sz); // set the value array to the Graph to read from
mGraph->setColors(mColors,sz); // set the color array to the Graph to read from
mGraph->draw(); // Draw the whole graph system
// DRAW ADDITIONAL TEXT ON SCREEN (Orthogonal projections)
//---------------------------------------------------------------------
glm::vec4 col(1.0f,1.0f,1.0f,1.0f); // White color
glm::vec3 pos(0.0f,0.0f,10.0f); // set screen position upper left corner 0,0.. note need z depth value for order.
float sy = (0.6f*(float)scene.getWidth())/320.0f; // scale size regardless to resolution our reference resolution is 320..
mText.setScale(sy,sy);
char buf[64]; // create text string
sprintf ( buf, "FPS=%.2f ms=%d",mDTime.currentFps(),mDTime.getElapsed());
mText.drawText(buf,pos,col); // call drawText
}