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


C++ CStopWatch类代码示例

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


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

示例1: RenderScene

// Called to draw scene
void RenderScene(void)
	{
	static CStopWatch rotTimer;
        GLenum e;

	// Clear the window and the depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    modelViewMatrix.PushMatrix(viewFrame);
		modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 20.0f, 0.0f, 1.0f, 0.0f);
		modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 17.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(toonShader);
		// 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());

        e = glGetError();

    // torusBatch.Draw();
    // cubeBatch.Draw();
        glDisable(GL_CULL_FACE);
        e = glGetError();
        glBindVertexArray(vao);
        e = glGetError();
        glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, NULL);
        e = glGetError();

    modelViewMatrix.PopMatrix();


    glutSwapBuffers();
	glutPostRedisplay();
	}
开发者ID:hanwj,项目名称:myStudy,代码行数:41,代码来源:GSTessellate.cpp

示例2: RenderScene

// Called to draw scene
void RenderScene(void)
	{
    // Color values
    static GLfloat vFloorColor[] = { 0.0f, 1.0f, 0.0f, 1.0f};
    static GLfloat vTorusColor[] = { 1.0f, 0.0f, 0.0f, 1.0f };

    // Time Based animation
	static CStopWatch	rotTimer;
	float yRot = rotTimer.GetElapsedSeconds() * 60.0f;
	
	// Clear the color and depth buffers
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
    
    // Save the current modelview matrix (the identity matrix)
	modelViewMatrix.PushMatrix();	
		
	// Draw the ground
	shaderManager.UseStockShader(GLT_SHADER_FLAT,
								 transformPipeline.GetModelViewProjectionMatrix(),
								 vFloorColor);	
	floorBatch.Draw();

    // Draw the spinning Torus
    modelViewMatrix.Translate(0.0f, 0.0f, -2.5f);
    modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f);
    shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(),
                                vTorusColor);
    torusBatch.Draw();

	// Restore the previous modleview matrix (the idenity matrix)
	modelViewMatrix.PopMatrix();
        
    // Do the buffer Swap
    glutSwapBuffers();
        
    // Tell GLUT to do it again
    glutPostRedisplay();
    }
开发者ID:zsutxz,项目名称:SuperBible5_src,代码行数:40,代码来源:SphereWorld.cpp

示例3: RenderScene

///////////////////////////////////////////////////////////////////////////////
// Render a frame. The owning framework is responsible for buffer swaps,
// flushes, etc.
void RenderScene(void)
{
	static CStopWatch animationTimer;
	float yRot = animationTimer.GetElapsedSeconds() * 60.0f;

	// first, draw to FBO at full FBO resolution

	// Bind FBO with 8b attachment
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboName);
	glViewport(0, 0, hdrTexturesWidth[curHDRTex], hdrTexturesHeight[curHDRTex]);
	glClear(GL_COLOR_BUFFER_BIT);

	// Bind texture with HDR image 
	glBindTexture(GL_TEXTURE_2D, hdrTextures[curHDRTex]);

	// Render pass, downsample to 8b using selected program
	projectionMatrix.LoadMatrix(fboOrthoMatrix);
	SetupHDRProg();
	fboQuad.Draw();

	// Then draw the resulting image to the screen, maintain image proportions 
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
	glViewport(0, 0, screenWidth, screenHeight);
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

	// Attach 8b texture with HDR image 
	glBindTexture(GL_TEXTURE_2D, fboTextures[0]);
	
	// draw screen sized, proportional quad with 8b texture
	projectionMatrix.LoadMatrix(orthoMatrix);
	SetupStraightTexProg();
	screenQuad.Draw();
                
    // Do the buffer Swap
    glutSwapBuffers();
        
    // Do it again
    glutPostRedisplay();
}
开发者ID:marblep,项目名称:OpenGL,代码行数:42,代码来源:hdr_imaging.cpp

示例4: clFinish

void ToneMappingDrago03::getDataFromOpenCLMemory()
{
	clFinish(core->getCqCommandQueue());
	CStopWatch timer;
	timer.startTimer();
	
	unsigned int size = image->getHeight() * image->getWidth() * sizeof(cl_uint) * RGB_NUM_OF_CHANNELS;
	cl_int ciErr1;			// Error code var
	// Synchronous/blocking read of results, and check accumulated errors
	ciErr1 = clEnqueueReadBuffer(core->getCqCommandQueue(), cl_picture, CL_TRUE, 0, 
		size, picture, 0, NULL, NULL);

	clFinish(core->getCqCommandQueue());
	timer.stopTimer();
	logFile("gpuDrago,data_out,%d,%d,%f, \n", image->getHeight(), image->getWidth(), timer.getElapsedTime());

    logFile("clEnqueueReadBuffer ...\n\n"); 
    if (ciErr1 != CL_SUCCESS)
    {
		logFile("%d :Error in clEnqueueReadBuffer, Line %u in file %s !!!\n\n", ciErr1, __LINE__, __FILE__);
    }
}
开发者ID:mihailo,项目名称:HDRTool,代码行数:22,代码来源:ToneMappingDrago03.cpp

