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


C++ CStopWatch::Reset方法代码示例

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


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

示例1: 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;
    }
}
开发者ID:CodeBees,项目名称:OpenGLSuperBible5ANGLE,代码行数:29,代码来源:pix_buffs.cpp

示例2: 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;
	}
}
开发者ID:CodeBees,项目名称:OpenGLSuperBible5ANGLE,代码行数:30,代码来源:pix_buffs.cpp

示例3: movingCylinder

void movingCylinder()
{

    static CStopWatch cameraTimer;
    float fTime = cameraTimer.GetElapsedSeconds();
    cameraTimer.Reset();

    float linear = fTime * 3.0f;
    float angular = fTime * float(m3dDegToRad(15.0f));

    if(isMoveForward == true) cameraFrame.MoveForward(linear);
    if(isMoveBack == true) cameraFrame.MoveForward(-linear);
    if(isRotateLeft == true) cameraFrame.RotateWorld(angular, 0.0f, 1.0f, 0.0f);
    if(isRotateRight == true) cameraFrame.RotateWorld(-angular, 0.0f, 1.0f, 0.0f);
    if(isRotateUp == true) cameraFrame.RotateWorld(angular, 1.0f, 0.0f, 0.0f);
    if(isRotateDown == true) cameraFrame.RotateWorld(-angular, 1.0f, 0.0f, 0.0f);
}
开发者ID:ybbai,项目名称:workspace,代码行数:17,代码来源:fbotextures.cpp

示例4: SpecialKeys

///////////////////////////////////////////////////////////////////////////////
// Update the camera based on user input, toggle display modes
// 
void SpecialKeys(int key, int x, int y)
{ 
	static CStopWatch cameraTimer;
	float fTime = cameraTimer.GetElapsedSeconds();
	cameraTimer.Reset(); 

	float linear = fTime * 0.60f;
	float angular = fTime * float(m3dDegToRad(60.0f));

	if(key == GLUT_KEY_UP)
		cameraFrame.MoveForward(linear);

	if(key == GLUT_KEY_DOWN)
		cameraFrame.MoveForward(-linear);

	if(key == GLUT_KEY_LEFT)
		cameraFrame.RotateWorld(angular, 0.0f, 1.0f, 0.0f);

	if(key == GLUT_KEY_RIGHT)
		cameraFrame.RotateWorld(-angular, 0.0f, 1.0f, 0.0f);
}
开发者ID:marblep,项目名称:OpenGL,代码行数:24,代码来源:fbo_textures.cpp

示例5: SpecialKeys

///////////////////////////////////////////////////////////////////////////////
// Update the camera based on user input, toggle display modes
// 
void SpecialKeys(int key, int x, int y)
{ 
    static CStopWatch cameraTimer;
    float fTime = cameraTimer.GetElapsedSeconds();
    cameraTimer.Reset(); 

    float linear = fTime * 3.0f;
    float angular = fTime * float(m3dDegToRad(60.0f));

    if(key == GLUT_KEY_LEFT)
    {
        worldAngle += angular*50;
        if(worldAngle > 360)
            worldAngle -= 360;
    }

    if(key == GLUT_KEY_RIGHT)
    {
        worldAngle -= angular*50;
        if(worldAngle < 360)
            worldAngle += 360;
    }
}
开发者ID:1085075003,项目名称:oglsuperbible5,代码行数:26,代码来源:oit.cpp

示例6: StartZero

TEST(TestStopWatch, Reset)
{
  CStopWatch a;
  CTestStopWatchThread thread;

  EXPECT_FALSE(a.IsRunning());
  EXPECT_EQ(0.0f, a.GetElapsedSeconds());
  EXPECT_EQ(0.0f, a.GetElapsedMilliseconds());

  std::cout << "Calling StartZero()" << std::endl;
  a.StartZero();
  thread.Sleep(1000);
  EXPECT_TRUE(a.IsRunning());
  std::cout << "Elapsed Seconds: " << a.GetElapsedSeconds() << std::endl;
  std::cout << "Elapsed Milliseconds: " << a.GetElapsedMilliseconds() << std::endl;

  std::cout << "Calling Reset()" << std::endl;
  a.Reset();
  thread.Sleep(1000);
  EXPECT_TRUE(a.IsRunning());
  std::cout << "Elapsed Seconds: " << a.GetElapsedSeconds() << std::endl;
  std::cout << "Elapsed Milliseconds: " << a.GetElapsedMilliseconds() << std::endl;
}
开发者ID:DJMatty,项目名称:xbmc,代码行数:23,代码来源:TestStopwatch.cpp

