예제 #1
0
파일: main.cpp 프로젝트: Jing-Qiu/JelloDemo
void drawOverlay()
{
  // Draw Overlay
  glColor4f(1.0, 1.0, 1.0, 1.0);
  glPushAttrib(GL_LIGHTING_BIT);
     glDisable(GL_LIGHTING);

     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluOrtho2D(0.0, 1.0, 0.0, 1.0);

     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
     glRasterPos2f(0.01, 0.01);
     
     char* intstr;
     switch (theJello.GetIntegrationType())
     {
     case JelloMesh::EULER: intstr = "Euler"; break;
     case JelloMesh::MIDPOINT: intstr = "Midpoint"; break;
     case JelloMesh::RK4: intstr = "RK4"; break;
     }

     char info[1024];
     sprintf(info, "Framerate: %3.1f %s %s", 
         theFpsTracker.fpsAverage(),
         intstr, isRecording? "(Recording ON)" : "");
 
     for (unsigned int i = 0; i < strlen(info); i++)
     {
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, info[i]);
     }
  glPopAttrib();
}
예제 #2
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();
}
예제 #3
0
파일: main.cpp 프로젝트: duxing/SmokeSim
void drawOverlay()
{
  // Draw Overlay
  glColor4f(1.0, 1.0, 1.0, 1.0);
  glPushAttrib(GL_LIGHTING_BIT);
     glDisable(GL_LIGHTING);

     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluOrtho2D(0.0, 1.0, 0.0, 1.0);

     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
     glRasterPos2f(0.01, 0.01);
     
     char info[1024];
     sprintf(info, "Framerate: %3.1f  |  Frame: %u  |  %s", 
         theFpsTracker.fpsAverage(), theSmokeSim.getTotalFrames(),
         theSmokeSim.isRecording()? "Recording..." : "");
 
     for (unsigned int i = 0; i < strlen(info); i++)
     {
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, info[i]);
     }
  glPopAttrib();
}
예제 #4
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();
}
예제 #5
0
파일: main.cpp 프로젝트: duxing/GPUFinal
void drawFps()
{
	glColor4f(1.0, 1.0, 0.0, 1.0);
	glPushAttrib(GL_LIGHTING_BIT);
	glDisable(GL_LIGHTING);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0.0, 1.0, 0.0, 1.0);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glRasterPos2f(0.01, 0.01);

	char info[1024];
	sprintf(info, "Render Frame Rate: %3.1f", 
		frame_num / delta_t);//fpsTracker.fpsAverage()
	for (unsigned int i = 0; i < strlen(info); i++)
	{
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, info[i]);
	}

	glRasterPos2f(0.01, 0.03);
	sprintf(info, "Display Frame Rate: %3.1f", 
		fpsTracker.fpsAverage());//
	for (unsigned int i = 0; i < strlen(info); i++)
	{
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, info[i]);
	}

	glRasterPos2f(0.01, 0.05);
	sprintf(info, "Total Frames: %3d", 
		frame_num);//
	for (unsigned int i = 0; i < strlen(info); i++)
	{
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, info[i]);
	}

	glRasterPos2f(0.01, 0.07);
	sprintf(info, "Total Time: %3.1f", 
		delta_t);//
	for (unsigned int i = 0; i < strlen(info); i++)
	{
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, info[i]);
	}

	glPopAttrib();
}
예제 #6
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();
	}
예제 #7
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();

	
}