Xcode/TemplatesForXcodeLeopard/SDL OpenGL Application/atlantis/atlantis.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 11 Sep 2011 14:44:37 -0400
branchSDL-1.2
changeset 5895 402eac854030
child 7191 75360622e65f
permissions -rw-r--r--
Unpacked Xcode.tar.gz.
icculus@5895
     1
icculus@5895
     2
/* Copyright (c) Mark J. Kilgard, 1994. */
icculus@5895
     3
icculus@5895
     4
/**
icculus@5895
     5
 * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
icculus@5895
     6
 * ALL RIGHTS RESERVED
icculus@5895
     7
 * Permission to use, copy, modify, and distribute this software for
icculus@5895
     8
 * any purpose and without fee is hereby granted, provided that the above
icculus@5895
     9
 * copyright notice appear in all copies and that both the copyright notice
icculus@5895
    10
 * and this permission notice appear in supporting documentation, and that
icculus@5895
    11
 * the name of Silicon Graphics, Inc. not be used in advertising
icculus@5895
    12
 * or publicity pertaining to distribution of the software without specific,
icculus@5895
    13
 * written prior permission.
icculus@5895
    14
 *
icculus@5895
    15
 * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
icculus@5895
    16
 * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
icculus@5895
    17
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
icculus@5895
    18
 * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
icculus@5895
    19
 * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
icculus@5895
    20
 * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
icculus@5895
    21
 * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
icculus@5895
    22
 * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
icculus@5895
    23
 * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
icculus@5895
    24
 * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
icculus@5895
    25
 * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
icculus@5895
    26
 * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
icculus@5895
    27
 *
icculus@5895
    28
 * US Government Users Restricted Rights
icculus@5895
    29
 * Use, duplication, or disclosure by the Government is subject to
icculus@5895
    30
 * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
icculus@5895
    31
 * (c)(1)(ii) of the Rights in Technical Data and Computer Software
icculus@5895
    32
 * clause at DFARS 252.227-7013 and/or in similar or successor
icculus@5895
    33
 * clauses in the FAR or the DOD or NASA FAR Supplement.
icculus@5895
    34
 * Unpublished-- rights reserved under the copyright laws of the
icculus@5895
    35
 * United States.  Contractor/manufacturer is Silicon Graphics,
icculus@5895
    36
 * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
icculus@5895
    37
 *
icculus@5895
    38
 * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
icculus@5895
    39
 */
icculus@5895
    40
#include <stdio.h>
icculus@5895
    41
#include <stdlib.h>
icculus@5895
    42
#include <string.h>
icculus@5895
    43
#include <math.h>
icculus@5895
    44
#include <sys/time.h>
icculus@5895
    45
#include <GLUT/glut.h>
icculus@5895
    46
#include "atlantis.h"
icculus@5895
    47
icculus@5895
    48
fishRec sharks[NUM_SHARKS];
icculus@5895
    49
fishRec momWhale;
icculus@5895
    50
fishRec babyWhale;
icculus@5895
    51
fishRec dolph;
icculus@5895
    52
icculus@5895
    53
GLboolean Timing = GL_TRUE;
icculus@5895
    54
icculus@5895
    55
int w_win = 640;
icculus@5895
    56
int h_win = 480;
icculus@5895
    57
GLint count  = 0;
icculus@5895
    58
GLenum StrMode = GL_VENDOR;
icculus@5895
    59
icculus@5895
    60
GLboolean moving;
icculus@5895
    61
icculus@5895
    62
static double mtime(void)
icculus@5895
    63
{
icculus@5895
    64
   struct timeval tk_time;
icculus@5895
    65
   struct timezone tz;
icculus@5895
    66
   
icculus@5895
    67
   gettimeofday(&tk_time, &tz);
icculus@5895
    68
   
icculus@5895
    69
   return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
icculus@5895
    70
}
icculus@5895
    71
icculus@5895
    72
