예제 #1
0
파일: main.cpp 프로젝트: duxing/GPUFinal
void display()
{
	if(lastTime == 0)
	{
		lastTime = glutGet(GLUT_ELAPSED_TIME);
	}
	now = glutGet(GLUT_ELAPSED_TIME);

	delta_t = (now - lastTime) / 1000.0f;
	//lastTime = now; //1 / delta_t here means the frame rate.

	fpsTracker.timestamp();
	//update camera information per frame
	updateCamera();
	checkClear();
	if(moved)
		lastTime = now;
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//do raytrace
	raytrace();
	
	//render result as texture
	displayTexture();
	//draw tool bar
	TwDraw();
	drawFps();

	glutSwapBuffers();
	glutPostRedisplay();
}
예제 #2
0
파일: main.cpp 프로젝트: duxing/SmokeSim
void onDrawCb()
{
	// Keep track of time
	theFpsTracker.timestamp();

	// Draw Scene and overlay
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	theCamera.draw();
	theSmokeSim.draw(theCamera);
	drawOverlay();
	glutSwapBuffers();
}
예제 #3
0
	void display(){
		theFpsTracker.timestamp();

		cudaEvent_t start, stop;
		float time;

		// Keep track of time
		cudaEventCreate(&start);
		cudaEventCreate(&stop);

		cudaEventRecord( start, 0 );

		runCuda();

		cudaEventRecord( stop, 0 );
		cudaEventSynchronize( stop );

		cudaEventElapsedTime( &time, start, stop );
		cudaEventDestroy( start );
		cudaEventDestroy( stop );

		char info[1024];
		sprintf(info, "565Raytracer | %i Iterations | Framerate : %3.1f fps | GPU Elapsed Time : %3.1f ms", iterations, theFpsTracker.fpsAverage(), time);
		string title(info);
		
		glutSetWindowTitle(title.c_str());

		glBindBuffer( GL_PIXEL_UNPACK_BUFFER, pbo);
		glBindTexture(GL_TEXTURE_2D, displayImage);
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, 
			  GL_RGBA, GL_UNSIGNED_BYTE, NULL);

		glClear(GL_COLOR_BUFFER_BIT);   

		// VAO, shader program, and texture already bound
		glDrawElements(GL_TRIANGLES, 6,  GL_UNSIGNED_SHORT, 0);

		glutPostRedisplay();
		glutSwapBuffers();
	}
예제 #4
0
파일: main.cpp 프로젝트: Jing-Qiu/JelloDemo
void onDrawCb()
{
    // Keep track of time
    theFpsTracker.timestamp();

    // Draw Scene and overlay
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    theCamera.draw();
    //drawAxes();

    vec3 cpos = theCamera.getPosition();
    float pos[4] = {cpos[0], cpos[1]+2.0, cpos[2],0.0};
    glLightfv(GL_LIGHT0, GL_POSITION, pos);

    theWorld.Draw();
    theJello.Draw(cpos);
    //drawOverlay();
    glutSwapBuffers();

	
}