示例5: TEST

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;
}
开发者ID:DJMatty,项目名称:xbmc,代码行数:16,代码来源:TestStopwatch.cpp

示例6: m_socket

CDStarNetwork::CDStarNetwork(const std::string& gatewayAddress, unsigned int gatewayPort, unsigned int localPort, bool duplex, const char* version, bool debug) :
m_socket(localPort),
m_address(),
m_port(gatewayPort),
m_duplex(duplex),
m_version(version),
m_debug(debug),
m_enabled(false),
m_outId(0U),
m_outSeq(0U),
m_inId(0U),
m_buffer(1000U, "D-Star Network"),
m_pollTimer(1000U, 60U),
m_linkStatus(LS_NONE),
m_linkReflector(NULL)
{
	m_address = CUDPSocket::lookup(gatewayAddress);

	m_linkReflector = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH];

	CStopWatch stopWatch;
	::srand(stopWatch.start());
}
开发者ID:GB7FH,项目名称:MMDVMHost,代码行数:23,代码来源:DStarNetwork.cpp

示例7: 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

示例8: 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

示例9: RasterizeImage

void CTopographyRasterizer::RasterizeImage()
{
	CStopWatch sw;
	sw.Start();

	int LowPixel = 255;
	int HighPixel = 0;

	byte * ImageData = new byte[ImageSize * ImageSize * 3];
	for (int i = 0; i < ImageSize; ++ i)
	{
		for (int j = 0; j < ImageSize; ++ j)
		{
			int const Index = ImageSize * i + j;

			double const Value = Buckets[Index].Value;
			double const Intensity = 1.0f;
			int const Pixel = Clamp<int>((int) (Value * Intensity), 0, 255);

			LowPixel = Min(LowPixel, Pixel);
			HighPixel = Max(HighPixel, Pixel);

			ImageData[Index * 3 + 0] = Pixel;
			ImageData[Index * 3 + 1] = Pixel;
			ImageData[Index * 3 + 2] = Pixel;
			
		}
	}

	Log::Info("Low value: %d High Value: %d", LowPixel, HighPixel);

	CImage * Image = new CImage(ImageData, vec2u(ImageSize), 3);
	Image->FlipY();
	Image->Write(OutputName);

	Log::Info("Rasterize to image took %.3f", sw.Stop());
}
开发者ID:iondune,项目名称:Aqueous-2.0,代码行数:37,代码来源:CBathymetryRasterizer.cpp

示例10: RenderScence

void RenderScence(void)
{

	static CStopWatch rotTimer;
	float yRot = rotTimer.GetElapsedSeconds() * 60.0f;//每秒旋转60度?

	//Clear the window and the depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	M3DMatrix44f mTranslate, mRotate, mModelView, mModelViewProjection;

	//生成一个平移矩阵,用于将花环移回视野中,有个问题,1.0f会是什么效果?1.0会看不见花托。有可能截头体是世界坐标1.0-1000.0f是指距离camera的。所以此矩阵是相对于摄像机的操作,移到摄像机面前2.5f深度距离处
	//即摄像机所在的地方为原点(0,0,0)
	m3dTranslationMatrix44(mTranslate, 0.0f, 0.0f, -2.5f);

	//生成旋转矩阵 以y为轴,旋转时间t产生的旋转角 yRot
	m3dRotationMatrix44(mRotate, m3dDegToRad(yRot), 0.0f, 1.0f, 0.0f);

	//组合为模型变换矩阵,而原模型矩阵在最右边,即先旋转再平移 ?
	m3dMatrixMultiply44(mModelView, mTranslate, mRotate);

	//组合成模型投影矩阵,而原模型矩阵在最右边,先做模型变换再投影 ?
	m3dMatrixMultiply44(mModelViewProjection, viewFrustum.GetProjectionMatrix(), mModelView);

	GLfloat vBlack[] = { 1.0f, 1.0f, 1.0f, 1.0f };

	//选择要配置的渲染操作类型,非smooth,每种模式对应的参数要熟悉才能正确使用
	shaderManger.UseStockShader(GLT_SHADER_FLAT, mModelViewProjection, vBlack);//黑色背景?不是,是设置当前画笔颜色

	torusBatch.Draw();

	glutSwapBuffers();

	glutPostRedisplay();

	//整个流程是:先旋转在平移,然后进行投影剪裁,最后光栅化。UseStockShader 和draw函数之前的变换管线还是不清晰
}
开发者ID:wjingzhe,项目名称:OpenGL_SB5_static,代码行数:37,代码来源:ModelViewProjection_jingz.cpp