static double filter(double in, double *save)
icculus@5895
    73
{
icculus@5895
    74
	static double k1 = 0.9;
icculus@5895
    75
	static double k2 = 0.05;
icculus@5895
    76
icculus@5895
    77
	save[3] = in;
icculus@5895
    78
	save[1] = save[0]*k1 + k2*(save[3] + save[2]);
icculus@5895
    79
icculus@5895
    80
	save[0]=save[1];
icculus@5895
    81
	save[2]=save[3];
icculus@5895
    82
icculus@5895
    83
	return(save[1]);
icculus@5895
    84
}
icculus@5895
    85
icculus@5895
    86
void DrawStr(const char *str)
icculus@5895
    87
{
icculus@5895
    88
	GLint i = 0;
icculus@5895
    89
	
icculus@5895
    90
	if(!str) return;
icculus@5895
    91
        
icculus@5895
    92
	while(str[i])
icculus@5895
    93
	{
icculus@5895
    94
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
icculus@5895
    95
		i++;
icculus@5895
    96
	}
icculus@5895
    97
}
icculus@5895
    98
icculus@5895
    99
void
icculus@5895
   100
InitFishs(void)
icculus@5895
   101
{
icculus@5895
   102
    int i;
icculus@5895
   103
icculus@5895
   104
    for (i = 0; i < NUM_SHARKS; i++) {
icculus@5895
   105
        sharks[i].x = 70000.0 + rand() % 6000;
icculus@5895
   106
        sharks[i].y = rand() % 6000;
icculus@5895
   107
        sharks[i].z = rand() % 6000;
icculus@5895
   108
        sharks[i].psi = rand() % 360 - 180.0;
icculus@5895
   109
        sharks[i].v = 1.0;
icculus@5895
   110
    }
icculus@5895
   111
icculus@5895
   112
    dolph.x = 30000.0;
icculus@5895
   113
    dolph.y = 0.0;
icculus@5895
   114
    dolph.z = 6000.0;
icculus@5895
   115
    dolph.psi = 90.0;
icculus@5895
   116
    dolph.theta = 0.0;
icculus@5895
   117
    dolph.v = 3.0;
icculus@5895
   118
icculus@5895
   119
    momWhale.x = 70000.0;
icculus@5895
   120
    momWhale.y = 0.0;
icculus@5895
   121
    momWhale.z = 0.0;
icculus@5895
   122
    momWhale.psi = 90.0;
icculus@5895
   123
    momWhale.theta = 0.0;
icculus@5895
   124
    momWhale.v = 3.0;
icculus@5895
   125
icculus@5895
   126
    babyWhale.x = 60000.0;
icculus@5895
   127
    babyWhale.y = -2000.0;
icculus@5895
   128
    babyWhale.z = -2000.0;
icculus@5895
   129
    babyWhale.psi = 90.0;
icculus@5895
   130
    babyWhale.theta = 0.0;
icculus@5895
   131
    babyWhale.v = 3.0;
icculus@5895
   132
}
icculus@5895
   133
icculus@5895
   134
void
icculus@5895
   135
Atlantis_Init(void)
icculus@5895
   136
{
icculus@5895
   137
    static float ambient[] = {0.2, 0.2, 0.2, 1.0};
icculus@5895
   138
    static float diffuse[] = {1.0, 1.0, 1.0, 1.0};
icculus@5895
   139
    static float position[] = {0.0, 1.0, 0.0, 0.0};
icculus@5895
   140
    static float mat_shininess[] = {90.0};
icculus@5895
   141
    static float mat_specular[] = {0.8, 0.8, 0.8, 1.0};
icculus@5895
   142
    static float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0};
icculus@5895
   143
    static float mat_ambient[] = {0.3, 0.4, 0.5, 1.0};
icculus@5895
   144
    static float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0};
icculus@5895
   145
    static float lmodel_localviewer[] = {0.0};
icculus@5895
   146
    //GLfloat map1[4] = {0.0, 0.0, 0.0, 0.0};
