void myDisplay(void) { int i; double FPS = CalFrequency(); printf("FPS = %f\n", FPS); glClear(GL_COLOR_BUFFER_BIT); // 创建透视效果视图 glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90.0f, 1.7f, 10.0f, 2000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, -500.0, 0.0, 1.0, 0.0); glBegin(GL_TRIANGLES); glVertex3f(0.0f, 0.0f, -200.0f); glVertex3f(100.0f, 0.0f, -200.0f); glVertex3f(100.0f, 100.0f, -200.0f); glEnd(); glFlush(); glutSwapBuffers(); }
void myDisplay(void) { double FPS = CalFrequency(); printf("FPS = %f\n", FPS); glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(75, 1, 1, 400000000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0, -200000000, 200000000, 0, 0, 0, 0, 0, 1); // 绘制红色的“太阳” glColor3f(1.0f, 0.0f, 0.0f); glutSolidSphere(69600000, 20, 20); // 绘制蓝色的“地球” glColor3f(0.0f, 0.0f, 1.0f); glRotatef(day / 360.0*360.0, 0.0f, 0.0f, -1.0f); glTranslatef(150000000, 0.0f, 0.0f); glutSolidSphere(15945000, 20, 20); // 绘制黄色的“月亮” glColor3f(1.0f, 1.0f, 0.0f); glRotatef(day / 30.0*360.0 - day / 360.0*360.0, 0.0f, 0.0f, -1.0f); glTranslatef(38000000, 0.0f, 0.0f); glutSolidSphere(4345000, 20, 20); glFlush(); glutSwapBuffers(); }
void display_FPS() { float x=-5,y=5,FS=1; int fps=CalFrequency(); int thousand=fps/1000; int hundred=(fps-thousand*1000)/100; int ten=(fps-thousand*1000-hundred*100)/10; int one=(fps-thousand*1000-hundred*100-ten*10)/1; //printf("fps=%f fps2=%d%d%d%d\n",CalFrequency(),thousand,hundred,ten,one); char c_thousand=thousand+48; char c_hundred=hundred+48; char c_ten=ten+48; char c_one=one+48; glColor3f(1, 1, 1); float gap=FS/6; printc('F', x, y, FS); x=x+gap; printc('P', x, y, FS); x=x+gap; printc('S', x, y, FS); x=x+gap; printc(' ', x, y, FS); x=x+gap; printc('=', x, y, FS); x=x+gap; printc(' ', x, y, FS); x=x+gap; printc(c_thousand, x, y, FS); x=x+gap; printc(c_hundred, x, y, FS); x=x+gap; printc(c_ten, x, y, FS); x=x+gap; printc(c_one, x, y, FS); x=x+gap; printc(' ', x, y, FS); x=x+gap; prints("Ver.beta", x, y, FS); glFlush(); }