本文整理汇总了C++中CStopWatch::GetElapsedSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ CStopWatch::GetElapsedSeconds方法的具体用法?C++ CStopWatch::GetElapsedSeconds怎么用?C++ CStopWatch::GetElapsedSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStopWatch
的用法示例。
在下文中一共展示了CStopWatch::GetElapsedSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderScene
// Called to draw scene
void RenderScene(void)
{
static CStopWatch rotTimer;
// Clear the window and the depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelViewMatrix.PushMatrix(viewFrame);
modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.0f, 0.0f, 1.0f, 0.0f);
modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 13.0f, 1.0f, 0.0f, 0.0f);
GLfloat vEyeLight[] = { -100.0f, 100.0f, 100.0f };
GLfloat vAmbientColor[] = { 0.1f, 0.1f, 0.1f, 1.0f };
GLfloat vDiffuseColor[] = { 0.1f, 1.0f, 0.1f, 1.0f };
GLfloat vSpecularColor[] = { 1.0f, 1.0f, 1.0f, 1.0f };
glUseProgram(explodeProgram);
glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix());
glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeline.GetModelViewMatrix());
glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeline.GetNormalMatrix());
float push_out = sinf(rotTimer.GetElapsedSeconds() * 3.0f) * 0.1f + 0.2f;
glUniform1f(locPushOut, push_out);
torusBatch.Draw();
modelViewMatrix.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例2: Display
void Display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
static CStopWatch timer;
GLfloat yRot = timer.GetElapsedSeconds()*20.0f;
GLfloat vWhite[] = {1.0f,1.0f,1.0f,1.0f};
GLfloat vLightPos[] = {0.0f,2.0f,2.0f};
GLfloat vAmbient[] = {0.3f,0.3f,1.0f,1.0f};
modelViewMatrix.PushMatrix();
//move to camera view
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.MultMatrix(mCamera);
modelViewMatrix.PushMatrix();
modelViewMatrix.Rotate(yRot,1.0,1.0,1.0);
glBindTexture(GL_TEXTURE_2D,fbxTexture);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF,
transformPipeLine.GetModelViewMatrix(),
transformPipeLine.GetProjectionMatrix(),
vLightPos, vWhite, 0);
//*/shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeLine.GetModelViewProjectionMatrix(),vWhite);
modelViewMatrix.Scale(0.05,0.05,0.05);
rTest.DrawReader();
modelViewMatrix.PopMatrix();
modelViewMatrix.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例3: RenderScene
// Called to draw scene
void RenderScene(void)
{
static CStopWatch rotTimer;
// Clear the window and the depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelViewMatrix.PushMatrix(viewFrame);
modelViewMatrix.Rotate(-90.0f, 1.0f, 0.0f, 0.0f);
modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.0f, 0.0f, 0.0f, 1.0f);
GLfloat vEyeLight[] = { -100.0f, 100.0f, 150.0f };
GLfloat vAmbientColor[] = { 0.2f, 0.2f, 0.2f, 1.0f };
GLfloat vDiffuseColor[] = { 1.0f, 1.0f, 1.0f, 1.0f};
glUseProgram(normalMapShader);
glUniform4fv(locAmbient, 1, vAmbientColor);
glUniform4fv(locDiffuse, 1, vDiffuseColor);
glUniform3fv(locLight, 1, vEyeLight);
glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix());
glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeline.GetModelViewMatrix());
glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeline.GetNormalMatrix());
glUniform1i(locColorMap, 0);
glUniform1i(locNormalMap, 1);
sphereBatch.Draw();
modelViewMatrix.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例4: RenderScene
// Called to draw scene
void RenderScene(void)
{
static CStopWatch timer;
// Clear the window and the depth buffer
glClear(GL_COLOR_BUFFER_BIT);
// Turn on additive blending
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
// Let the vertex program determine the point size
glEnable(GL_PROGRAM_POINT_SIZE);
// Bind to our shader, set uniforms
glUseProgram(starFieldShader);
glUniformMatrix4fv(locMVP, 1, GL_FALSE, viewFrustum.GetProjectionMatrix());
glUniform1i(locTexture, 0);
// fTime goes from 0.0 to 999.0 and recycles
float fTime = timer.GetElapsedSeconds() * 10.0f;
fTime = fmod(fTime, 999.0f);
glUniform1f(locTimeStamp, fTime);
// Draw the stars
starsBatch.Draw();
glutSwapBuffers();
glutPostRedisplay();
}
示例5: ProccessKeys
///////////////////////////////////////////////////////////////////////////////
// Update the camera based on user input, toggle display modes
//
void ProccessKeys(unsigned char key, int x, int y)
{
static CStopWatch cameraTimer;
float fTime = cameraTimer.GetElapsedSeconds();
float linear = fTime * 12.0f;
cameraTimer.Reset();
// Alternate between PBOs and local memory when 'P' is pressed
if(key == 'P' || key == 'p')
bUsePBOPath = (bUsePBOPath)? GL_FALSE : GL_TRUE;
// Speed up movement
if(key == 'j' || key == 'J')
{
speedFactor += linear/2;
if(speedFactor > 6)
speedFactor = 6;
}
// Slow down moement
if(key == 'k' || key == 'K')
{
speedFactor -= linear/2;
if(speedFactor < 0.5)
speedFactor = 0.5;
}
}
示例6: UpdateFrameCount
void UpdateFrameCount()
{
static int iFrames = 0; // Frame count
static CStopWatch frameTimer; // Render time
// Reset the stopwatch on first time
if(iFrames == 0)
{
frameTimer.Reset();
iFrames++;
}
// Increment the frame count
iFrames++;
// Do periodic frame rate calculation
if (iFrames == 101)
{
float fps;
fps = 100.0f / frameTimer.GetElapsedSeconds();
if (bUsePBOPath)
printf("Pix_buffs - Using PBOs %.1f fps\n", fps);
else
printf("Pix_buffs - Using Client mem copies %.1f fps\n", fps);
frameTimer.Reset();
iFrames = 1;
}
}
示例7: RenderScene
void RenderScene(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glEnable( GL_DEPTH_TEST ) ;
glUseProgram(shader);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
float angle = timer.GetElapsedSeconds();
M3DVector3f eye = {cos(angle)*4.0f,sin(angle)*4.0,sin(angle)*4.0f};
M3DVector3f at = {0,0,0};
M3DVector3f up = {0.0f,0.0f,1.0f};
GLFrame cameraFrame;
LookAt(cameraFrame, eye, at, up);
cameraFrame.GetCameraMatrix(cameraMatrix);
m3dMatrixMultiply44(matrix, viewFrustum.GetProjectionMatrix(), cameraMatrix);
M3DMatrix44f tMatrix;
m3dTranslationMatrix44(tMatrix, 0, 0, 0);
m3dMatrixMultiply44(matrix, tMatrix, matrix);
if((sin(angle) < 0 && sin(angle-0.003) > 0) || (sin(angle) > 0 && sin(angle-0.003) < 0)) {
debugMatrix44(matrix);
}
glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrix);
// drawGrid(0.1);
drawPyramid();
glutSwapBuffers();
glutPostRedisplay();
}
示例8: Start
TEST(TestStopWatch, Start)
{
CStopWatch a;
CTestStopWatchThread thread;
EXPECT_FALSE(a.IsRunning());
EXPECT_EQ(0.0f, a.GetElapsedSeconds());
EXPECT_EQ(0.0f, a.GetElapsedMilliseconds());
std::cout << "Calling Start()" << std::endl;
a.Start();
thread.Sleep(1000);
EXPECT_TRUE(a.IsRunning());
std::cout << "Elapsed Seconds: " << a.GetElapsedSeconds() << std::endl;
std::cout << "Elapsed Milliseconds: " << a.GetElapsedMilliseconds() << std::endl;
}
示例9: RenderScene
void RenderScene()
{
static GLfloat vSunColor[] = { 1.0f, 0.0f, 0.0f, 1.0f };
static GLfloat vEarthColor[] = { 0.0f, 0.0f, 1.0f, 1.0f };
static GLfloat vMoonColor[] = { 1.0f, 1.0f, 0.0f, 1.0f };
static GLfloat vFloorColor[] = { 0.0f, 1.0f, 0.0f, 1.0f};
static CStopWatch rotTimer;
float yRot = rotTimer.GetElapsedSeconds() * 60.0f;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelViewMatrix.PushMatrix();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.PushMatrix(mCamera);
M3DVector4f vLightPos = { 0.0f, 10.0f, 5.0f, 1.0f };
M3DVector4f vLightEyePos;
m3dTransformVector4(vLightEyePos, vLightPos, mCamera);
shaderManager.UseStockShader(GLT_SHADER_FLAT,
transformPipeline.GetModelViewProjectionMatrix(),
vFloorColor);
floorBatch.Draw();
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
modelViewMatrix.Translate(0.0f, 0.0f, -3.5f);
modelViewMatrix.PushMatrix();
modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f);
shaderManager.UseStockShader(GLT_SHADER_FLAT,
transformPipeline.GetModelViewProjectionMatrix(), vSunColor);
sunSphereBatch.Draw();
modelViewMatrix.PopMatrix();
modelViewMatrix.Rotate(yRot * -2.0f, 0.0f, 1.0f, 0.0f);
modelViewMatrix.Translate(0.8f, 0.0f, 0.0f);
shaderManager.UseStockShader(GLT_SHADER_FLAT,
transformPipeline.GetModelViewProjectionMatrix(), vEarthColor);
earthSphereBatch.Draw();
modelViewMatrix.Rotate(yRot * -4.0f, 0.0f, 1.0f, 0.0f);
modelViewMatrix.Translate(0.4f, 0.0f, 0.0f);
shaderManager.UseStockShader(GLT_SHADER_FLAT,
transformPipeline.GetModelViewProjectionMatrix(), vMoonColor);
moonSphereBatch.Draw();
modelViewMatrix.PopMatrix();
modelViewMatrix.PopMatrix();
modelViewMatrix.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例10: RenderScene
void RenderScene(void)
{
static CStopWatch rotTimer;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelViewMatrix.PushMatrix(viewFrame);
{
modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.f, 0.0f, 1.0f, 0.0f);
glUseProgram(toonShader);
glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeLine.GetModelViewMatrix());
glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeLine.GetModelViewProjectionMatrix());
glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeLine.GetNormalMatrix());
glUniform3fv(locLP, 1, vEyeLight);
glUniform1i(locColorTable, 0);
torusBatch.Draw();
}
modelViewMatrix.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例11: RenderScene
// Called to draw scene
static void RenderScene(void)
{
static CStopWatch rotTimer;
// Clear the window and the depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelViewMatrix.PushMatrix(viewFrame);
modelViewMatrix.Rotate(40.0f, 0.0f, 1.0f, 0.0f);
modelViewMatrix.Rotate(20.0f, 1.0f, 0.0f, 0.0f);
float f = (float)rotTimer.GetElapsedSeconds();
GLfloat vViewpoint[] = { sinf(f * 3.1f) * 30.0f, cosf(f * 2.4f) * 30.0f, sinf(f * 1.7f) * 30.0f };
glUseProgram(cullingShader);
glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix());
glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeline.GetModelViewMatrix());
glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeline.GetNormalMatrix());
glUniform3fv(locViewpoint, 1, vViewpoint);
torusBatch.Draw();
modelViewMatrix.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例12: updateCamera
void updateCamera()
{
M3DVector3f at = {0, 0, 0};
M3DVector3f up = {0, 0, -1};
M3DVector3f eye;
float angle = timer.GetElapsedSeconds() * 2;
eye[0] = 6.8f * cos(angle);
eye[1] = 6.0f * sin(angle);
eye[2] = 5.0f;
lookAt(frame, eye, at, up);
}
示例13: RenderScene
///////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
{
static CStopWatch timer;
// Clear the window
glClear(GL_COLOR_BUFFER_BIT);
// Everything is white
GLfloat vWhite [] = { 1.0f, 1.0f, 1.0f, 1.0f };
glBindTexture(GL_TEXTURE_2D, starTexture);
glUseProgram(starFieldShader);
glUniformMatrix4fv(locMVP, 1, GL_FALSE, viewFrustum.GetProjectionMatrix());
glUniform1i(locStarTexture, 0);
// Draw small stars
glPointSize(4.0f);
smallStarBatch.Draw();
// Draw medium sized stars
glPointSize(8.0f);
mediumStarBatch.Draw();
// Draw largest stars
glPointSize(12.0f);
largeStarBatch.Draw();
// Draw distant horizon
shaderManager.UseStockShader(GLT_SHADER_FLAT, viewFrustum.GetProjectionMatrix(), vWhite);
glLineWidth(3.5);
mountainRangeBatch.Draw();
// Draw the "moon"
glBindTexture(GL_TEXTURE_2D_ARRAY, moonTexture);
glUseProgram(moonShader);
glUniformMatrix4fv(locMoonMVP, 1, GL_FALSE, viewFrustum.GetProjectionMatrix());
glUniform1i(locMoonTexture, 0);
// fTime goes from 0.0 to 28.0 and recycles
float fTime = timer.GetElapsedSeconds();
fTime = fmod(fTime, 28.0f);
glUniform1f(locTimeStamp, fTime);
moonBatch.Draw();
// Swap buffers
glutSwapBuffers();
glutPostRedisplay();
}
示例14: RenderScene
void RenderScene(void)
{
static CStopWatch stopwatch;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(instancingShader);
glBindVertexArray(square_vao);
glUniform1f(angle_loc, stopwatch.GetElapsedSeconds());
glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, 4);
glutSwapBuffers();
glutPostRedisplay();
}
示例15: render_scene
void render_scene(void) {
float angle = timer.GetElapsedSeconds() * 3.14f / 10.0f;
location[0] = -8.0f * cos(angle / 2.0f);
location[1] = -8.0f * sin(angle / 2.0f);
location[2] = 5.0f;
light_0.position[0] = 10.0f * cos(-angle);
light_0.position[1] = 10.0f * sin(-angle);
light_0.position[2] = 3.0f;
look_at(camera_frame, location, target, up_dir);
camera_frame.GetCameraMatrix(camera_matrix);
p_stack.LoadMatrix(view_frustum.GetProjectionMatrix());
mv_stack.LoadMatrix(camera_matrix);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
//--
glUseProgram(shader_color);
mv_stack.PushMatrix();
mv_stack.Translate(light_0.position[0], light_0.position[1], light_0.position[2]);
mv_stack.Scale(0.25f, 0.25f, 0.25f);
glUniformMatrix4fv(mvp_matrix_location_shader_color, 1, GL_FALSE, geometry_pipeline.GetModelViewProjectionMatrix());
draw_light();
mv_stack.PopMatrix();
//--
glUseProgram(shader_light);
glUniformMatrix3fv(normal_matrix_location, 1, GL_FALSE, geometry_pipeline.GetNormalMatrix());
glUniformMatrix4fv(v_matrix_location, 1, GL_FALSE, camera_matrix);
glUniform3fv(intensity_ambient_component_location, 1, intensity_ambient_component);
glUniform3fv(light_0_position_location, 1, light_0.position);
glUniform3fv(light_0_intensity_diffuse_location, 1, light_0.intensity_diffuse);
glUniform3fv(light_0_intensity_specular_location, 1, light_0.intensity_specular);
glUniform3fv(light_0_attenuation_location, 1, light_0.attenuation);
glUniform1f(material_0_ka_location, material_0.ka);
glUniform1f(material_0_kd_location, material_0.kd);
glUniform1f(material_0_ks_location, material_0.ks);
glUniform1f(material_0_alpha_location, material_0.alpha);
//--
for(int i = -10; i <= 10; i += 3)
for(int j = -10; j <= 10; j += 3) {
mv_stack.PushMatrix();
mv_stack.Translate(i, j, 0.0f);
glUniformMatrix4fv(mvp_matrix_location, 1, GL_FALSE, geometry_pipeline.GetModelViewProjectionMatrix());
glUniformMatrix4fv(mv_matrix_location, 1, GL_FALSE, geometry_pipeline.GetModelViewMatrix());
glDrawElements(GL_TRIANGLES, faces.size(), GL_UNSIGNED_INT, 0);
mv_stack.PopMatrix();
}
//--
glUseProgram(0);
glutSwapBuffers();
glutPostRedisplay();
}