icculus@5895
   147
    //GLfloat map2[4] = {0.0, 0.0, 0.0, 0.0};
icculus@5895
   148
    static float fog_color[] = {0.0, 0.5, 0.9, 1.0};
icculus@5895
   149
icculus@5895
   150
    glFrontFace(GL_CCW);
icculus@5895
   151
icculus@5895
   152
    glDepthFunc(GL_LESS);
icculus@5895
   153
    glEnable(GL_DEPTH_TEST);
icculus@5895
   154
icculus@5895
   155
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
icculus@5895
   156
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
icculus@5895
   157
    glLightfv(GL_LIGHT0, GL_POSITION, position);
icculus@5895
   158
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
icculus@5895
   159
    glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer);
icculus@5895
   160
    glEnable(GL_LIGHTING);
icculus@5895
   161
    glEnable(GL_LIGHT0);
icculus@5895
   162
icculus@5895
   163
    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
icculus@5895
   164
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
icculus@5895
   165
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
icculus@5895
   166
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
icculus@5895
   167
icculus@5895
   168
    InitFishs();
icculus@5895
   169
icculus@5895
   170
    glEnable(GL_FOG);
icculus@5895
   171
	glFogi(GL_FOG_MODE, GL_EXP);
icculus@5895
   172
	glFogf(GL_FOG_DENSITY, 0.0000025);
icculus@5895
   173
	glFogfv(GL_FOG_COLOR, fog_color);
icculus@5895
   174
icculus@5895
   175
    glClearColor(0.0, 0.5, 0.9, 1.0);
icculus@5895
   176
}
icculus@5895
   177
icculus@5895
   178
void
icculus@5895
   179
Atlantis_Reshape(int width, int height)
icculus@5895
   180
{
icculus@5895
   181
	w_win = width;
icculus@5895
   182
	h_win = height;
icculus@5895
   183
	
icculus@5895
   184
    glViewport(0, 0, width, height);
icculus@5895
   185
icculus@5895
   186
    glMatrixMode(GL_PROJECTION);
icculus@5895
   187
    glLoadIdentity();
icculus@5895
   188
    gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0, 300000.0);
icculus@5895
   189
    glMatrixMode(GL_MODELVIEW);
icculus@5895
   190
}
icculus@5895
   191
icculus@5895
   192
void
icculus@5895
   193
Atlantis_Animate(void)
icculus@5895
   194
{
icculus@5895
   195
    int i;
icculus@5895
   196
icculus@5895
   197
    for (i = 0; i < NUM_SHARKS; i++) {
icculus@5895
   198
        SharkPilot(&sharks[i]);
icculus@5895
   199
        SharkMiss(i);
icculus@5895
   200
    }
icculus@5895
   201
    WhalePilot(&dolph);
icculus@5895
   202
    dolph.phi++;
icculus@5895
   203
    //glutPostRedisplay();
icculus@5895
   204
    WhalePilot(&momWhale);
icculus@5895
   205
    momWhale.phi++;
icculus@5895
   206
    WhalePilot(&babyWhale);
icculus@5895
   207
    babyWhale.phi++;
icculus@5895
   208
}
icculus@5895
   209
icculus@5895
   210
void
icculus@5895
   211