示例11:

CDescriptorSet * CFeatureExtractor::getDescriptors(const IplImage * pImage)
{
	CStopWatch s; s.startTimer();

	const int nChannels = pImage->nChannels;

	if(nChannels == 1)
	{
		pGreyImg = const_cast<IplImage *>(pImage);
	}
	else
	{
		CHECK(!pGreyImg, "Haven't created a grey image for corner detection");
		//cvCvtColor(pImage, pGreyImg, CV_RGB2GRAY);
		greyScaler.greyScale(pImage, pGreyImg);
	}

	CDescriptorSet * pDS = getDescriptors_int(pImage);

	s.stopTimer();
	REPEAT(20, cout << "Extract corners and describe features took " << s.getElapsedTime() << " seconds\n");

	return pDS;
}
开发者ID:JustineSurGithub,项目名称:tom-cv,代码行数:24,代码来源:featureExtractor.cpp

示例12: RenderScene

void RenderScene(void)
{
	static CStopWatch rotTimer;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	mvMatrix.PushMatrix(viewFrame);
		mvMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.0f, 0.0f, 1.0f, 0.0f);
		
		GLfloat vAmbientColor[] = { 0.1f, 0.1f, 0.1f, 1.0f };
		
		GLfloat vDiffuseColor[] = { 0.0f, 0.0f, 1.0f, 1.0f };
		
		GLfloat vSpecularColor[] = { 1.0f, 1.0f, 1.0f, 1.0f };

		GLfloat vEyeLight[] = { -100.0f, 100.0f, 100.0f };
		
		glUseProgram(ADSGouraudShader);

		glUniform4fv(locAC, 1, vAmbientColor);
		glUniform4fv(locDC, 1, vDiffuseColor);
		glUniform4fv(locSC, 1, vSpecularColor);
		glUniform3fv(locLP, 1, vEyeLight);

		glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeLine.GetModelViewProjectionMatrix());
		glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeLine.GetModelViewMatrix());
		glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeLine.GetNormalMatrix());


		sphereBatch.Draw();
	mvMatrix.PopMatrix();

	glutSwapBuffers();

	glutPostRedisplay();
}
开发者ID:wjingzhe,项目名称:OpenGL_SB5_static,代码行数:36,代码来源:ADSGouraud.cpp

示例13: 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);

		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(ADSDissloveShader);
		glUniform4fv(locAmbient, 1, vAmbientColor);
		glUniform4fv(locDiffuse, 1, vDiffuseColor);
		glUniform4fv(locSpecular, 1, vSpecularColor);
		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(locTexture, 1);

		float fFactor = fmod(rotTimer.GetElapsedSeconds(), 10.0f);
		fFactor /= 10.0f;
		glUniform1f(locDissolveFactor, fFactor);
    torusBatch.Draw();

    modelViewMatrix.PopMatrix();


    glutSwapBuffers();
	glutPostRedisplay();
	}
开发者ID:marblep,项目名称:OpenGL,代码行数:37,代码来源:Dissolve.cpp

示例14: main

int main(int argc, char *argv[])
{
    loadConfig();
	
    QSurfaceFormat format;
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    format.setProfile(QSurfaceFormat::CompatibilityProfile);
    QSurfaceFormat::setDefaultFormat(format);

    QApplication a(argc, argv);
    QZGeometryWindow w;
    QObject::connect(&w, SIGNAL(displayQtVersion()), &a, SLOT(aboutQt()));

    CStopWatch timer;
    timer.startTimer();
    g_engineWrapper.open();
    timer.stopTimer("-- Matlab Initialization time: ", " --");

    if (!w.initialize(mesh_list_name)) std::exit(-1);

    w.show();
	return a.exec();
}
开发者ID:sunyzm,项目名称:ZGeometry,代码行数:24,代码来源:main.cpp

示例15: 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.Translate(0.0f, 0.0f, 800.0f);
    modelViewMatrix.Rotate(-12.0, 1.0f, 0.0f, 0.0f);
    modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 15.0f, 0.0f, 1.0f, 0.0f);

    glUseProgram(grassShader);
    glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix());

    glBindVertexArray(vao);

    glDrawArraysInstancedARB(GL_TRIANGLE_STRIP, 0, 6, 1024 * 1024);

    modelViewMatrix.PopMatrix();

    glutSwapBuffers();
    glutPostRedisplay();
}
开发者ID:coolsee,项目名称:opengl,代码行数:25,代码来源:Grass.cpp


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