示例7: handleInput

void handleInput(CStopWatch &inputTimer)
{	
	// Exit
	if (in.keyPressed(sf::Keyboard::Escape))
		exit(0);

	// Camera movement
	float elapsedTime = inputTimer.GetElapsedSeconds() * 1.5f;
	inputTimer.Reset();
	if (mouseActive)
	{
		if (in.keyPressed(sf::Keyboard::W))
			cameraFrame.MoveForward(camSpeed*elapsedTime);
		if (in.keyPressed(sf::Keyboard::S))
			cameraFrame.MoveForward(-camSpeed*elapsedTime);
		if (in.keyPressed(sf::Keyboard::A))
			cameraFrame.MoveRight(camSpeed*elapsedTime);
		if (in.keyPressed(sf::Keyboard::D))
			cameraFrame.MoveRight(-camSpeed*elapsedTime);
		if (in.keyPressed(sf::Keyboard::Space))
			cameraFrame.MoveUp(camSpeed*elapsedTime);
		if (in.keyPressed(sf::Keyboard::LControl))
			cameraFrame.MoveUp(-camSpeed*elapsedTime);
	}

	else
	{
		if (in.keyPressed(sf::Keyboard::W))
			cameraFrame.MoveUp(camSpeed*elapsedTime);
		if (in.keyPressed(sf::Keyboard::S))
			cameraFrame.MoveUp(-camSpeed*elapsedTime);
		if (in.keyPressed(sf::Keyboard::A))
			cameraFrame.MoveRight(camSpeed*elapsedTime);
		if (in.keyPressed(sf::Keyboard::D))
			cameraFrame.MoveRight(-camSpeed*elapsedTime);
	}
}
开发者ID:Errim,项目名称:Datorsalsplaneraren,代码行数:37,代码来源:main.cpp

示例8: SpecialKeys

///////////////////////////////////////////////////////////////////////////////
// Update the camera based on user input, toggle display modes
// 
void SpecialKeys(int key, int x, int y)
{
	static CStopWatch cameraTimer;
	float fTime = cameraTimer.GetElapsedSeconds();
	cameraTimer.Reset(); 

	float linear = fTime * 3.0f;
	float angular = fTime * float(m3dDegToRad(60.0f));

	if(key == GLUT_KEY_UP)
		cameraFrame.MoveForward(linear);

	if(key == GLUT_KEY_DOWN)
		cameraFrame.MoveForward(-linear);

	if(key == GLUT_KEY_LEFT)
		cameraFrame.RotateWorld(angular, 0.0f, 1.0f, 0.0f);

	if(key == GLUT_KEY_RIGHT)
		cameraFrame.RotateWorld(-angular, 0.0f, 1.0f, 0.0f);

	static bool bF2IsDown = false;
	if(key == GLUT_KEY_F2)
	{
		if(bF2IsDown == false)
		{
			bF2IsDown = true;
			bUseFBO = !bUseFBO;
		}
	}
	else
	{
		bF2IsDown = false; 
	}

#ifndef OPENGL_ES
	if(key == GLUT_KEY_F3)
	{
		glActiveTexture(GL_TEXTURE1);
		glBindTexture(GL_TEXTURE_BUFFER_ARB, texBOTexture);
		glTexBufferARB(GL_TEXTURE_BUFFER_ARB, GL_R32F, texBO[0]); // FIX THIS IN GLEE
		glActiveTexture(GL_TEXTURE0);
	}
	else if(key == GLUT_KEY_F4)
	{
		glActiveTexture(GL_TEXTURE1);
		glBindTexture(GL_TEXTURE_BUFFER_ARB, texBOTexture);
		glTexBufferARB(GL_TEXTURE_BUFFER_ARB, GL_R32F, texBO[1]); // FIX THIS IN GLEE
		glActiveTexture(GL_TEXTURE0);
	}
	else if(key == GLUT_KEY_F5)
	{
		glActiveTexture(GL_TEXTURE1);
		glBindTexture(GL_TEXTURE_BUFFER_ARB, texBOTexture);
		glTexBufferARB(GL_TEXTURE_BUFFER_ARB, GL_R32F, texBO[2]); // FIX THIS IN GLEE
		glActiveTexture(GL_TEXTURE0);
	}
#endif

	 // Refresh the Window
	 glutPostRedisplay();
}
开发者ID:CodeBees,项目名称:OpenGLSuperBible5ANGLE,代码行数:65,代码来源:fbo_drawbuffers.cpp