Atlantis_Key(unsigned char key, int x, int y)
icculus@5895
   212
{
icculus@5895
   213
    switch (key) {
icculus@5895
   214
    case 't':
icculus@5895
   215
    	Timing = !Timing;
icculus@5895
   216
    break;
icculus@5895
   217
    case ' ':
icculus@5895
   218
    	switch(StrMode)
icculus@5895
   219
    	{
icculus@5895
   220
		    case GL_EXTENSIONS:
icculus@5895
   221
    			StrMode = GL_VENDOR;
icculus@5895
   222
		    break;
icculus@5895
   223
		    case GL_VENDOR:
icculus@5895
   224
		    	StrMode = GL_RENDERER;
icculus@5895
   225
		    break;
icculus@5895
   226
		    case GL_RENDERER:
icculus@5895
   227
		    	StrMode = GL_VERSION;
icculus@5895
   228
		    break;
icculus@5895
   229
		    case GL_VERSION:
icculus@5895
   230
		    	StrMode = GL_EXTENSIONS;
icculus@5895
   231
		    break;
icculus@5895
   232
		}
icculus@5895
   233
	break;
icculus@5895
   234
    case 27:           /* Esc will quit */
icculus@5895
   235
        exit(1);
icculus@5895
   236
    break;
icculus@5895
   237
    case 's':             		/* "s" start animation */
icculus@5895
   238
        moving = GL_TRUE;
icculus@5895
   239
        //glutIdleFunc(Animate);
icculus@5895
   240
    break;
icculus@5895
   241
    case 'a':          			/* "a" stop animation */
icculus@5895
   242
        moving = GL_FALSE;
icculus@5895
   243
        //glutIdleFunc(NULL);
icculus@5895
   244
    break;
icculus@5895
   245
    case '.':          			/* "." will advance frame */
icculus@5895
   246
        if (!moving) {
icculus@5895
   247
            Atlantis_Animate();
icculus@5895
   248
        }
icculus@5895
   249
    }
icculus@5895
   250
}
icculus@5895
   251
/*
icculus@5895
   252
void Display(void)
icculus@5895
   253
{
icculus@5895
   254
	static float P123[3] = {-448.94, -203.14, 9499.60};
icculus@5895
   255
	static float P124[3] = {-442.64, -185.20, 9528.07};
icculus@5895
   256
	static float P125[3] = {-441.07, -148.05, 9528.07};
icculus@5895
   257
	static float P126[3] = {-443.43, -128.84, 9499.60};
icculus@5895
   258
	static float P127[3] = {-456.87, -146.78, 9466.67};
icculus@5895
   259
	static float P128[3] = {-453.68, -183.93, 9466.67};
icculus@5895
   260
icculus@5895
   261
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
icculus@5895
   262
	
icculus@5895
   263
	glPushMatrix();
icculus@5895
   264
    FishTransform(&dolph);
icculus@5895
   265
    DrawDolphin(&dolph);
icculus@5895
   266
    glPopMatrix();
icculus@5895
   267
 
icculus@5895
   268
	glutSwapBuffers();
icculus@5895
   269
}
icculus@5895
   270
*/
icculus@5895
   271
icculus@5895
   272
void
icculus@5895
   273
