Example #1
0
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();
}
Example #2
0
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();
}
Example #3
0
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();
}
Example #4
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();
	}