glut输出文字

梦想游戏人
目录:
OpenGL

opengl不带输出文字api,可以用glut来实现

  • void myDisplay(void)
  • {
  • int a = clock();
  • glClear(GL_COLOR_BUFFER_BIT);
  • char *str = "FPS:60";
  • int n = strlen(str);
  • glRasterPos3f(-1, 0.95, 0.0);
  • for (int i = 0; i < n; i++)
  • glutBitmapCharacter(GLUT_BITMAP_9_BY_15, *(str + i));
  • glFlush();
  • cout << "FPS:" << 1000.0 / (clock() - a) << endl;
  • }
void myDisplay(void)
{
	int a = clock();
	glClear(GL_COLOR_BUFFER_BIT);
	char *str = "FPS:60";
	int n = strlen(str);
	glRasterPos3f(-1, 0.95, 0.0);
	for (int i = 0; i < n; i++)
		glutBitmapCharacter(GLUT_BITMAP_9_BY_15, *(str + i));

	glFlush();
	cout << "FPS:" << 1000.0 / (clock() - a) << endl;
}
Scroll Up