Atlantis_Display(void)
icculus@5895
   274
{
icculus@5895
   275
    int i;
icculus@5895
   276
    static double th[4] = {0.0, 0.0, 0.0, 0.0};
icculus@5895
   277
	static double t1 = 0.0, t2 = 0.0, t;
icculus@5895
   278
	char num_str[128];
icculus@5895
   279
    
icculus@5895
   280
    t1 = t2;
icculus@5895
   281
icculus@5895
   282
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
icculus@5895
   283
icculus@5895
   284
    for (i = 0; i < NUM_SHARKS; i++) {
icculus@5895
   285
        glPushMatrix();
icculus@5895
   286
        FishTransform(&sharks[i]);
icculus@5895
   287
        DrawShark(&sharks[i]);
icculus@5895
   288
        glPopMatrix();
icculus@5895
   289
    }
icculus@5895
   290
icculus@5895
   291
    glPushMatrix();
icculus@5895
   292
    FishTransform(&dolph);
icculus@5895
   293
    DrawDolphin(&dolph);
icculus@5895
   294
    glPopMatrix();
icculus@5895
   295
icculus@5895
   296
    glPushMatrix();
icculus@5895
   297
    FishTransform(&momWhale);
icculus@5895
   298
    DrawWhale(&momWhale);
icculus@5895
   299
    glPopMatrix();
icculus@5895
   300
icculus@5895
   301
    glPushMatrix();
icculus@5895
   302
    FishTransform(&babyWhale);
icculus@5895
   303
    glScalef(0.45, 0.45, 0.3);
icculus@5895
   304
    DrawWhale(&babyWhale);
icculus@5895
   305
    glPopMatrix();
icculus@5895
   306
    
icculus@5895
   307
    if(Timing)
icculus@5895
   308
    {
icculus@5895
   309
		t2 = mtime();
icculus@5895
   310
		t = t2 - t1;
icculus@5895
   311
		if(t > 0.0001) t = 1.0 / t;
icculus@5895
   312
		
icculus@5895
   313
		glDisable(GL_LIGHTING);
icculus@5895
   314
		//glDisable(GL_DEPTH_TEST);
icculus@5895
   315
		
icculus@5895
   316
		glColor3f(1.0, 0.0, 0.0);
icculus@5895
   317
		
icculus@5895
   318
		glMatrixMode (GL_PROJECTION);
icculus@5895
   319
		glPushMatrix();
icculus@5895
   320
		glLoadIdentity();
icculus@5895
   321
		glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
icculus@5895
   322
		
icculus@5895
   323
		glRasterPos2f(5.0, 5.0);
icculus@5895
   324
		
icculus@5895
   325
		switch(StrMode)
icculus@5895
   326
		{
icculus@5895
   327
			case GL_VENDOR:
icculus@5895
   328
				sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win);
icculus@5895
   329
				DrawStr(num_str);
icculus@5895
   330
				DrawStr(glGetString(GL_VENDOR));
icculus@5895
   331
			break;
icculus@5895
   332
			case GL_RENDERER:
icculus@5895
   333
				sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win);
icculus@5895
   334
				DrawStr(num_str);
icculus@5895
   335
				DrawStr(glGetString(GL_RENDERER));
icculus@5895
   336
			break;
icculus@5895
   337
			case GL_VERSION:
icculus@5895
   338
				sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win);
icculus@5895
   339
				DrawStr(num_str);
icculus@5895
   340
				DrawStr(glGetString(GL_VERSION));
icculus@5895
   341
			break;
icculus@5895
   342
			case GL_EXTENSIONS:
icculus@5895
   343
				sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win);
icculus@5895
   344
				DrawStr(num_str);
icculus@5895
   345
				DrawStr(glGetString(GL_EXTENSIONS));
icculus@5895
   346
			break;
icculus@5895
   347
		}
icculus@5895
   348
		
icculus@5895
   349
		glPopMatrix();
icculus@5895
   350
		glMatrixMode(GL_MODELVIEW);
icculus@5895
   351
		
icculus@5895
   352
		glEnable(GL_LIGHTING);
icculus@5895
   353
		//glEnable(GL_DEPTH_TEST);
icculus@5895
   354
	}
icculus@5895
   355
	
icculus@5895
   356
    count++;
icculus@5895
   357
icculus@5895
   358
    glutSwapBuffers();
icculus@5895
   359
}
icculus@5895
   360
icculus@5895
   361