示例9: GameLoop

void GameLoop( sf::RenderWindow &app, bool &bczyGra, bool &bMenu )
{
    ResetGame();

    bool pauseGame = false;

    sf::Mouse::setPosition( sf::Vector2i( Width / 2, Height / 2 ), app );
    app.setMouseCursorVisible( false );

    sounds[2].play();

    while ( bczyGra )
    {
        LoopTime = TimeLoop.GetElapsedSeconds();
        TimeLoop.Reset();

        sf::Event event;
        while (app.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                bczyGra = false;
                bMenu = false;
                app.close();
            }
            else if (event.type == sf::Event::Resized)
            {
                ChangeSize( event.size.width, event.size.height );
            }
            else if ( ( event.type == sf::Event::KeyReleased ) &&
                      ( event.key.code == sf::Keyboard::Escape ) ){
                bczyGra = false;
                bMenu = true;
            }

            if ( ( ( event.type == sf::Event::JoystickButtonReleased ) &&
                 ( event.joystickButton.button == 0 ) )  ||
                ( event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::P ) ){
                pauseGame = !pauseGame;
                if ( pauseGame == true ) {
                    app.setMouseCursorVisible( true );
                    sounds[2].pause();
                } else {
                    sf::Mouse::setPosition( sf::Vector2i( Width / 2, Height / 2 ), app );
                    app.setMouseCursorVisible( false );
                    LoopTime = 0.0f;
                    TimeLoop.Reset();
                    sounds[2].play();
                }
            }
        }

        KeyControl( LoopTime, app );
        if ( !pauseGame ) {
            MoveMouse( sf::Mouse::getPosition( app ).x, sf::Mouse::getPosition( app ).y, app );
            MouseControl( LoopTime );
            Joystick( LoopTime, app );
            if ( Player.getLife() < 0 ) {
                bczyGra = false;
                bMenu = true;
            }
            Logika( LoopTime );
            RenderScene();
            app.display();
        }
    }

    sounds[2].stop();
    hud.sendScore();
}
开发者ID:SharpShooter17,项目名称:Space_Ship_3D_OpenGL_Fatal_game,代码行数:70,代码来源:GameLoop.cpp

示例10: RenderScene

