1 // License information.
2 // The Software "SAF BENCH" was written by Patrik.A, also known as Nitton Attiofyra
3 // on YouTube. (https://www.youtube.com/@NittonAttiofyra)
5 // The software is released in to the Public Domain and comes with no warranty and is used
8 // how to compile under linux.
9 // g++ saf_bench.cpp j35_draken.cpp tu_95.cpp bmp_alpha.cpp runway.cpp skybox1.cpp skybox2.cpp ground2.cpp digits.cpp menus.cpp -lglut -lGL -lGLU -o saf_bench
10 // how to compile under IRIX with MIPS4
11 // g++ saf_bench.cpp j35_draken.cpp tu_95.cpp bmp_alpha.cpp runway.cpp skybox1.cpp skybox2.cpp ground2.cpp digits.cpp menus.cpp -lglut -lGL -lGLU -mips4 -o saf_bench
13 #include <stdlib.h> // VS 2005 wont compile it if its noth placed here, need to investigate
27 //#include <Windows.h>
34 #include "j35_draken.h"
36 #include "bmp_alpha.h"
45 #define for if(0);else for // C2374 VC6++ on Alpha bug
49 static GLfloat rotX = 0; // rotate everything on the X axis
50 static GLfloat rotY = 0; // rotate everything on the Y axis
51 static GLfloat rotZ = 0; // rotate everything on the Z axis
52 static GLfloat transX = 0; // sets the zoom on X axis in viewport
53 static GLfloat transY = 0; // sets the zoom on Y axis in viewport
54 static GLfloat transZ = 0; // sets the zoom on Z axis in viewport
56 static GLfloat rot_worldX = 0; // rotate the world on the X axis
57 static GLfloat rot_worldY = 0; // rotate the world on the Y axis
58 static GLfloat rot_worldZ = 0; // rotate the world on the Z axis
59 static GLfloat trans_worldX = 0; // translates the world X axis
60 static GLfloat trans_worldY = 0; // translates the world Y axis
61 static GLfloat trans_worldZ = 0; // translates the world Z axis
63 static GLfloat rot_drakenX = 0; // rotate draken
64 static GLfloat rot_drakenY = 0; // rotate draken
65 static GLfloat rot_drakenZ = 0; // rotate draken
67 static GLfloat trans_drakenX = 0; // translate draken
68 static GLfloat trans_drakenY = 0; // translate draken
69 static GLfloat trans_drakenZ = 0; // translate draken
71 static GLfloat rot_tu95_X = 0; // translate TU-95
72 static GLfloat rot_tu95_Y = 0; // translate TU-95
73 static GLfloat rot_tu95_Z = 0; // translate TU-95
74 static GLfloat trans_tu95_X = 0; // translate TU-95
75 static GLfloat trans_tu95_Y = 0; // translate TU-95
76 static GLfloat trans_tu95_Z = 0; // translate TU-95
78 static GLfloat draken_velocity = 0; // J 35 Draken Velocity
80 static int ScreenWidth = 512; // windows width excluding boarders
81 static int ScreenHeight = 384; // windows hight excluding boarders
82 static int Pre_ScreenWidth; // store previous screen width, usfulle for toggeling fullscreen
83 static int Pre_ScreenHeight; // store previous screen higth, usfulle for toggeling fullscreen
84 static int fullscreen; // toggle fullscreen
85 static int res_mode = 4; // preset resolution modes
87 static int frames; // count every rendered frame
88 static int fps=0; // countes frames per second
89 extern int draken_wheels; // toggel landing gear visible or hidden
90 extern int draken_ab_on; // toggle afterburner on and off
91 extern int draken_contrail; // toggle contrail on or off
92 extern int draw_ground2; // draw ground2 or ground3
93 static int old_time = 0; // time passed in ms since last physics calcualtions
94 static int now_time = 0; // current time passed in ms
95 static int diff_time = 0; // difference in ms between time passed for previous physic calculation and start of current
96 static int scene = 0; // scene to render
97 static int scene_defaults = 0; // check if defaults are set for a scene
98 static int bench_start_time = 0; // when the demo started to run
99 extern GLfloat clouds_x; // move the clouds on X axis
100 extern GLfloat contrail_x[]; // contrails, TU-95
101 extern GLfloat contrail_draken_x []; // contrails, J-35 Draken
102 extern int menu; // keep track on what menu to render
103 extern GLfloat res_dial_w; // rotate the width resolution dialresolution dial
104 extern GLfloat res_dial_h; // rotate the height resolution dial
105 static int demo; // if = 1 then we are running a demo
106 static int frames_total; // total rendered frames during the benchmark
107 extern GLfloat check_pos; // settings check marker position
108 extern int draw_fps[]; // array that holds up to 5 digits that represents each digit in the FPS number
109 extern int draw_score[]; // array that holds up to 8 digits that represents each digit in the score number
110 int fps_i; // increments so every digit is saved in the fps array
111 static int score_i; // increments so every digit is saved in the score array
112 static int old_pos_x, old_pos_y; // save old X and Y window position, old glut forgets
115 static GLfloat light_position[4]; // light position (X,Y,Z,W) if W = 0 light is directional
116 static GLfloat light_ambient[4] = { .1, .1, .1, .1 };
119 // Mouse_lock is to make sure the left button is released before registering
120 // another button press. If we dont we will flipp back and fort betemen menus that have
121 // overlapping buttons
122 static int left_mouse_button, right_mouse_button, mouse_x_pos, mouse_y_pos, mouse_lock;
124 // change the checkmarker position for the resolution alternatives
125 void check_marker_pos()
129 case 0: check_pos = 0; break;
130 case 1: check_pos = 4.4; break;
131 case 2: check_pos = 8.85; break;
132 case 3: check_pos = 13.25; break;
133 case 4: check_pos = 17.7; break;
134 case 5: check_pos = 22.15; break;
135 case 6: check_pos = 26.6; break;
136 case 7: check_pos = 31; break;
140 // code to set resolutions
145 case 0: ScreenWidth = 320; ScreenHeight = 240; glutReshapeWindow(ScreenWidth, ScreenHeight);fullscreen = 0; break;
146 case 1: ScreenWidth = 400; ScreenHeight = 300; glutReshapeWindow(ScreenWidth, ScreenHeight);fullscreen = 0; break;
147 case 2: ScreenWidth = 512; ScreenHeight = 384; glutReshapeWindow(ScreenWidth, ScreenHeight);fullscreen = 0; break;
148 case 3: ScreenWidth = 640; ScreenHeight = 480; glutReshapeWindow(ScreenWidth, ScreenHeight);fullscreen = 0; break;
149 case 4: ScreenWidth = 800; ScreenHeight = 600; glutReshapeWindow(ScreenWidth, ScreenHeight);fullscreen = 0; break;
150 case 5: ScreenWidth = 1024; ScreenHeight = 768; glutReshapeWindow(ScreenWidth, ScreenHeight);fullscreen = 0; break;
151 case 6: ScreenWidth = 1280; ScreenHeight = 1024; glutReshapeWindow(ScreenWidth, ScreenHeight);fullscreen = 0; break;
154 // Window wont start at 0,0 and when it is its not full screen hight so we move it down 20 pixels
155 old_pos_x = (glutGet(GLUT_WINDOW_X)); // save old X window position, old glut forgets
156 old_pos_y = (glutGet(GLUT_WINDOW_Y)); // save old Y window position, old glut forgets
157 glutPositionWindow(0, 20);
159 old_pos_x = (glutGet(GLUT_WINDOW_X)); // save old X window position, old glut forgets
160 old_pos_y = (glutGet(GLUT_WINDOW_Y)); // save old Y window position, old glut forgets
163 Pre_ScreenWidth = ScreenWidth; // windows width excluding boarders
164 Pre_ScreenHeight = ScreenHeight; // windows hight excluding boarders
170 // convert score to separet digits
173 // set the first digit to 0 so it always renders, any higher digits sis set to 10 so they wont render.
183 // devide fps int into separete digits
185 while (frames_total > 0)
187 int digit2 = frames_total%10;
190 draw_score[score_i] = digit2;
195 // Save score to file with Time and Date
203 // current date/time based on current system
206 // convert now to string form
209 // write score to file
210 f = fopen("score.txt", "a+"); // open file, append
214 fprintf(f,"Resolution %d x %d\n", ScreenWidth, ScreenHeight); // prins resolution
215 fprintf(f,"Average FPS %.1f\n",frames_total / 107.5); // print the average frame rate
216 fprintf(f,"Score %d\n\n",frames_total);
217 fclose(f); // close file
221 fprintf(stderr,"\nThere was an error opening score.txt\n\n");
225 // rotate propellers and move contrails
226 void rotate_propellers()
228 r_propeller = r_propeller + (0.05 * diff_time);
229 // loop for drawing the 50 smoke puffs per contrail
230 for (int i = 0; i < 50; ++i)
232 contrail_x[i] = contrail_x[i] + (0.072 * diff_time); // exhaust speed of contrail
236 // move J-35 Draken contrails
237 void move_draken_contrail()
239 for (int i = 0; i < 50; ++i)
241 contrail_draken_x[i] = contrail_draken_x[i] + (0.072 * diff_time); // exhaust speed of contrail
245 // scroll the cloud and ground texture on the X axis
246 void scroll_clouds_X()
248 clouds_x = clouds_x + (0.0001 * diff_time);
251 // light position for menu
252 void light_position_menu()
254 // light position (X,Y,Z,W) if W = 0 light is directional
255 light_position[0] = 0; // X
256 light_position[1] = 0; // Y
257 light_position[2] = 1000; // Z
258 light_position[3] = 1; // W
261 // light position for skybox1
262 void light_position_skybox1()
264 // light position (X,Y,Z,W) if W = 0 light is directional
265 light_position[0] = 0; // X
266 light_position[1] = 10000; // Y
267 light_position[2] = 3500; // Z
268 light_position[3] = 1; // W
271 // light position for skybox2
272 void light_position_skybox2()
274 // light position (X,Y,Z,W) if W = 0 light is directional
275 light_position[0] = 100; // X
276 light_position[1] = 490; // Y
277 light_position[2] = -300; // Z
278 light_position[3] = 1; // W
281 // check for keyboard inputs
282 void NormalKeys(unsigned char key, int mouse_x, int mouse_y)
287 // if 'f' key is pressed go fullscreen
288 if ((fullscreen == 0) && (demo == 1))
290 res_mode = 7; // set res_mode to 7 that equals fullscreen
291 resolutions(); // run resolution code to set fullscreen
294 // if 'f' key is pressed and we are in demo mode, exit fullscreen and restor window size
295 if ((fullscreen == 1) && (demo == 1))
297 res_mode = 2; // set 512x384 as the windows resolution
298 resolutions(); // sets resolution
299 glutPositionWindow(old_pos_x, old_pos_y); // restore old window X and Y position
305 // if 'ESC' key(s) is pressed in fullscreen benchmark got back to main menu
306 if ((fullscreen == 1) && (demo == 0))
308 scene = 0; // sett scene to none existing scene zero
309 menu = 1; // goto main menu
310 frames_total = 0; // set score to zero
311 convert_score(); // show zero score
314 // if 'ESC' key is pressed in fullscreen demo mode, exit fullscreen and restor window size
315 if ((fullscreen == 1) && (demo == 1))
317 res_mode = 2; // set 512x384 as the windows resolution
318 resolutions(); // sets resolution
319 glutPositionWindow(old_pos_x, old_pos_y); // restore old window X and Y position
322 //if 'ESC' key is pressed and the program is running a scene in a window, exit to main menu
323 if ((scene > 0) && ( fullscreen == 0 ))
325 scene = 0; // sett scene to none existing scene zero
326 menu = 1; // goto main menu
327 frames_total = 0; // set score to zero
328 convert_score(); // show zero score
331 //if 'ESC" key is pressed and we are in the settings menu, go back to main menu
334 menu = 1; // goto main menu
338 //if 'ESC" key is pressed exit the program if we are in the main menu
339 if ((fullscreen == 0) && (menu == 1))
341 exit(0); // exit program
345 // Increase window size
347 if ((demo == 1) && (res_mode < 6) && (fullscreen == 0))
349 ++res_mode; // add 1 to res_model variable
350 resolutions(); // sets resolution
354 // Reduce Window Size
356 if ((demo == 1) && (res_mode > 0) && (fullscreen == 0))
358 --res_mode; // subracts 1 from res_model variable
359 resolutions(); // sets resolution
365 // grab mouse clicks and corsponding coordinates
366 void MouseClick(int mouse_button, int mouse_button_state, int mouse_x, int mouse_y)
368 if ((mouse_button == GLUT_LEFT_BUTTON) && (mouse_button_state == GLUT_DOWN))
370 left_mouse_button = 1;
371 mouse_x_pos = mouse_x;
372 mouse_y_pos = mouse_y;
374 else if ((mouse_button == GLUT_LEFT_BUTTON) && (mouse_button_state == GLUT_UP))
377 left_mouse_button = 0;
381 if ((mouse_button == GLUT_RIGHT_BUTTON) && (mouse_button_state == GLUT_DOWN))
383 right_mouse_button = 1;
385 else{right_mouse_button = 0;
389 // Calculate scenes and Menus every 5 ms
392 glutTimerFunc(5, timer, 0); // next Timer call milliseconds later
394 // kill the program if we dont have a glut Window.
395 // MacOS classis wont terminate the console if we use the close button on the window
396 if (glutGetWindow() == 0)exit(0);
398 // calculate time between frames
400 now_time = glutGet(GLUT_ELAPSED_TIME);
401 diff_time = now_time - old_time;
408 if (left_mouse_button == 1 && mouse_x_pos >= 32 && mouse_x_pos <= 257 && mouse_y_pos >= 290 && mouse_y_pos <= 325 && mouse_lock == 0)
410 scene = 1; // scene to render, 0 = no scene
411 menu = 0; // keep track on what menu to render
412 demo = 0; // if = 1 then we are running a demo
413 mouse_lock = 1; // make sure mouse button is released before registering another button press
414 resolutions(); // set the selected resolution
416 // run demo in a loop
417 else if (left_mouse_button == 1 && mouse_x_pos >= 354 && mouse_x_pos <= 482 && mouse_y_pos >= 290 && mouse_y_pos <= 326 && mouse_lock == 0)
419 scene = 1; // scene to render, 0 = no scene
420 menu = 0; // keep track on what menu to render
421 demo = 1; // if = 1 then we are running a demo
422 mouse_lock = 1; // make sure mouse button is released before registering another button press
423 resolutions(); // set the selected resolution
426 else if (left_mouse_button == 1 && mouse_x_pos >= 32 && mouse_x_pos <= 257 && mouse_y_pos >= 338 && mouse_y_pos <= 373 && mouse_lock == 0)
431 check_marker_pos(); // check marker indication selected resoltution in settings menu
434 else if (left_mouse_button == 1 && mouse_x_pos >= 354 && mouse_x_pos <= 482 && mouse_y_pos >= 338 && mouse_y_pos <= 373 && mouse_lock == 0)
436 exit(0); // exit the program
443 // OK button. Retrun to main menu
444 if (left_mouse_button == 1 && mouse_x_pos >= 177 && mouse_x_pos <= 339 && mouse_y_pos >= 339 && mouse_y_pos <= 373 && mouse_lock == 0)
451 else if (left_mouse_button == 1 && mouse_x_pos >= 15 && mouse_x_pos <= 47 && mouse_y_pos >= 39 && mouse_y_pos <= 62 && mouse_lock == 0)
457 else if (left_mouse_button == 1 && mouse_x_pos >= 15 && mouse_x_pos <= 47 && mouse_y_pos >= 75 && mouse_y_pos <= 99 && mouse_lock == 0)
463 else if (left_mouse_button == 1 && mouse_x_pos >= 15 && mouse_x_pos <= 47 && mouse_y_pos >= 111 && mouse_y_pos <= 133 && mouse_lock == 0)
469 else if (left_mouse_button == 1 && mouse_x_pos >= 15 && mouse_x_pos <= 47 && mouse_y_pos >= 147 && mouse_y_pos <= 171 && mouse_lock == 0)
475 else if (left_mouse_button == 1 && mouse_x_pos >= 15 && mouse_x_pos <= 47 && mouse_y_pos >= 182 && mouse_y_pos <= 207 && mouse_lock == 0)
481 else if (left_mouse_button == 1 && mouse_x_pos >= 15 && mouse_x_pos <= 47 && mouse_y_pos >= 218 && mouse_y_pos <= 242 && mouse_lock == 0)
487 else if (left_mouse_button == 1 && mouse_x_pos >= 15 && mouse_x_pos <= 47 && mouse_y_pos >= 252 && mouse_y_pos <= 278 && mouse_lock == 0)
493 else if (left_mouse_button == 1 && mouse_x_pos >= 15 && mouse_x_pos <= 47 && mouse_y_pos >= 290 && mouse_y_pos <= 315 && mouse_lock == 0)
504 //-----------------------------------------//
505 // if case 0 then menus are loaded and should always be 512x384 res
508 fullscreen = 0; // no fullscreen in menu mode
509 demo = 0; // if = 1 then we are running a demo
510 scene_defaults = 0; // make sure defaults are loaded when needed
526 if ((glutGet(GLUT_WINDOW_X) == 0) || (glutGet(GLUT_WINDOW_Y) == 0)){glutPositionWindow(old_pos_x, old_pos_y);}
528 // restore menu resolution to 512x384
529 ScreenWidth = 512; // windows width excluding boarders
530 ScreenHeight = 384; // windows hight excluding boarders
531 glutReshapeWindow(ScreenWidth, ScreenHeight); // changes window size
533 light_position_menu(); // set ligth position
535 // rotat the resolution dial clockwize for ever if we have no score
536 if ((draw_score[0] == 0) && (draw_score[1] == 10)) // rotate dail's if first and second digit in the score was not written to
543 //-----------------------------------------//
544 // Start of first J 35 Draken scene Physics
545 // setup scene defaults
547 if (scene_defaults == 0)
549 // Create array of 50 smoke puffs for the Draken and TU-95 contrail, evenly spaced 3.0 appart on X axis.
550 // No need to do it more then ocne peer loop of the demo.
551 for (int i = 0; i < 50; ++i)
553 contrail_draken_x[i] = i * 3; // exhaust speed of contrail
554 contrail_x[i] = i * 3; // exhaust speed of contrail
557 scene_defaults = 1; // sett to 1 so we only set defaults once
558 frames_total = 0; // reset total_total frames in case benchmark has been run before
578 draken_velocity = 0.3;
584 // set ligth position
585 light_position_skybox1();
587 //record when benchmark started
588 bench_start_time = glutGet(GLUT_ELAPSED_TIME);
590 // accelerate the plane
591 if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 7500)
593 draken_velocity = (draken_velocity + (0.00035 * diff_time ));
594 trans_worldX = trans_worldX - ((draken_velocity / 21) * diff_time);
597 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 7500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 9500)
599 rot_drakenZ = rot_drakenZ + (0.0021 * diff_time);
600 trans_worldX = trans_worldX - (0.13 * diff_time);
602 // lift off and gear up
603 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 9500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 11500)
607 trans_worldY = trans_worldY - (0.003 * diff_time);
609 trans_worldX = trans_worldX - (0.13 * diff_time);
611 // role to the left and glimb
612 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 11500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 15500)
617 trans_worldY = trans_worldY - (0.003 * diff_time);
618 rot_drakenX = rot_drakenX - (0.005 * diff_time);
619 trans_worldX = trans_worldX - (0.13 * diff_time);
621 // role rigth and pull up and increas clime rate
622 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 15500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 17500)
624 trans_worldY = trans_worldY - (0.007 * diff_time);
625 rot_drakenX = rot_drakenX + (0.005 * diff_time);
626 transZ = transZ - (0.00478 * diff_time);
627 rotY = rotY + (0.06 * diff_time);
628 rot_drakenZ = rot_drakenZ + (0.0286 * diff_time);
629 trans_drakenY = trans_drakenY + (0.0045 * diff_time);
630 trans_worldX = trans_worldX - (00.13 * diff_time);
632 // pull up even more for higher angle of attack for maximm climbe rate
633 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 17500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 18100)
635 trans_worldY = trans_worldY - (0.03 * diff_time);
636 trans_drakenY = trans_drakenY + (0.025 * diff_time);
637 rot_drakenX = rot_drakenX + (0.02 * diff_time);
638 rot_drakenZ = rot_drakenZ + (0.0286 * diff_time);
639 trans_worldX = trans_worldX - (0.13 * diff_time);
642 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 18100)
644 scene = 2; // goto scene 2
645 scene_defaults = 0; // make sure defaults are loaded
648 // End of first J 35 Draken scene Physics
650 //-----------------------------------------//
652 // Start of second J 35 Draken scene Physics
653 // setup scene defaults
655 if (scene_defaults == 0)
685 // set ligth position
686 //light_position_skybox1(); // same as previous scene
689 // Rotate the world and the Draken
690 if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 18100 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 22000)
692 rot_drakenZ = rot_drakenZ + (0.001 * diff_time);
693 trans_worldY = trans_worldY - (0.07 * diff_time);
694 trans_worldX = trans_worldX - (0.21 * diff_time);
696 // Rotate the world and the Draken
697 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 22000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 27000)
700 rotZ = rotZ + (-0.00025 * diff_time);
701 rot_worldX = rot_worldX + (0.00175 * diff_time);
702 rot_worldY = rot_worldY - (0.001 * diff_time);
703 rot_drakenZ = rot_drakenZ + (0.00075 * diff_time);
704 trans_worldX = trans_worldX - (0.21 * diff_time);
705 trans_worldY = trans_worldY - (0.07 * diff_time);
706 trans_worldZ = trans_worldZ - (0.01 * diff_time);
708 // Move the world and Zoom in on the plane
709 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 27000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 28400)
712 trans_worldX = trans_worldX - (0.21 * diff_time);
713 trans_worldY = trans_worldY - (0.07 * diff_time);
714 trans_worldZ = trans_worldZ - (0.01 * diff_time);
715 transZ = transZ + (0.0006 * diff_time);
718 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 28400)
720 scene = 3; // goto scene 3
721 scene_defaults = 0; // make sure defaults are loaded
724 // End of second J 35 Draken scene Physics
726 //-----------------------------------------//
728 // Start of first TU-95 scene Physics
729 // setup scene defaults
731 if (scene_defaults == 0)
758 // set ligth position
759 light_position_skybox2();
762 // Zoom in on the TU-95 Bear from above
763 if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 28400 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 35000)
765 transZ = transZ + (0.002 * diff_time);
767 // Rotate the world 200 degrees to view the plane from a top side angle
768 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 35000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 35500)
775 // Rotate Camera around the plane
776 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 35500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 48000)
778 rotY = rotY + (0.02 * diff_time);
779 rotX = rotX - (0.0065 * diff_time);
783 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 48000)
785 scene = 4; // goto scene 4
786 scene_defaults = 0; // make sure defaults are loaded
789 // rotat propellers routine
792 // rutine for moving the cloud textures
796 // End of first TU-95 scene Physics
798 //-----------------------------------------//
800 // Start of third J 35 Draken scene Physics
801 // setup scene defaults
803 if (scene_defaults == 0)
833 // set ligth position
834 //light_position_skybox2(); // same as previous scene
837 // Track the Draken passing by from the left to the rigth
838 if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 48000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 51000)
840 trans_drakenY = trans_drakenY + (0.02 * diff_time);
841 trans_drakenX = trans_drakenX + (0.04 * diff_time);
842 rotX = rotX - (0.007 * diff_time);
843 rotY = rotY - (0.004 * diff_time);
844 transZ = transZ + (0.007 * diff_time);
847 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 51000)
849 scene = 5; // goto scene 5
850 scene_defaults = 0; // make sure defaults are loaded
853 // rutine for moving the cloud textures
856 // move J-35 Draken contrail
857 move_draken_contrail();
860 // End of third J 35 Draken scene Physics
862 //-----------------------------------------//
864 // Start of first scene with Draken and TU-95
865 // setup scene defaults
867 if (scene_defaults == 0)
890 trans_drakenZ = -1.4;
905 // set ligth position
906 //light_position_skybox2(); // same as previous scene
909 // camera hugs the Draken rigth wing, draken aprotching TU-95 on its left side from the rear
910 if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 51000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 53000)
912 trans_tu95_X = trans_tu95_X - (0.02 * diff_time);
914 // camera rotatest to the rigth to track the TU-95
915 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 53000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 55000)
917 trans_tu95_X = trans_tu95_X - (0.015 * diff_time);
918 rotY = rotY + (0.007 * diff_time);
919 trans_drakenZ = trans_drakenZ - (0.0005 * diff_time);
921 // camera keeps rotatest to the rigth and pans up to track the TU-95
922 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 55000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 57000)
924 trans_tu95_X = trans_tu95_X - (0.01 * diff_time);
925 rotY = rotY + (0.007 * diff_time);
926 rotX = rotX - (0.004 * diff_time);
927 trans_drakenZ = trans_drakenZ - (0.0005 * diff_time);
928 trans_drakenY = trans_drakenY - (0.0002 * diff_time);
931 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 57000)
933 scene = 6; // goto scene 6
934 scene_defaults = 0; // make sure defaults are loaded
937 // rotat propellers routine
940 // rutine for moving the cloud textures
943 // move J-35 Draken contrail
944 move_draken_contrail();
947 // End of first Draken & TU-95 Physics Scenen
949 //-----------------------------------------//
951 // Start of second scene with Draken and TU-95
952 // setup scene defaults
954 if (scene_defaults == 0)
975 trans_drakenX = -120;
992 // set ligth position
993 //light_position_skybox2(); // same as previous scene
996 // Draken spotted from the TU-95 rigth wing, tracking Draken
997 if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 57000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 62000)
999 trans_drakenX = trans_drakenX + (0.02 * diff_time);
1000 rotX = rotX + (0.002 * diff_time);
1001 rotY = rotY + (0.002 * diff_time);
1003 // Draken spotted from the TU-95 rigth wing, tracking Draken
1004 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 62000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 65500)
1006 trans_drakenX = trans_drakenX + (0.015 * diff_time);
1007 rotX = rotX + (0.001 * diff_time);
1008 rotY = rotY + (0.015 * diff_time);
1012 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 65500)
1014 scene = 7; // goto scene 7
1015 scene_defaults = 0; // make sure defaults are loaded
1018 // rotat propellers routine
1019 rotate_propellers();
1021 // rutine for moving the cloud textures
1024 // move J-35 Draken contrail
1025 move_draken_contrail();
1028 // End of second Draken & TU-95 Physics Scenen
1030 //-----------------------------------------//
1032 // Start of third scene with Draken and TU-95
1033 // setup scene defaults
1035 if (scene_defaults == 0)
1057 trans_drakenY = -15;
1058 trans_drakenZ = -35;
1059 draken_velocity = 0;
1062 draken_contrail = 1;
1073 // set ligth position
1074 //light_position_skybox2(); // same as previous scene
1077 // Draken slowly climbind and rotating in to position next to TU-95 left side
1078 if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 65500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 68500)
1080 trans_drakenY = trans_drakenY + (0.002 * diff_time);
1081 trans_drakenX = trans_drakenX + (0.001 * diff_time);
1082 trans_drakenZ = trans_drakenZ + (0.0005 * diff_time);
1083 rot_drakenX = rot_drakenX + (0.006 * diff_time);
1084 trans_tu95_X = trans_tu95_X - (0.002 * diff_time);
1086 // Draken slowly climbind and rotating in to position next to TU-95 left side
1087 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 68500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 71500)
1089 trans_drakenY = trans_drakenY + (0.002 * diff_time);
1090 trans_drakenX = trans_drakenX + (0.001 * diff_time);
1091 trans_drakenZ = trans_drakenZ + (0.001 * diff_time);
1092 rot_drakenX = rot_drakenX + (0.002 * diff_time);
1093 trans_tu95_X = trans_tu95_X - (0.002 * diff_time);
1095 // Draken slowly climbind and rotating in to position next to TU-95 left side
1096 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 71500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 73000)
1101 trans_drakenY = trans_drakenY + (0.001 * diff_time);
1102 trans_drakenX = trans_drakenX + (0.001 * diff_time);
1103 trans_drakenZ = trans_drakenZ + (0.004 * diff_time);
1104 rot_drakenX = rot_drakenX - (0.007 * diff_time);
1105 trans_tu95_X = trans_tu95_X + (0.0005 * diff_time);
1107 // Draken slowly climbind and rotating in to position next to TU-95 left side
1108 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 73000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 74500)
1110 trans_drakenY = trans_drakenY + (0.001 * diff_time);
1111 trans_drakenX = trans_drakenX + (0.0008 * diff_time);
1112 trans_drakenZ = trans_drakenZ + (0.003 * diff_time);
1113 rot_drakenX = rot_drakenX - (0.014 * diff_time);
1114 trans_tu95_X = trans_tu95_X + (0.0003 * diff_time);
1116 // Rotate the world 220 degrees on Y axis to view the plane from a top side angle of 55 degres on X axis
1117 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 74500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 74750)
1126 trans_drakenZ = -35;
1130 // Rotate Camera around the planes
1131 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 74750 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 90000)
1133 rotY = rotY + (0.023 * diff_time);
1134 rotX = rotX - (0.0035 * diff_time);
1135 transZ = transZ + (0.001 * diff_time);
1138 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 90000)
1140 scene = 8; // goto scene 8
1141 scene_defaults = 0; // make sure defaults are loaded
1143 // routine for rotating the propellers
1144 rotate_propellers();
1146 // rutine for moving the cloud textures
1149 // move J-35 Draken contrail
1150 move_draken_contrail();
1153 // End of third Draken & TU-95 Physics Scenen
1155 //-----------------------------------------//
1157 // Start of second TU-95 scene
1158 // setup scene defaults
1160 if (scene_defaults == 0)
1187 // set ligth position
1188 //light_position_skybox2(); // same as previous scene
1191 // TU-95 roles to the rigth to start its rigth turn to head home to base
1192 if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 90000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 92000)
1194 rot_tu95_X = rot_tu95_X + (0.003 * diff_time);
1195 rot_tu95_Z = rot_tu95_Z + (0.0004 * diff_time);
1196 trans_tu95_X = trans_tu95_X - (0.0005 * diff_time);
1197 trans_tu95_Z = trans_tu95_Z + (0.0004 * diff_time);
1198 transZ = transZ - (0.0005 * diff_time);
1199 rotY = rotY - (0.0002 * diff_time);
1201 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 92000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 94000)
1203 rot_tu95_X = rot_tu95_X + (0.002 * diff_time);
1204 rot_tu95_Y = rot_tu95_Y - (0.0005 * diff_time);
1205 rot_tu95_Z = rot_tu95_Z + (0.0006 * diff_time);
1206 trans_tu95_X = trans_tu95_X - (0.0008 * diff_time);
1207 trans_tu95_Z = trans_tu95_Z + (0.0008 * diff_time);
1208 transZ = transZ - (0.001 * diff_time);
1209 rotY = rotY - (0.0004 * diff_time);
1211 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 94000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 95000)
1213 rot_tu95_X = rot_tu95_X + (0.001 * diff_time);
1214 rot_tu95_Y = rot_tu95_Y - (0.001 * diff_time);
1215 rot_tu95_Z = rot_tu95_Z + (0.0003 * diff_time);
1216 trans_tu95_X = trans_tu95_X - (0.0011 * diff_time);
1217 trans_tu95_Z = trans_tu95_Z + (0.0012 * diff_time);
1218 transZ = transZ - (0.0015 * diff_time);
1219 rotY = rotY - (0.0007 * diff_time);
1221 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 95000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 96000)
1223 rot_tu95_X = rot_tu95_X + (0.0008 * diff_time);
1224 rot_tu95_Y = rot_tu95_Y - (0.0015 * diff_time);
1225 rot_tu95_Z = rot_tu95_Z + (0.0002 * diff_time);
1226 trans_tu95_X = trans_tu95_X - (0.0014 * diff_time);
1227 trans_tu95_Z = trans_tu95_Z + (0.0016 * diff_time);
1228 transZ = transZ - (0.002 * diff_time);
1229 rotY = rotY - (0.0007 * diff_time);
1231 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 96000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 97000)
1233 rot_tu95_Y = rot_tu95_Y - (0.002 * diff_time);
1234 rot_tu95_Z = rot_tu95_Z + (0.00025 * diff_time);
1235 trans_tu95_X = trans_tu95_X - (0.002 * diff_time);
1236 trans_tu95_Z = trans_tu95_Z + (0.0024 * diff_time);
1237 transZ = transZ - (0.002 * diff_time);
1238 rotY = rotY - (0.001 * diff_time);
1240 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 97000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 100000)
1242 rot_tu95_Y = rot_tu95_Y - (0.0025 * diff_time);
1243 rot_tu95_Z = rot_tu95_Z + (0.0004 * diff_time);
1244 trans_tu95_X = trans_tu95_X - (0.0026 * diff_time);
1245 trans_tu95_Z = trans_tu95_Z + (0.003 * diff_time);
1246 transZ = transZ - (0.002 * diff_time);
1247 rotY = rotY - (0.001 * diff_time);
1249 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 100000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 104000)
1251 rot_tu95_Y = rot_tu95_Y - (0.003 * diff_time);
1252 rot_tu95_Z = rot_tu95_Z + (0.00050 * diff_time);
1253 trans_tu95_X = trans_tu95_X - (0.0034 * diff_time);
1254 trans_tu95_Z = trans_tu95_Z + (0.0038 * diff_time);
1255 transZ = transZ - (0.002 * diff_time);
1256 rotY = rotY - (0.0015 * diff_time);
1259 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 104000)
1261 scene = 9; // goto scene 1
1262 scene_defaults = 0; // make sure defaults are loaded
1265 // routine for rotating the propellers
1266 rotate_propellers();
1268 // rutine for moving the cloud textures
1272 // End of second TU-95 scene
1274 //-----------------------------------------//
1276 // Start of fourth scene with Draken and TU-95
1277 // setup scene defaults
1279 if (scene_defaults == 0)
1299 trans_drakenX = 0.5;
1301 trans_drakenZ = -35;
1302 draken_velocity = 0;
1305 draken_contrail = 1;
1316 // set ligth position
1317 //light_position_skybox2(); // same as previous scene
1320 // Draken roles to the left and disengaged the TU-95
1321 if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 104000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 106000)
1323 trans_tu95_X = trans_tu95_X - (0.0034 * diff_time);
1324 trans_tu95_Z = trans_tu95_Z + (0.0034 * diff_time);
1325 rot_tu95_Y = rot_tu95_Y - (0.002 * diff_time);
1326 rot_drakenX = rot_drakenX - (0.02 * diff_time);
1327 rot_drakenZ = rot_drakenZ + (0.003 * diff_time);
1328 trans_drakenZ = trans_drakenZ - (0.01 * diff_time);
1329 trans_drakenY = trans_drakenY + (0.0038 * diff_time);
1331 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 106000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 106500)
1333 trans_tu95_X = trans_tu95_X - (0.0034 * diff_time);
1334 trans_tu95_Z = trans_tu95_Z + (0.004 * diff_time);
1335 rot_tu95_Y = rot_tu95_Y - (0.002 * diff_time);
1336 rot_drakenX = rot_drakenX - (0.015 * diff_time);
1337 rot_drakenZ = rot_drakenZ + (0.003 * diff_time);
1338 trans_drakenZ = trans_drakenZ - (0.011 * diff_time);
1339 trans_drakenY = trans_drakenY + (0.0047 * diff_time);
1341 // Draken roles in to the camera
1342 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 106500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 107350)
1346 trans_tu95_X = trans_tu95_X - (0.0034 * diff_time);
1347 trans_tu95_Z = trans_tu95_Z + (0.005 * diff_time);
1348 rot_tu95_Y = rot_tu95_Y - (0.002 * diff_time);
1349 rot_drakenX = rot_drakenX - (0.01 * diff_time);
1350 rot_drakenZ = rot_drakenZ + (0.003 * diff_time);
1351 trans_drakenZ = trans_drakenZ - (0.013 * diff_time);
1352 trans_drakenY = trans_drakenY + (0.0052 * diff_time);
1354 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 107350 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 107500)
1356 trans_tu95_X = trans_tu95_X - (0.0034 * diff_time);
1357 trans_tu95_Z = trans_tu95_Z + (0.005 * diff_time);
1358 rot_tu95_Y = rot_tu95_Y - (0.002 * diff_time);
1359 rot_drakenX = rot_drakenX - (0.01 * diff_time);
1360 rot_drakenZ = rot_drakenZ + (0.003 * diff_time);
1361 trans_drakenZ = trans_drakenZ - (0.014 * diff_time);
1362 trans_drakenY = trans_drakenY + (0.0055 * diff_time);
1366 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 107500 && demo == 1)
1368 scene = 1; // sett scene to none existing scene zero
1369 menu = 0; // goto main menu
1370 scene_defaults = 0; // make sure defaults are loaded
1373 // collect benchmark data and goto main menu
1374 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 107500 && demo == 0)
1376 scene = 0; // sett scene to none existing scene zero
1377 res_dial_w = 5; // set width dail position 5 degres past 6'o clock in case we run some odd resolution
1378 res_dial_h = 5; // set height dail position 5 degres past 6'o clock in case we run some odd resolution
1380 // move the resolution dail's to indicate what valid resolution the benchmark ran at
1381 if (glutGet(GLUT_WINDOW_WIDTH) > 1280){res_dial_w = 345;} // if width resolution is above 1280 move dial to red area on resolution scale
1382 if (glutGet(GLUT_WINDOW_HEIGHT) > 1024){res_dial_h = 345;} // if higth resolution is above 1024 move dial to red area on resolution scale
1384 // move the width dial to the proper resolution on the scale
1385 switch(glutGet(GLUT_WINDOW_WIDTH))
1387 case 320: res_dial_w = 57; break;
1388 case 400: res_dial_w = 77; break;
1389 case 512: res_dial_w = 97; break;
1390 case 640: res_dial_w = 130; break;
1391 case 800: res_dial_w = 180; break;
1392 case 1024: res_dial_w = 240; break;
1393 case 1152: res_dial_w = 275; break;
1394 case 1280: res_dial_w = 305; break;
1396 // move the heigth dial to the proper resolution on the scale
1397 switch(glutGet(GLUT_WINDOW_HEIGHT))
1399 case 240: res_dial_h = 39; break;
1400 case 300: res_dial_h = 51; break;
1401 case 384: res_dial_h = 72; break;
1402 case 480: res_dial_h = 90; break;
1403 case 576: res_dial_h = 110; break;
1404 case 600: res_dial_h = 118; break;
1405 case 720: res_dial_h = 155; break;
1406 case 768: res_dial_h = 170; break;
1407 case 800: res_dial_h = 180; break;
1408 case 864: res_dial_h = 197; break;
1409 case 960: res_dial_h = 225; break;
1410 case 1024: res_dial_h = 240; break;
1413 menu = 1; // goto main menu
1414 scene_defaults = 0; // make sure defaults are loaded
1416 // Save the score to a file
1419 // convert score to individual digits so we can render them later
1423 // routine for rotating the propellers
1424 rotate_propellers();
1426 // rutine for moving the cloud textures
1429 // move J-35 Draken contrail
1430 move_draken_contrail();
1433 // End of fourth Draken & TU-95 Physics Scenen
1437 // set the backgorund color
1438 void background_color()
1440 glClearColor(0.424, 0.639, 0.725, 1);
1443 // Clears the current window and draws the benchmark.
1448 // set up the viewport and the screen size
1449 glViewport(0, 0, ScreenWidth,ScreenHeight );
1452 //get window resolution to maintain aspect ratio with gluPerspective and glOrtho
1453 ScreenWidth = glutGet(GLUT_WINDOW_WIDTH);
1454 ScreenHeight = glutGet(GLUT_WINDOW_HEIGHT);
1456 //set FOV, perspective, clipping and maintan aspect ratio
1457 glMatrixMode(GL_PROJECTION);
1460 gluPerspective(60,(float)ScreenWidth/ScreenHeight,1,2048);
1461 glMatrixMode(GL_MODELVIEW);
1463 glutPostRedisplay(); // Post re-paint request to activate display()
1465 // Set every pixel in the frame buffer to the current clear color.
1466 //clear the depth buffer
1467 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1469 glEnable(GL_DEPTH_TEST);
1472 //-----------------------------------------//
1476 menus(); // render menus
1477 if (menu == 1) render_score(); // render score in main menu
1480 if (demo == 0 && scene > 0 && res_mode != 7) // make sure resolution cant be changed during benchmarking
1486 if (ScreenWidth != 320 || ScreenHeight != 240)resolutions();
1489 if (ScreenWidth != 400 || ScreenHeight != 300)resolutions();
1492 if (ScreenWidth != 512 || ScreenHeight != 384)resolutions();
1495 if (ScreenWidth != 640 || ScreenHeight != 480)resolutions();
1498 if (ScreenWidth != 800 || ScreenHeight != 600)resolutions();
1501 if (ScreenWidth != 1024 || ScreenHeight != 768)resolutions();
1504 if (ScreenWidth != 1280 || ScreenHeight != 1024)resolutions();
1510 // Render Skybox1 in scene 1
1511 if (scene == 1 && scene_defaults == 1)
1513 // rotate and translate skybox
1515 glTranslatef (0 , 0 + trans_worldY , 0);
1516 glRotatef(rotX, 1, 0, 0);
1517 glRotatef(rotY, 0, 1, 0);
1518 glRotatef(rotZ, 0, 0, 1);
1519 skybox1(); // render skybox1
1524 // rotate and translate everything
1525 glTranslatef (0 + transX, 0 + transY, 0 + transZ);
1526 glRotatef(rotX, 1, 0, 0);
1527 glRotatef(rotY, 0, 1, 0);
1528 glRotatef(rotZ, 0, 0, 1);
1531 // rotate and translate the world but not the plane
1532 glTranslatef (0 + trans_worldX, 0 + trans_worldY, 0 + trans_worldZ);
1533 glRotatef(rot_worldX, 1, 0, 0);
1534 glRotatef(rot_worldY, 0, 1, 0);
1535 glRotatef(rot_worldZ, 0, 0, 1);
1536 if (scene == 1 && scene_defaults == 1)runway(); // render the runway, scene 1
1537 if (scene == 2 && scene_defaults == 1)ground2(); // render ground2, scene 2
1539 // render skybox2, scene 3, 4, 5, 6, 7 and 8
1540 if (scene_defaults == 1 && scene == 3 || scene == 4 || scene == 5 || scene == 6 || scene == 7 || scene == 8 || scene == 9)skybox2();
1545 // rotate and translate everything
1546 glTranslatef (0 + transX, 0 + transY, 0 + transZ);
1547 glRotatef(rotX, 1, 0, 0);
1548 glRotatef(rotY, 0, 1, 0);
1549 glRotatef(rotZ, 0, 0, 1);
1551 // rotate and translate J 35 Draken
1553 glTranslatef (0 + trans_drakenX, 0 + trans_drakenY, 0 + trans_drakenZ);
1554 glRotatef(rot_drakenX, 1, 0, 0);
1555 glRotatef(rot_drakenY, 0, 1, 0);
1556 glRotatef(rot_drakenZ, 0, 0, 1);
1558 // render the plane from j35_draken.cpp
1559 // render draken in scene 1, 2, 4, 5, 6 and 7
1560 if (scene_defaults == 1 && scene == 1 || scene == 2 || scene == 4 || scene == 5 || scene == 6 || scene == 7 || scene == 9)j35_draken();
1563 // rotate and translate TU-95
1565 glTranslatef (0 + trans_tu95_X, 0 + trans_tu95_Y, 0 + trans_tu95_Z);
1566 glRotatef(rot_tu95_X, 1, 0, 0);
1567 glRotatef(rot_tu95_Y, 0, 1, 0);
1568 glRotatef(rot_tu95_Z, 0, 0, 1);
1570 // render the plane from tu_95.cpp
1571 // render TU-95 in scene 3, 5, 6, 7 and 8
1572 if (scene_defaults == 1 && scene == 3 || scene == 5 || scene == 6 || scene == 7 || scene == 8 || scene == 9)tu_95();
1576 glLightfv(GL_LIGHT0, GL_POSITION, light_position);
1579 // render FPS counter
1580 glDisable(GL_DEPTH_TEST);
1581 if (scene > 0)render_fps();
1582 glEnable(GL_DEPTH_TEST);
1584 // alpha transperancy
1585 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1587 //we need to swap the frame buffer when we are running double buffering
1590 // Flush drawing command buffer to make drawing happen as soon as possible.
1594 ++frames; // add +1 to frame variable so we can count the number of frames rendered
1595 if (scene > 0)++frames_total; // add +1 to total number of rendered frames so we can computee a score later
1601 glutTimerFunc(1000, fps_timer, 0); // next Timer call milliseconds later
1605 // sett entrys in array to 10 so not to render any digits that is not part of the frame rate number
1612 // devide fps int into separete digits
1619 draw_fps[fps_i] = digit;
1624 // Initializes GLUT, the display mode, and main window; registers callbacks;
1625 // enters the main event loop.
1626 int main(int argc, char** argv)
1628 // set up the viewport and the screen size
1629 glViewport(0, 0, ScreenWidth,ScreenHeight );
1631 // Use a double buffered window in RGB mode
1633 glutInit(&argc, argv);
1636 putenv( (char *) "vblank_mode=0" ); // Disable Vsync in linux, AMD Intel
1637 putenv( (char *) "__GL_SYNC_TO_VBLANK=0" ); // Disable Vsync in linux, Nvidia
1639 putenv( (char *) "DECOUPLE_SWAPBUF y" ); // Disables swapbuffers sync to vertical blank
1642 // glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE); // antialasing, wont work with older glut but should work with newer freeglut
1643 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
1645 // Position window at 80,50 and give it a title.
1646 glutInitWindowPosition(80, 50);
1647 glutInitWindowSize(ScreenWidth, ScreenHeight);
1648 glutCreateWindow("SAF BENCH v1.3 by Patrik.A");
1650 // Tell GLUT that whenever the main window needs to be repainted that it
1651 // should call the function display().
1652 glutDisplayFunc(display);
1655 glEnable(GL_LIGHTING);
1656 glEnable(GL_LIGHT0);
1657 glEnable(GL_COLOR_MATERIAL);
1658 glEnable(GL_NORMALIZE);
1659 glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
1661 //set background color
1664 // glut mouse support
1665 glutMouseFunc(MouseClick);
1667 // glut keyboard support
1668 glutKeyboardFunc(NormalKeys);
1670 // time for physics and stuff
1671 glutTimerFunc(0, timer, 0);
1673 // update fps timer and terminal every
1674 glutTimerFunc(0, fps_timer, 0);
1687 // Turn off V-sync in windows
1688 typedef BOOL (WINAPI *PFNWGLSWAPINTERVALEXTPROC)(int interval);
1689 PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
1690 wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
1691 if(wglSwapIntervalEXT)
1692 wglSwapIntervalEXT(0); // 0 = Vsync off, 1 = Vsync on
1695 // Tell GLUT to start reading and processing events. This function
1696 // never returns; the program only exits when the user closes the main
1697 // window or kills the process.