/*
icculus@5895
   362
void
icculus@5895
   363
Visible(int state)
icculus@5895
   364
{
icculus@5895
   365
    if (state == GLUT_VISIBLE) {
icculus@5895
   366
        if (moving)
icculus@5895
   367
            glutIdleFunc(Animate);
icculus@5895
   368
    } else {
icculus@5895
   369
        if (moving)
icculus@5895
   370
            glutIdleFunc(NULL);
icculus@5895
   371
    }
icculus@5895
   372
}
icculus@5895
   373
icculus@5895
   374
icculus@5895
   375
void
icculus@5895
   376
timingSelect(int value)
icculus@5895
   377
{
icculus@5895
   378
    switch(value)
icculus@5895
   379
    {
icculus@5895
   380
		case 1:
icculus@5895
   381
			StrMode = GL_VENDOR;
icculus@5895
   382
		break;
icculus@5895
   383
		case 2:
icculus@5895
   384
			StrMode = GL_RENDERER;
icculus@5895
   385
		break;
icculus@5895
   386
		case 3:
icculus@5895
   387
			StrMode = GL_VERSION;
icculus@5895
   388
		break;
icculus@5895
   389
		case 4:
icculus@5895
   390
			StrMode = GL_EXTENSIONS;
icculus@5895
   391
		break;
icculus@5895
   392
    }
icculus@5895
   393
}
icculus@5895
   394
icculus@5895
   395
void
icculus@5895
   396
menuSelect(int value)
icculus@5895
   397
{
icculus@5895
   398
    switch (value) {
icculus@5895
   399
    case 1:
icculus@5895
   400
        moving = GL_TRUE;
icculus@5895
   401
        glutIdleFunc(Animate);
icculus@5895
   402
        break;
icculus@5895
   403
    case 2:
icculus@5895
   404
        moving = GL_FALSE;
icculus@5895
   405
        glutIdleFunc(NULL);
icculus@5895
   406
        break;
icculus@5895
   407
    case 4:
icculus@5895
   408
        exit(0);
icculus@5895
   409
        break;
icculus@5895
   410
    }
icculus@5895
   411
}
icculus@5895
   412
icculus@5895
   413
int
icculus@5895
   414
main(int argc, char **argv)
icculus@5895
   415
{
icculus@5895
   416
	GLboolean fullscreen = GL_FALSE; 
icculus@5895
   417
	GLint time_menu;
icculus@5895
   418
 	
icculus@5895
   419
 	srand(0);
icculus@5895
   420
icculus@5895
   421
        glutInit(&argc, argv);
icculus@5895
   422
	if (argc > 1 && !strcmp(argv[1], "-w"))
icculus@5895
   423
		fullscreen = GL_FALSE;
icculus@5895
   424
icculus@5895
   425
	//glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
icculus@5895
   426
	glutInitDisplayString("rgba double depth=24");
icculus@5895
   427
	if (fullscreen) {
icculus@5895
   428
	  glutGameModeString("1024x768:32");
icculus@5895
   429
	  glutEnterGameMode();
icculus@5895
   430
	} else {
icculus@5895
   431
	  glutInitWindowSize(320, 240);
icculus@5895
   432
	  glutCreateWindow("Atlantis Timing");
icculus@5895
   433
	}
icculus@5895
   434
    Init();
icculus@5895
   435
    glutDisplayFunc(Display);
icculus@5895
   436
    glutReshapeFunc(Reshape);
icculus@5895
   437
    glutKeyboardFunc(Key);
icculus@5895
   438
    moving = GL_TRUE;
icculus@5895
   439
glutIdleFunc(Animate);
icculus@5895
   440
    glutVisibilityFunc(Visible);
icculus@5895
   441
    
icculus@5895
   442
    time_menu = glutCreateMenu(timingSelect);
icculus@5895
   443
    glutAddMenuEntry("GL_VENDOR", 1);
icculus@5895
   444
    glutAddMenuEntry("GL_RENDERER", 2);
icculus@5895
   445
    glutAddMenuEntry("GL_VERSION", 3);
icculus@5895
   446
    glutAddMenuEntry("GL_EXTENSIONS", 4);
icculus@5895
   447
    
icculus@5895
   448
    glutCreateMenu(menuSelect);
icculus@5895
   449
    glutAddMenuEntry("Start motion", 1);
icculus@5895
   450
    glutAddMenuEntry("Stop motion", 2);
icculus@5895
   451
    glutAddSubMenu("Timing Mode", time_menu);
icculus@5895
   452
    glutAddMenuEntry("Quit", 4);
icculus@5895
   453
    
icculus@5895
   454
    //glutAttachMenu(GLUT_RIGHT_BUTTON);
icculus@5895
   455
    glutAttachMenu(GLUT_RIGHT_BUTTON);
icculus@5895
   456
    glutMainLoop();
icculus@5895
   457
    return 0;             // ANSI C requires main to return int.
icculus@5895
   458
}
icculus@5895
   459
*/