automatic download of data files
[safbench] / saf_bench.cpp
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)
4
5 // The software is released in to the Public Domain and comes with no warranty and is used
6 // at your own risk!
7
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
12
13 #include <stdlib.h> // VS 2005 wont compile it if its noth placed here, need to investigate
14 #ifdef macintosh
15 #include <glut.h>
16 #include <gl.h>
17 #include <glu.h>
18 #else
19 #include <GL/glut.h>
20 #include <GL/gl.h>
21 #include <GL/glu.h>
22 #endif
23
24 #include <iostream>
25 #include <string>
26 #ifdef _WIN32
27 //#include <Windows.h>
28 #include "wglext.h"
29 #else
30 #include <unistd.h>
31 #endif
32 #include "menus.h"
33 #include "digits.h"
34 #include "j35_draken.h"
35 #include "tu_95.h"
36 #include "bmp_alpha.h"
37 #include "runway.h"
38 #include "skybox1.h"
39 #include "skybox2.h"
40 #include "ground2.h"
41 #include <stdio.h>
42 #include <cstring>
43 #include <time.h>
44
45 #define for if(0);else for                              // C2374 VC6++ on Alpha bug
46
47 using namespace std;
48
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
55
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
62
63 static GLfloat rot_drakenX = 0;                 // rotate draken
64 static GLfloat rot_drakenY = 0;                 // rotate draken
65 static GLfloat rot_drakenZ = 0;                 // rotate draken
66
67 static GLfloat trans_drakenX = 0;               // translate draken
68 static GLfloat trans_drakenY = 0;               // translate draken
69 static GLfloat trans_drakenZ = 0;               // translate draken
70
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
77
78 static GLfloat draken_velocity = 0;             // J 35 Draken Velocity
79
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
86
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
113
114 // light stuff
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 };
117
118 // mouse stuff
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;
123
124 // change the checkmarker position for the resolution alternatives
125 void check_marker_pos()
126 {
127         switch(res_mode)
128         {
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;
137         }
138 }
139
140 // code to set resolutions
141 void resolutions()
142 {
143         switch(res_mode)
144         {
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;
152         case 7:
153 #ifdef macintosh
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);
158 #else
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
161 #endif
162                         fullscreen = 1;
163                         Pre_ScreenWidth = ScreenWidth;                  // windows width excluding boarders
164                         Pre_ScreenHeight = ScreenHeight;                // windows hight excluding boarders
165                         glutFullScreen();
166                         break;
167         }
168 }
169
170 // convert score to separet digits
171 void convert_score()
172 {
173         // set the first digit to 0 so it always renders, any higher digits sis set to 10 so they wont render.
174         draw_score[0] = 0;
175         draw_score[1] = 10;
176         draw_score[2] = 10;
177         draw_score[3] = 10;
178         draw_score[4] = 10;
179         draw_score[5] = 10;
180         draw_score[6] = 10;
181         draw_score[7] = 10;
182
183         // devide fps int into separete digits
184         score_i = 0;
185         while (frames_total > 0)
186         {
187                 int digit2 = frames_total%10;
188                 frames_total /= 10;
189                 //print digit2
190                 draw_score[score_i] = digit2;
191                 score_i++;
192         }
193 }
194
195 // Save score to file with Time and Date
196 void save_score()
197 {
198         // get date and time
199         char* dt;
200         time_t now;
201         struct tm* gmtm;
202         FILE *f;
203         // current date/time based on current system
204         now = time(0);
205
206         // convert now to string form
207         dt = ctime(&now);
208
209         // write score to file
210         f = fopen("score.txt", "a+");                                                                                   // open file, append
211         if(f!=NULL)
212         {
213                 fprintf(f,"%s",dt);
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
218         }
219         else
220         {
221                 fprintf(stderr,"\nThere was an error opening score.txt\n\n");
222         }
223 }
224
225 // rotate propellers and move contrails
226 void rotate_propellers()
227 {
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)
231         {
232                 contrail_x[i] = contrail_x[i] + (0.072 * diff_time);                            // exhaust speed of contrail
233         }
234 }
235
236 // move J-35 Draken contrails
237 void move_draken_contrail()
238 {
239         for (int i = 0; i < 50; ++i)
240         {
241                 contrail_draken_x[i] = contrail_draken_x[i] + (0.072 * diff_time);      // exhaust speed of contrail
242         }
243 }
244
245 // scroll the cloud and ground texture on the X axis
246 void scroll_clouds_X()
247 {
248         clouds_x = clouds_x + (0.0001 * diff_time);
249 }
250
251 // light position for menu
252 void light_position_menu()
253 {
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
259 }
260
261 // light position for skybox1
262 void light_position_skybox1()
263 {
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
269 }
270
271 // light position for skybox2
272 void light_position_skybox2()
273 {
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
279 }
280
281 // check for keyboard inputs
282 void NormalKeys(unsigned char key, int mouse_x, int mouse_y)
283 {
284         switch(key)
285         {
286         case 'f':
287                 // if 'f' key is pressed go fullscreen
288                 if ((fullscreen == 0) && (demo == 1))
289                 {
290                         res_mode = 7;                                                                   // set res_mode to 7 that equals fullscreen
291                         resolutions();                                                                  // run resolution code to set fullscreen
292                         break;
293                 }
294                 // if 'f' key is pressed and we are in demo mode, exit fullscreen and restor window size
295                 if ((fullscreen == 1) && (demo == 1))
296                 {
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
300                         break;
301                 }
302                 break;
303
304         case 27:
305                 // if 'ESC' key(s) is pressed in fullscreen benchmark got back to main menu
306                 if ((fullscreen == 1) && (demo == 0))
307                 {
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
312                         break;
313                 }
314                 // if 'ESC' key is pressed in fullscreen demo mode, exit fullscreen and restor window size
315                 if ((fullscreen == 1) && (demo == 1))
316                 {
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
320                         break;
321                 }
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 ))
324                 {
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
329                         break;
330                 }
331                 //if 'ESC" key is pressed  and we are in the settings menu, go back to main menu
332                 if (menu == 2)
333                 {
334                         menu = 1;                                                                               // goto main menu
335                         break;
336                 }
337
338                 //if 'ESC" key is pressed exit the program if we are in the main menu
339                 if ((fullscreen == 0) && (menu == 1))
340                 {
341                         exit(0);                                                                                // exit program
342                 }
343                 break;
344
345                 // Increase window size
346         case '+':
347                 if ((demo == 1) && (res_mode < 6) && (fullscreen  == 0))
348                 {
349                         ++res_mode;                                                                     // add 1 to res_model variable
350                         resolutions();                                                                  // sets resolution
351                 }
352                 break;
353
354                 // Reduce Window Size
355         case '-':
356                 if ((demo == 1) && (res_mode > 0) && (fullscreen  == 0))
357                 {
358                         --res_mode;                                                                             // subracts 1 from res_model variable
359                         resolutions();                                                                  // sets resolution
360                 }
361                 break;
362         }
363 }
364
365 // grab mouse clicks and corsponding coordinates
366 void MouseClick(int mouse_button, int mouse_button_state, int mouse_x, int mouse_y)
367 {
368         if ((mouse_button == GLUT_LEFT_BUTTON) && (mouse_button_state == GLUT_DOWN))
369         {
370                 left_mouse_button = 1;
371                 mouse_x_pos = mouse_x;
372                 mouse_y_pos = mouse_y;
373         }
374         else if ((mouse_button == GLUT_LEFT_BUTTON) && (mouse_button_state == GLUT_UP))
375         {
376                 mouse_lock = 0;
377                 left_mouse_button = 0;
378                 mouse_x_pos = 0;
379                 mouse_y_pos = 0;
380         }
381         if ((mouse_button ==  GLUT_RIGHT_BUTTON) && (mouse_button_state == GLUT_DOWN))
382         {
383                 right_mouse_button = 1;
384         }
385         else{right_mouse_button = 0;
386         }
387 }
388
389 // Calculate scenes and Menus every 5 ms
390 void timer(int)
391 {
392         glutTimerFunc(5, timer, 0);     // next Timer call milliseconds later
393
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);
397
398         // calculate time between frames
399         old_time = now_time;
400         now_time = glutGet(GLUT_ELAPSED_TIME);
401         diff_time = now_time - old_time;
402
403         switch(menu)
404         {
405                 // Main menu, 1
406         case 1:
407                 // run benchmark
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)
409                 {
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
415                 }
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)
418                 {
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
424                 }
425                 // settings menu
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)
427                 {
428                         scene = 0;
429                         menu = 2;
430                         mouse_lock = 1;
431                         check_marker_pos();                                             // check marker indication selected resoltution in settings menu
432                 }
433                 // quit the program
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)
435                 {
436                         exit(0);                                                                // exit the program
437                 }
438                 break;
439
440                 // settings menu
441         case 2:
442                 check_marker_pos();
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)
445                 {
446                         scene = 0;
447                         menu = 1;
448                         mouse_lock = 1;
449                 }
450                 // 320x240
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)
452                 {
453                         res_mode = 0;
454                         mouse_lock = 1;
455                 }
456                 // 400x300
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)
458                 {
459                         res_mode = 1;
460                         mouse_lock = 1;
461                 }
462                 // 512x384
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)
464                 {
465                         res_mode = 2;
466                         mouse_lock = 1;
467                 }
468                 // 640x480
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)
470                 {
471                         res_mode = 3;
472                         mouse_lock = 1;
473                 }
474                 // 800x600
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)
476                 {
477                         res_mode = 4;
478                         mouse_lock = 1;
479                 }
480                 // 1024x768
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)
482                 {
483                         res_mode = 5;
484                         mouse_lock = 1;
485                 }
486                 // 1280x1024
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)
488                 {
489                         res_mode = 6;
490                         mouse_lock = 1;
491                 }
492                 // 1600x1200
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)
494                 {
495                         res_mode = 7;
496                         mouse_lock = 1;
497                 }
498                 break;
499         }
500
501         // scenes
502         switch(scene)
503         {
504                 //-----------------------------------------//
505                 // if case 0 then menus are loaded and should always be 512x384 res
506         case 0:
507
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
511
512                 // reset coordinates
513                 transX = 0;
514                 transY = 0;
515                 transZ = 0;
516                 rotX = 0;
517                 rotY = 0;
518                 rotZ = 0;
519                 rot_worldX = 0;
520                 rot_worldY = 0;
521                 rot_worldZ = 0;
522                 trans_worldX = 0;
523                 trans_worldY = 0;
524                 trans_worldZ = 0;
525
526                 if ((glutGet(GLUT_WINDOW_X) == 0) || (glutGet(GLUT_WINDOW_Y) == 0)){glutPositionWindow(old_pos_x, old_pos_y);}
527
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
532
533                 light_position_menu();                                                          // set ligth position
534
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
537                 {
538                         res_dial_h++;
539                         res_dial_w+=2;
540                 }
541                 break;
542
543                 //-----------------------------------------//
544                 // Start of first J 35 Draken scene Physics
545                 // setup scene defaults
546         case 1:
547                 if (scene_defaults == 0)
548                 {
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)
552                         {
553                                 contrail_draken_x[i] = i * 3;   // exhaust speed of contrail
554                                 contrail_x[i] = i * 3;                  // exhaust speed of contrail
555                         }
556
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
559
560                         transX = 0;
561                         transY = 0;
562                         transZ = -16;
563                         rotX = 24;
564                         rotY = -30;
565                         rotZ = 0;
566                         rot_worldX = 0;
567                         rot_worldY = 0;
568                         rot_worldZ = 0;
569                         trans_worldX = 980;
570                         trans_worldY = -0.3;
571                         trans_worldZ = 0;
572                         rot_drakenX = 0;
573                         rot_drakenY = 0;
574                         rot_drakenZ = 0;
575                         trans_drakenX = 0;
576                         trans_drakenY = 0;
577                         trans_drakenZ = 0;
578                         draken_velocity = 0.3;
579                         draken_wheels = 1;
580                         draken_ab_on = 1;
581                         draken_contrail = 0;
582                         draw_ground2 = 1;
583
584                         // set ligth position
585                         light_position_skybox1();
586
587                         //record when benchmark started
588                         bench_start_time = glutGet(GLUT_ELAPSED_TIME);
589                 }
590                 // accelerate the plane
591                 if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 7500)
592                 {
593                         draken_velocity = (draken_velocity + (0.00035 * diff_time ));
594                         trans_worldX = trans_worldX - ((draken_velocity / 21) * diff_time);
595                 }
596                 // V1 rotate
597                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 7500 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 9500)
598                 {
599                         rot_drakenZ = rot_drakenZ + (0.0021 * diff_time);
600                         trans_worldX = trans_worldX - (0.13 * diff_time);
601                 }
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)
604                 {
605                         rotY = 90;
606                         rotZ = 20;
607                         trans_worldY = trans_worldY - (0.003 * diff_time);
608                         draken_wheels = 0;
609                         trans_worldX = trans_worldX - (0.13 * diff_time);
610                 }
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)
613                 {
614                         rotX = 0;
615                         rotY = -30;
616                         rotZ = 0;
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);
620                 }
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)
623                 {
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);
631                 }
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)
634                 {
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);
640                 }
641                 // Goto Scene 2
642                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 18100)
643                 {
644                         scene = 2;              // goto scene 2
645                         scene_defaults = 0;     // make sure defaults are loaded
646                 }
647                 break;
648                 // End of first J 35 Draken scene Physics
649
650                 //-----------------------------------------//
651
652                 // Start of second J 35 Draken scene Physics
653                 // setup scene defaults
654         case 2:
655                 if (scene_defaults == 0)
656                 {
657                         scene_defaults = 1;
658
659                         transX = 0;
660                         transY = 0;
661                         transZ = 0;
662                         rotX = 10;
663                         rotX = 0;
664                         rotY = -90;
665                         rotZ = -70;
666                         transZ = -13;
667                         rot_worldX = 0;
668                         rot_worldY = 0;
669                         rot_worldZ = 0;
670                         trans_worldX = 600;
671                         trans_worldY = -50;
672                         trans_worldZ = 0;
673                         rot_drakenX = 0;
674                         rot_drakenY = 0;
675                         rot_drakenZ = 50;
676                         trans_drakenX = 0;
677                         trans_drakenY = 0;
678                         trans_drakenZ = 0;
679                         draken_velocity = 0;
680                         draken_wheels = 0;
681                         draken_ab_on = 0;
682                         draken_contrail = 0;
683                         draw_ground2 = 1;
684
685                         // set ligth position
686                         //light_position_skybox1();     // same as previous scene
687                 }
688
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)
691                 {
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);
695                 }
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)
698                 {
699                         draw_ground2 = 0;
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);
707                 }
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)
710                 {
711                         draw_ground2 = 0;
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);
716                 }
717                 // Goto Scene 3
718                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 28400)
719                 {
720                         scene = 3;              // goto scene 3
721                         scene_defaults = 0;     // make sure defaults are loaded
722                 }
723                 break;
724                 // End of second J 35 Draken scene Physics
725
726                 //-----------------------------------------//
727
728                 // Start of first TU-95 scene Physics
729                 // setup scene defaults
730         case 3:
731                 if (scene_defaults == 0)
732                 {
733                         scene_defaults = 1;
734
735                         transX = 0;
736                         transY = 0;
737                         transZ = 0;
738                         rotX = 10;
739                         rotX = 90;
740                         rotY = 90;
741                         rotZ = 0;
742                         rot_worldX = 0;
743                         rot_worldY = 0;
744                         rot_worldZ = 0;
745                         transZ = -64;
746                         trans_worldX = 0;
747                         trans_worldY = 0;
748                         trans_worldZ = 0;
749                         rot_tu95_X = 0;
750                         rot_tu95_Y = 0;
751                         rot_tu95_Z = 0;
752                         trans_tu95_X = 6;
753                         trans_tu95_Y = 0;
754                         trans_tu95_Z = 0;
755                         clouds_x = 0;
756                         r_propeller = 0;
757
758                         // set ligth position
759                         light_position_skybox2();
760                 }
761
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)
764                 {
765                         transZ = transZ + (0.002 * diff_time);
766                 }
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)
769                 {
770                         rotX = 35;
771                         rotY = 200;
772                         rotZ = 0;
773                         transZ = -60;
774                 }
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)
777                 {
778                         rotY = rotY + (0.02 * diff_time);
779                         rotX = rotX - (0.0065 * diff_time);
780                         transZ = -60;
781                 }
782                 // go to scene 4
783                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 48000)
784                 {
785                         scene = 4;              // goto scene 4
786                         scene_defaults = 0;     // make sure defaults are loaded
787                 }
788
789                 // rotat propellers routine
790                 rotate_propellers();
791
792                 // rutine for moving the cloud textures
793                 scroll_clouds_X();
794
795                 break;
796                 // End of first TU-95 scene Physics
797
798                 //-----------------------------------------//
799
800                 // Start of third J 35 Draken scene Physics
801                 // setup scene defaults
802         case 4:
803                 if (scene_defaults == 0)
804                 {
805                         scene_defaults = 1;
806
807                         transX = 0;
808                         transY = 0;
809                         transZ = 0;
810                         rotX = 10;
811                         rotX = 35;
812                         rotY = 190;
813                         rotZ = 0;
814                         rot_worldX = 0;
815                         rot_worldY = 0;
816                         rot_worldZ = 0;
817                         transZ = 50;
818                         trans_worldX = 0;
819                         trans_worldY = 100;
820                         trans_worldZ = -80;
821                         rot_drakenX = 0;
822                         rot_drakenY = 0;
823                         rot_drakenZ = 20;
824                         trans_drakenX = -80;
825                         trans_drakenY = -80;
826                         trans_drakenZ = 100;
827                         draken_velocity = 0;
828                         draken_wheels = 0;
829                         draken_ab_on = 1;
830                         draken_contrail = 1;
831                         clouds_x = 0;
832
833                         // set ligth position
834                         //light_position_skybox2();     // same as previous scene
835                 }
836
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)
839                 {
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);
845                 }
846                 // go to scene 5
847                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 51000)
848                 {
849                         scene = 5;              // goto scene 5
850                         scene_defaults = 0;     // make sure defaults are loaded
851                 }
852
853                 // rutine for moving the cloud textures
854                 scroll_clouds_X();
855
856                 // move J-35 Draken contrail
857                 move_draken_contrail();
858
859                 break;
860                 // End of third J 35 Draken scene Physics
861
862                 //-----------------------------------------//
863
864                 // Start of first scene with Draken and TU-95
865                 // setup scene defaults
866         case 5:
867                 if (scene_defaults == 0)
868                 {
869                         scene_defaults = 1;
870
871                         transX = 0;
872                         transY = 0;
873                         transZ = 0;
874                         rotX = 10;
875                         rotX = 0;
876                         rotY = 90;
877                         rotZ = 2;
878                         rot_worldX = 0;
879                         rot_worldY = 0;
880                         rot_worldZ = 0;
881                         transZ = -5;
882                         trans_worldX = 0;
883                         trans_worldY = 0;
884                         trans_worldZ = 0;
885                         rot_drakenX = 0;
886                         rot_drakenY = 0;
887                         rot_drakenZ = 0;
888                         trans_drakenX = -0;
889                         trans_drakenY = -4;
890                         trans_drakenZ = -1.4;
891                         draken_velocity = 0;
892                         draken_wheels = 0;
893                         draken_ab_on = 0;
894                         draken_contrail = 0;
895                         rot_tu95_X = 0;
896                         rot_tu95_Y = 0;
897                         rot_tu95_Z = 0;
898                         trans_tu95_X = 150;
899                         trans_tu95_Y = 15;
900                         trans_tu95_Z = 50;
901                         clouds_x = 0;
902                         r_propeller = 0;
903                         clouds_x = 0;
904
905                         // set ligth position
906                         //light_position_skybox2();     // same as previous scene
907                 }
908
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)
911                 {
912                         trans_tu95_X = trans_tu95_X - (0.02 * diff_time);
913                 }
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)
916                 {
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);
920                 }
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)
923                 {
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);
929                 }
930                 // go to scene 1
931                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 57000)
932                 {
933                         scene = 6;              // goto scene 6
934                         scene_defaults = 0;     // make sure defaults are loaded
935                 }
936
937                 // rotat propellers routine
938                 rotate_propellers();
939
940                 // rutine for moving the cloud textures
941                 scroll_clouds_X();
942
943                 // move J-35 Draken contrail
944                 move_draken_contrail();
945
946                 break;
947                 // End of first Draken & TU-95 Physics Scenen
948
949                 //-----------------------------------------//
950
951                 // Start of second scene with Draken and TU-95
952                 // setup scene defaults
953         case 6:
954                 if (scene_defaults == 0)
955                 {
956                         scene_defaults = 1;
957
958                         transX = 0;
959                         transY = 0;
960                         transZ = 0;
961                         rotX = 10;
962                         rotX = 20;
963                         rotY = -40;
964                         rotZ = 0;
965                         rot_worldX = 0;
966                         rot_worldY = 0;
967                         rot_worldZ = 0;
968                         transZ = 1.5;
969                         trans_worldX = 0;
970                         trans_worldY = 0;
971                         trans_worldZ = 0;
972                         rot_drakenX = 0;
973                         rot_drakenY = 0;
974                         rot_drakenZ = 0;
975                         trans_drakenX = -120;
976                         trans_drakenY = -30;
977                         trans_drakenZ = -50;
978                         draken_velocity = 0;
979                         draken_wheels = 0;
980                         draken_ab_on = 0;
981                         draken_contrail = 1;
982                         rot_tu95_X = 0;
983                         rot_tu95_Y = 0;
984                         rot_tu95_Z = 0;
985                         trans_tu95_X = -12;
986                         trans_tu95_Y = -0.5;
987                         trans_tu95_Z = 0;
988                         clouds_x = 0;
989                         r_propeller = 0;
990                         clouds_x = 0;
991
992                         // set ligth position
993                         //light_position_skybox2();     // same as previous scene
994                 }
995
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)
998                 {
999                         trans_drakenX = trans_drakenX + (0.02 * diff_time);
1000                         rotX = rotX + (0.002 * diff_time);
1001                         rotY = rotY + (0.002 * diff_time);
1002                 }
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)
1005                 {
1006                         trans_drakenX = trans_drakenX + (0.015 * diff_time);
1007                         rotX = rotX + (0.001 * diff_time);
1008                         rotY = rotY + (0.015 * diff_time);
1009                 }
1010
1011                 // go to scene 1
1012                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 65500)
1013                 {
1014                         scene = 7;                      // goto scene 7
1015                         scene_defaults = 0;     // make sure defaults are loaded
1016                 }
1017
1018                 // rotat propellers routine
1019                 rotate_propellers();
1020
1021                 // rutine for moving the cloud textures
1022                 scroll_clouds_X();
1023
1024                 // move J-35 Draken contrail
1025                 move_draken_contrail();
1026
1027                 break;
1028                 // End of second Draken & TU-95 Physics Scenen
1029
1030                 //-----------------------------------------//
1031
1032                 // Start of third scene with Draken and TU-95
1033                 // setup scene defaults
1034         case 7:
1035                 if (scene_defaults == 0)
1036                 {
1037                         scene_defaults = 1;
1038
1039                         transX = 0;
1040                         transY = 0;
1041                         transZ = 0;
1042                         rotX = 10;
1043                         rotX = 0;
1044                         rotY = 190;
1045                         rotZ = 0;
1046                         rot_worldX = 0;
1047                         rot_worldY = 0;
1048                         rot_worldZ = 0;
1049                         transZ = -60;
1050                         trans_worldX = 0;
1051                         trans_worldY = 0;
1052                         trans_worldZ = 0;
1053                         rot_drakenX = 0;
1054                         rot_drakenY = 0;
1055                         rot_drakenZ = 0;
1056                         trans_drakenX = 0;
1057                         trans_drakenY = -15;
1058                         trans_drakenZ = -35;
1059                         draken_velocity = 0;
1060                         draken_wheels = 0;
1061                         draken_ab_on = 0;
1062                         draken_contrail = 1;
1063                         rot_tu95_X = 0;
1064                         rot_tu95_Y = 0;
1065                         rot_tu95_Z = 0;
1066                         trans_tu95_X = -20;
1067                         trans_tu95_Y = 10;
1068                         trans_tu95_Z = 30;
1069                         clouds_x = 0;
1070                         r_propeller = 0;
1071                         clouds_x = 0;
1072
1073                         // set ligth position
1074                         //light_position_skybox2();     // same as previous scene
1075                 }
1076
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)
1079                 {
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);
1085                 }
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)
1088                 {
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);
1094                 }
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)
1097                 {
1098                         rotX = 25;
1099                         rotY = 10;
1100                         transZ = -70;
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);
1106                 }
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)
1109                 {
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);
1115                 }
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)
1118                 {
1119                         rotX = 55;
1120                         rotY = 220;
1121                         rotZ = 0;
1122                         transZ = -80;
1123                         rot_drakenX = 0;
1124                         trans_drakenX = 10;
1125                         trans_drakenY = -7;
1126                         trans_drakenZ = -35;
1127                         trans_tu95_X = 0;
1128                         trans_tu95_Z = 15;
1129                 }
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)
1132                 {
1133                         rotY = rotY + (0.023 * diff_time);
1134                         rotX = rotX - (0.0035 * diff_time);
1135                         transZ = transZ + (0.001 * diff_time);
1136                 }
1137                 // go to scene 1
1138                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 90000)
1139                 {
1140                         scene = 8;              // goto scene 8
1141                         scene_defaults = 0;     // make sure defaults are loaded
1142                 }
1143                 // routine for rotating the propellers
1144                 rotate_propellers();
1145
1146                 // rutine for moving the cloud textures
1147                 scroll_clouds_X();
1148
1149                 // move J-35 Draken contrail
1150                 move_draken_contrail();
1151
1152                 break;
1153                 // End of third Draken & TU-95 Physics Scenen
1154
1155                 //-----------------------------------------//
1156
1157                 // Start of second TU-95 scene
1158                 // setup scene defaults
1159         case 8:
1160                 if (scene_defaults == 0)
1161                 {
1162                         scene_defaults = 1;
1163
1164                         transX = 0;
1165                         transY = 0;
1166                         transZ = 0;
1167                         rotX = 10;
1168                         rotY = 190;
1169                         rotZ = 0;
1170                         rot_worldX = 0;
1171                         rot_worldY = 0;
1172                         rot_worldZ = 0;
1173                         transZ = -55;
1174                         trans_worldX = 0;
1175                         trans_worldY = 0;
1176                         trans_worldZ = 0;
1177                         rot_tu95_X = 5;
1178                         rot_tu95_Y = 0;
1179                         rot_tu95_Z = 0;
1180                         trans_tu95_X = 10;
1181                         trans_tu95_Y = 8;
1182                         trans_tu95_Z = 0;
1183                         clouds_x = 0;
1184                         r_propeller = 0;
1185                         clouds_x = 0;
1186
1187                         // set ligth position
1188                         //light_position_skybox2();     // same as previous scene
1189                 }
1190
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)
1193                 {
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);
1200                 }
1201                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 92000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 94000)
1202                 {
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);
1210                 }
1211                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 94000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 95000)
1212                 {
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);
1220                 }
1221                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 95000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 96000)
1222                 {
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);
1230                 }
1231                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 96000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 97000)
1232                 {
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);
1239                 }
1240                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 97000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 100000)
1241                 {
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);
1248                 }
1249                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 100000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 104000)
1250                 {
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);
1257                 }
1258                 // go to scene 9
1259                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 104000)
1260                 {
1261                         scene = 9;              // goto scene 1
1262                         scene_defaults = 0;     // make sure defaults are loaded
1263                 }
1264
1265                 // routine for rotating the propellers
1266                 rotate_propellers();
1267
1268                 // rutine for moving the cloud textures
1269                 scroll_clouds_X();
1270
1271                 break;
1272                 // End of second TU-95 scene
1273
1274                 //-----------------------------------------//
1275
1276                 // Start of fourth scene with Draken and TU-95
1277                 // setup scene defaults
1278         case 9:
1279                 if (scene_defaults == 0)
1280                 {
1281                         scene_defaults = 1;
1282
1283                         transX = -30;
1284                         transY = 0;
1285                         transZ = 0;
1286                         rotX = 15;
1287                         rotY = 230;
1288                         rotZ = 0;
1289                         rot_worldX = 0;
1290                         rot_worldY = 0;
1291                         rot_worldZ = 0;
1292                         transZ = -80;
1293                         trans_worldX = 0;
1294                         trans_worldY = 0;
1295                         trans_worldZ = 0;
1296                         rot_drakenX = 0;
1297                         rot_drakenY = 0;
1298                         rot_drakenZ = 0;
1299                         trans_drakenX = 0.5;
1300                         trans_drakenY = 5;
1301                         trans_drakenZ = -35;
1302                         draken_velocity = 0;
1303                         draken_wheels = 0;
1304                         draken_ab_on = 0;
1305                         draken_contrail = 1;
1306                         rot_tu95_X = 15;
1307                         rot_tu95_Y = -20;
1308                         rot_tu95_Z = 5;
1309                         trans_tu95_X = -10;
1310                         trans_tu95_Y = 10;
1311                         trans_tu95_Z = 50;
1312                         clouds_x = 0;
1313                         r_propeller = 0;
1314                         clouds_x = 0;
1315
1316                         // set ligth position
1317                         //light_position_skybox2();     // same as previous scene
1318                 }
1319
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)
1322                 {
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);
1330                 }
1331                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 106000 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 106500)
1332                 {
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);
1340                 }
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)
1343                 {
1344                         transX = 0;
1345                         rotY = 180;
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);
1353                 }
1354                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 107350 && glutGet(GLUT_ELAPSED_TIME) - bench_start_time < 107500)
1355                 {
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);
1363                 }
1364
1365                 // go to scene 1
1366                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 107500 && demo == 1)
1367                 {
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
1371                 }
1372
1373                 // collect benchmark data and goto main menu
1374                 else if (glutGet(GLUT_ELAPSED_TIME) - bench_start_time > 107500 && demo == 0)
1375                 {
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
1379
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
1383
1384                         // move the width dial to the proper resolution on the scale
1385                         switch(glutGet(GLUT_WINDOW_WIDTH))
1386                         {
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;
1395                         }
1396                         // move the heigth dial to the proper resolution on the scale
1397                         switch(glutGet(GLUT_WINDOW_HEIGHT))
1398                         {
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;
1411                         }
1412
1413                         menu = 1;                                                                                                               // goto main menu
1414                         scene_defaults = 0;                                                                                             // make sure defaults are loaded
1415
1416                         // Save the score to a file
1417                         save_score();
1418
1419                         // convert score to individual digits so we can render them later
1420                         convert_score();
1421                 }
1422
1423                 // routine for rotating the propellers
1424                 rotate_propellers();
1425
1426                 // rutine for moving the cloud textures
1427                 scroll_clouds_X();
1428
1429                 // move J-35 Draken contrail
1430                 move_draken_contrail();
1431
1432                 break;
1433                 // End of fourth Draken & TU-95 Physics Scenen
1434         }
1435 }
1436
1437 // set the backgorund color
1438 void background_color()
1439 {
1440         glClearColor(0.424, 0.639, 0.725, 1);
1441 }
1442
1443 // Clears the current window and draws the benchmark.
1444 void display()
1445 {
1446 #ifdef macintosh
1447         // Mac OS specific
1448         // set up the viewport and the screen size
1449         glViewport(0, 0, ScreenWidth,ScreenHeight );
1450 #endif
1451
1452         //get window resolution to maintain aspect ratio with gluPerspective and glOrtho
1453         ScreenWidth = glutGet(GLUT_WINDOW_WIDTH);
1454         ScreenHeight = glutGet(GLUT_WINDOW_HEIGHT);
1455
1456         //set FOV, perspective, clipping and maintan aspect ratio
1457         glMatrixMode(GL_PROJECTION);
1458         glLoadIdentity();
1459
1460         gluPerspective(60,(float)ScreenWidth/ScreenHeight,1,2048);
1461         glMatrixMode(GL_MODELVIEW);
1462         glLoadIdentity();
1463         glutPostRedisplay();    // Post re-paint request to activate display()
1464
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);
1468         glLoadIdentity();
1469         glEnable(GL_DEPTH_TEST);
1470         glLoadIdentity();
1471
1472         //-----------------------------------------//
1473
1474         if (menu != 0)
1475         {
1476                 menus();                                                                                                        // render menus
1477                 if (menu == 1) render_score();                                                          // render score in main menu
1478         }
1479
1480         if (demo == 0 && scene > 0 && res_mode != 7)                                    // make sure resolution cant be changed during benchmarking
1481         {
1482
1483                 switch(res_mode)
1484                 {
1485                 case 0:
1486                         if (ScreenWidth != 320 || ScreenHeight != 240)resolutions();
1487                         break;
1488                 case 1:
1489                         if (ScreenWidth != 400 || ScreenHeight != 300)resolutions();
1490                         break;
1491                 case 2:
1492                         if (ScreenWidth != 512 || ScreenHeight != 384)resolutions();
1493                         break;
1494                 case 3:
1495                         if (ScreenWidth != 640 || ScreenHeight != 480)resolutions();
1496                         break;
1497                 case 4:
1498                         if (ScreenWidth != 800 || ScreenHeight != 600)resolutions();
1499                         break;
1500                 case 5:
1501                         if (ScreenWidth != 1024 || ScreenHeight != 768)resolutions();
1502                         break;
1503                 case 6:
1504                         if (ScreenWidth != 1280 || ScreenHeight != 1024)resolutions();
1505                         break;
1506                 }
1507         }
1508         // Render Scenes
1509
1510         // Render Skybox1 in scene 1
1511         if (scene == 1 && scene_defaults == 1)
1512         {
1513                 // rotate and translate skybox
1514                 glPushMatrix();
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
1520                 glPopMatrix();
1521         }
1522
1523         glPushMatrix();
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);
1529         glPushMatrix();
1530
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
1538
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();
1541         glPopMatrix();
1542         glPopMatrix();
1543
1544         glPushMatrix();
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);
1550
1551         // rotate and translate J 35 Draken
1552         glPushMatrix();
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);
1557
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();
1561         glPopMatrix();
1562
1563         // rotate and translate TU-95
1564         glPushMatrix();
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);
1569
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();
1573         glPopMatrix();
1574
1575         // update ligth
1576         glLightfv(GL_LIGHT0, GL_POSITION, light_position);
1577         glPopMatrix();
1578
1579         // render FPS counter
1580         glDisable(GL_DEPTH_TEST);
1581         if (scene > 0)render_fps();
1582         glEnable(GL_DEPTH_TEST);
1583
1584         // alpha transperancy
1585         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1586
1587         //we need to swap the frame buffer when we are running double buffering
1588         glutSwapBuffers();
1589
1590         // Flush drawing command buffer to make drawing happen as soon as possible.
1591         //      glFlush();
1592
1593
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
1596 }
1597
1598 // fps counter
1599 void fps_timer(int)
1600 {
1601         glutTimerFunc(1000, fps_timer, 0);      // next Timer call milliseconds later
1602         fps = frames;
1603         frames = 0;
1604
1605         // sett entrys in array to 10 so not to render any digits that is not part of the frame rate number
1606         draw_fps[0] = 10;
1607         draw_fps[1] = 10;
1608         draw_fps[2] = 10;
1609         draw_fps[3] = 10;
1610         draw_fps[4] = 10;
1611
1612         // devide fps int into separete digits
1613         fps_i = 0;
1614         while (fps > 0)
1615         {
1616                 int digit = fps%10;
1617                 fps /= 10;
1618                 //print digit
1619                 draw_fps[fps_i] = digit;
1620                 fps_i++;
1621         }
1622 }
1623
1624 // Initializes GLUT, the display mode, and main window; registers callbacks;
1625 // enters the main event loop.
1626 int main(int argc, char** argv)
1627 {
1628         // set up the viewport and the screen size
1629         glViewport(0, 0, ScreenWidth,ScreenHeight );
1630
1631         // Use a double buffered window in RGB mode
1632         // Use depth buffer
1633         glutInit(&argc, argv);
1634
1635 #ifdef __linux__
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
1638 #elif __sgi
1639         putenv( (char *) "DECOUPLE_SWAPBUF y" );                                                                                // Disables swapbuffers sync to vertical blank
1640 #endif
1641
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);
1644
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");
1649
1650         // Tell GLUT that whenever the main window needs to be repainted that it
1651         // should call the function display().
1652         glutDisplayFunc(display);
1653
1654         // enable ligthting
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);
1660
1661         //set background color
1662         background_color();
1663
1664         // glut mouse support
1665         glutMouseFunc(MouseClick);
1666
1667         // glut keyboard support
1668         glutKeyboardFunc(NormalKeys);
1669
1670         // time for physics and stuff
1671         glutTimerFunc(0, timer, 0);
1672
1673         // update fps timer and terminal every
1674         glutTimerFunc(0, fps_timer, 0);
1675
1676         // load textures
1677         textures_digits();
1678         textures_menus();
1679         textures_draken();
1680         textures_runway();
1681         textures_skybox1();
1682         textures_ground2();
1683         textures_skybox2();
1684         textures_tu_95();
1685
1686 #ifdef _WIN32
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
1693 #endif
1694
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.
1698         glutMainLoop();
1699         return 0;
1700
1701 }