// Called to draw scene
void RenderScene(void)
{
    static int iFrames = 0;           // Frame count
    static CStopWatch frameTimer;     // Render time
 
    // Reset the stopwatch on first time
    if(iFrames == 0)
    {
        frameTimer.Reset();
        iFrames++;
    }

    // Advance old frame
    currentFrame = (currentFrame + 1) % 3;
    int lastFrame = (currentFrame + 2) % 3;
    int frameBeforeThat = (currentFrame + 1) % 3;

    // Rotate the texture matrix for unit 0 (current frame)
    glActiveTexture(GL_TEXTURE0);
    glTranslatef(0.5f, 0.5f, 0.0f);
    glRotatef(angleIncrement, 0.0f, 0.0f, 1.0f);
    glTranslatef(-0.5f, -0.5f, 0.0f);

    if (!useMotionBlur)
    {
        GLfloat copiedMatrix[16];
        glGetFloatv(GL_TEXTURE_MATRIX, copiedMatrix);
        glActiveTexture(GL_TEXTURE1);
        glLoadMatrixf(copiedMatrix);
        glBindTexture(GL_TEXTURE_2D, 1);
    }

    // Draw objects in the scene
    int i;
    glBegin(GL_QUADS);
        for (i = 0; i < 3; i++)
            glMultiTexCoord2f(GL_TEXTURE0 + i, 0.0f, 0.0f);
        glVertex2f(-1.0f, -1.0f);
        for (i = 0; i < 3; i++)
            glMultiTexCoord2f(GL_TEXTURE0 + i, 0.0f, 1.0f);
        glVertex2f(-1.0f, 1.0f);
        for (i = 0; i < 3; i++)
            glMultiTexCoord2f(GL_TEXTURE0 + i, 1.0f, 1.0f);
        glVertex2f(1.0f, 1.0f);
        for (i = 0; i < 3; i++)
            glMultiTexCoord2f(GL_TEXTURE0 + i, 1.0f, 0.0f);
        glVertex2f(1.0f, -1.0f);
    glEnd();

    // Now read back result
    if (usePBOs)
    {
        glBindBuffer(GL_PIXEL_PACK_BUFFER, currentFrame + 1);
        glReadPixels(dataOffsetX, dataOffsetY, dataWidth, dataHeight, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)0);
        glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
    }
    else
    {
        glReadPixels(dataOffsetX, dataOffsetY, dataWidth, dataHeight, GL_RGB, GL_UNSIGNED_BYTE, pixels[currentFrame]);
    }

    frameGood[currentFrame] = GL_TRUE;

    // Prepare the last frame by dividing colors by 4
    if (usePBOs)
    {
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, lastFrame + 1);
        pixels[lastFrame] = (GLubyte*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
    }
    for (int y = 0; y < dataHeight; y++)
    {
        for (int x = 0; x < dataWidth; x++)
        {
            GLubyte *ptr = (GLubyte *)pixels[lastFrame] + (y*dataPitch) + (x*3);
            *(ptr + 0) >>= 2;
            *(ptr + 1) >>= 2;
            *(ptr + 2) >>= 2;
        }
    }
    if (usePBOs)
    {
        glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
        pixels[lastFrame] = NULL;
    }

    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, 2+lastFrame);
    if (usePBOs)
    {
        if (frameGood[lastFrame])
        {
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, dataWidth, dataHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)0);
        }
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
    }
    else if (frameGood[lastFrame])
    {
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, dataWidth, dataHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels[lastFrame]);
    }
//.........这里部分代码省略.........
开发者ID:quyenanh46dp,项目名称:Jingz_CPP_lab,代码行数:101,代码来源:pixbufobj.cpp

示例11: RenderScene

// Called to draw scene
void RenderScene(void)
    {
    static int iFrames = 0;             // Frame count
    static CStopWatch frameTimer;       // Render time
    
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
        
    glPushMatrix();
        frameCamera.ApplyCameraTransform();
        
        // Position light before any other transformations
        glLightfv(GL_LIGHT0, GL_POSITION, fLightPos);
        
        // Draw the ground
        glColor3f(1.0f, 1.0f, 1.0f);
        if(iMethod == 0)
            DrawGround();
        else
            glCallList(groundList);
        
        // Draw shadows first
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);
        glDisable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_STENCIL_TEST);
        glPushMatrix();
            glMultMatrixf(mShadowMatrix);
            DrawInhabitants(1);
        glPopMatrix();
        glDisable(GL_STENCIL_TEST);
        glDisable(GL_BLEND);
        glEnable(GL_LIGHTING);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_DEPTH_TEST);
        
        // Draw inhabitants normally
        DrawInhabitants(0);

    glPopMatrix();
        
    // Do the buffer Swap
    glutSwapBuffers();

    // Increment the frame count
    iFrames++;

    // Do periodic frame rate calculation
    if(iFrames == 100)
        {
        float fps;
        char cBuffer[64];
        
        fps = 100.0f / frameTimer.GetElapsedSeconds();
        if(iMethod == 0)
            sprintf(cBuffer,"OpenGL SphereWorld without Display Lists %.1f fps", fps);
        else
            sprintf(cBuffer,"OpenGL SphereWorld with Display Lists %.1f fps", fps);
            
        glutSetWindowTitle(cBuffer);
        
        frameTimer.Reset();
        iFrames = 0;
        }

    }
开发者ID:reima,项目名称:ogl-docs-mirror,代码行数:69,代码来源:sphereworld.cpp


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