-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
617 lines (525 loc) · 18.4 KB
/
main.cpp
File metadata and controls
617 lines (525 loc) · 18.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
#include "Angel.h"
#include <stdio.h>
const int NumTimesToSubdivide = 6;
const int NumTriangles = 16384; // (4 faces)^(NumTimesToSubdivide + 1)
const int NumVertices = 3 * NumTriangles;
const int NumSpheres = 6;
typedef Angel::vec4 point4;
typedef Angel::vec4 color4;
point4 points[6][NumVertices];
vec3 normals[6][NumVertices];
// Model-view and projection matrices uniform location
GLuint ModelView, Projection;
GLuint TransformLoc;
// Light properties uniform locations
GLuint AmbientProductLoc;
GLuint DiffuseProductLoc;
GLuint SpecularProductLoc;
GLuint LightPositionLoc;
GLuint ShininessLoc;
GLuint ShadingTypeLoc;
GLuint vao[6];
// Light property parameters
point4 light_position;
color4 light_ambient;
color4 light_diffuse;
color4 light_specular;
// Material property parameters
color4 material_ambient;
color4 material_diffuse;
color4 material_specular;
float material_shininess;
// Inital position of camera
float init_angle = 30;
mat4 initial_model_view = RotateX(init_angle) * Translate(0.0, -80.0, -160.0);
mat4 model_view;
// Initial planet positions
const mat4 p2trans = Translate(40.0, 0.0, 0.0);
const mat4 p1 = Translate(20.0, 0.0, 0.0) * Scale(1.5, 1.5, 1.5);
const mat4 p2 = p2trans * Scale(2, 2, 2);
const mat4 p3 = Translate(60.0, 0.0, 0.0) * Scale(3.6, 3.6, 3.6);
const mat4 p4 = Translate(90.0, 0.0, 0.0) * Scale(5.0, 5.0, 5.0);
const mat4 m1 = Translate(35.0, 0.0, 0.0) * Scale(0.6, 0.6, 0.6);
// Transform matrices
mat4 transform;
mat4 center;
mat4 planetOne;
mat4 planetTwo;
mat4 planetThree;
mat4 planetFour;
mat4 planetMoon;
// Planet rotation angles
float thetaOne;
float thetaTwo;
float thetaThree;
float thetaFour;
float thetaMoon;
// Camera rotations
float altitudeAngle = -init_angle;
float azimuthAngle = 0;
inline
mat4 transpose2( const mat4& A ) {
return mat4( A[0][0], A[0][1], A[0][2], A[0][3],
A[1][0], A[1][1], A[1][2], A[1][3],
A[2][0], A[2][1], A[2][2], A[2][3],
A[3][0], A[3][1], A[3][2], A[3][3] );
}
//----------------------------------------------------------------------------
int Index = 0;
void
triangle( const point4& a, const point4& b, const point4& c, int objIndex, bool flat )
{
vec3 normal = normalize( cross(b - a, c - b) );
// Argument flat determines flat shading or Phong shading
normals[objIndex][Index] = flat ? normal : normalize(vec3(a.x, a.y, a.z));
points[objIndex][Index] = a; Index++;
normals[objIndex][Index] = flat ? normal : normalize(vec3(b.x, b.y, b.z));
points[objIndex][Index] = b; Index++;
normals[objIndex][Index] = flat ? normal : normalize(vec3(c.x, c.y, c.z));
points[objIndex][Index] = c; Index++;
}
//----------------------------------------------------------------------------
point4
unit( const point4& p )
{
float len = p.x*p.x + p.y*p.y + p.z*p.z;
point4 t;
if ( len > DivideByZeroTolerance ) {
t = p / sqrt(len);
t.w = 1.0;
}
return t;
}
void
divide_triangle( const point4& a, const point4& b,
const point4& c, int count, int objIndex, bool flat )
{
if ( count > 0 ) {
point4 v1 = unit( a + b );
point4 v2 = unit( a + c );
point4 v3 = unit( b + c );
divide_triangle( a, v1, v2, count - 1, objIndex, flat );
divide_triangle( c, v2, v3, count - 1, objIndex, flat );
divide_triangle( b, v3, v1, count - 1, objIndex, flat );
divide_triangle( v1, v3, v2, count - 1, objIndex, flat );
}
else {
triangle( a, b, c, objIndex, flat );
}
}
void
tetrahedron( int count, int objIndex, bool flat )
{
// Initial tetrahedron points
point4 v[4] = {
vec4( 0.0, 0.0, 1.0, 1.0 ),
vec4( 0.0, 0.942809, -0.333333, 1.0 ),
vec4( -0.816497, -0.471405, -0.333333, 1.0 ),
vec4( 0.816497, -0.471405, -0.333333, 1.0 )
};
divide_triangle( v[0], v[1], v[2], count, objIndex, flat );
divide_triangle( v[3], v[2], v[1], count, objIndex, flat );
divide_triangle( v[0], v[3], v[1], count, objIndex, flat );
divide_triangle( v[0], v[2], v[3], count, objIndex, flat );
}
//----------------------------------------------------------------------------
// Transform all objects with the same matrix
void transformObjects(mat4 trans, bool post) {
if (post) { // Post multiplication
center = center * trans;
planetOne = planetOne * trans;
planetTwo = planetTwo * trans;
planetThree = planetThree * trans;
planetFour = planetFour * trans;
planetMoon = planetMoon * trans;
} else { // Pre multiplication
center = trans * center;
planetOne = trans * planetOne;
planetTwo = trans * planetTwo;
planetThree = trans * planetThree;
planetFour = trans * planetFour;
planetMoon = trans * planetMoon;
}
}
float reduceAngle(float angle) {
if (angle > 360) {
return angle - 360;
} else if (angle < -360) {
return angle + 360;
}
return angle;
}
// OpenGL initialization
void
init()
{
// Subdivide a tetrahedron into a sphere (centered at origin)
Index = 0;
tetrahedron( 5, 0, false );
Index = 0;
tetrahedron( 3, 1, true );
Index = 0;
tetrahedron( 4, 2, false );
Index = 0;
tetrahedron( 6, 3, false );
Index = 0;
tetrahedron( 5, 4, false );
Index = 0;
tetrahedron( 3, 5, false );
// Generate vertex array objects
glGenVertexArrays( 6, vao );
// Load shaders and use the resulting shader program
GLuint program = InitShader( "vshader.glsl", "fshader.glsl" );
glUseProgram( program );
// 6 objects, 1 sun, 4 planets, 1 moon
for (int k = 0; k < 6; k++) {
glBindVertexArray( vao[k] );
// Create and initialize a buffer object
GLuint buffer;
glGenBuffers( 1, &buffer );
glBindBuffer( GL_ARRAY_BUFFER, buffer );
glBufferData( GL_ARRAY_BUFFER, sizeof(points[k]) + sizeof(normals[k]),
NULL, GL_STATIC_DRAW );
glBufferSubData( GL_ARRAY_BUFFER, 0, sizeof(points[k]), points[k] );
glBufferSubData( GL_ARRAY_BUFFER, sizeof(points[k]),
sizeof(normals[k]), normals[k] );
// set up vertex arrays
GLuint vPosition = glGetAttribLocation( program, "vPosition" );
glEnableVertexAttribArray( vPosition );
glVertexAttribPointer( vPosition, 4, GL_FLOAT, GL_FALSE, 0,
BUFFER_OFFSET(0) );
GLuint vNormal = glGetAttribLocation( program, "vNormal" );
glEnableVertexAttribArray( vNormal );
glVertexAttribPointer( vNormal, 3, GL_FLOAT, GL_FALSE, 0,
BUFFER_OFFSET(sizeof(points[k])) );
}
// Initialize shader lighting parameters
light_position = point4( 0.0, 0.0, 0.0, 0.0 );
light_ambient = color4( 0.2, 0.2, 0.2, 1.0 );
light_diffuse = color4( 1.0, 1.0, 1.0, 1.0 );
light_specular = color4( 1.0, 1.0, 1.0, 1.0 );
material_ambient = color4( 1.0, 0.0, 1.0, 1.0 );
material_diffuse = color4( 1.0, 0.8, 0.0, 1.0 );
material_specular = color4( 1.0, 0.0, 1.0, 1.0 );
material_shininess = 10.0;
color4 ambient_product = light_ambient * material_ambient;
color4 diffuse_product = light_diffuse * material_diffuse;
color4 specular_product = light_specular * material_specular;
AmbientProductLoc = glGetUniformLocation(program, "AmbientProduct");
glUniform4fv( AmbientProductLoc, 1, ambient_product );
DiffuseProductLoc = glGetUniformLocation(program, "DiffuseProduct");
glUniform4fv( DiffuseProductLoc, 1, diffuse_product );
SpecularProductLoc = glGetUniformLocation(program, "SpecularProduct");
glUniform4fv( SpecularProductLoc, 1, specular_product );
LightPositionLoc = glGetUniformLocation(program, "LightPosition");
glUniform4fv( LightPositionLoc, 1, light_position );
ShininessLoc = glGetUniformLocation(program, "Shininess");
glUniform1f( ShininessLoc, material_shininess );
// Retrieve transformation uniform variable locations
ModelView = glGetUniformLocation( program, "ModelView" );
Projection = glGetUniformLocation( program, "Projection" );
// Retreive transform matrix uniform locations
TransformLoc = glGetUniformLocation(program, "Transform");
// Flat, Gouraund, Phong
ShadingTypeLoc = glGetUniformLocation(program, "shadingType");
// Init model-view matrix
model_view = initial_model_view;
std::cout << model_view << std::endl;
std::cout << model_view[1][3] << std::endl;
std::cout << model_view[2][3] << std::endl;
// Init angles
thetaOne = 0;
thetaTwo = 0;
thetaThree = 0;
thetaFour = 0;
thetaMoon = 0;
// Init Planet locations, relative to the Sun
center = Scale(8.0, 8.0, 8.0);
planetOne = p1;
planetTwo = p2;
planetThree = p3;
planetFour = p4;
planetMoon = m1;
glEnable( GL_DEPTH_TEST );
glClearColor( 0.0, 0.0, 0.0, 1.0 ); /* black background */
}
//----------------------------------------------------------------------------
// Called when the window needs to be redrawn.
// TODO: Don't forget to add glutPostRedisplay().
void callbackDisplay()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glUniformMatrix4fv( ModelView, 1, GL_TRUE, model_view );
glBindVertexArray( vao[0] );
// Draw the Sun
light_ambient = color4( 0.8, 0.1, 0.1, 1.0 );
light_diffuse = color4( 0.8, 0.2, 0.2, 1.0 );
light_specular = color4( 0.4, 0.1, 0.1, 1.0 );
material_ambient = color4( 0.8, 0.5, 0.5, 1.0 );
material_diffuse = color4( 0.8, 0.2, 0.2, 1.0 );
material_specular = color4( 1.0, 1.0, 1.0, 1.0 );
material_shininess = 1.0;
glUniform4fv( AmbientProductLoc, 1, light_ambient * material_ambient );
glUniform4fv( DiffuseProductLoc, 1, light_diffuse * material_diffuse );
glUniform4fv( SpecularProductLoc, 1, light_specular * material_specular );
glUniform1f( ShininessLoc, material_shininess );
glUniform4fv( LightPositionLoc, 1, light_position );
float shading_type = 2;
glUniform1f(ShadingTypeLoc, shading_type);
glUniformMatrix4fv(TransformLoc, 1, GL_TRUE, center);
glDrawArrays( GL_TRIANGLES, 0, NumVertices );
light_position = point4( 0.0, 0.0, 0.0, 0.0 );
glUniform4fv( LightPositionLoc, 1, light_position );
glBindVertexArray( vao[1] );
// Draw planet One
light_ambient = color4( 0.2, 0.2, 0.2, 1.0 );
light_diffuse = color4( 1.0, 1.0, 1.0, 1.0 );
light_specular = color4( 1.0, 1.0, 1.0, 1.0 );
material_ambient = color4( 1.0, 1.0, 1.0, 1.0 );
material_diffuse = color4( 0.8, 0.8, 0.8, 1.0 );
material_specular = color4( 1.0, 1.0, 1.0, 1.0 );
material_shininess = 20.0;
shading_type = 1;
glUniform4fv( AmbientProductLoc, 1, light_ambient * material_ambient );
glUniform4fv( DiffuseProductLoc, 1, light_diffuse * material_diffuse );
glUniform4fv( SpecularProductLoc, 1, light_specular * material_specular );
glUniform1f( ShininessLoc, material_shininess );
glUniformMatrix4fv(TransformLoc, 1, GL_TRUE, planetOne);
glDrawArrays( GL_TRIANGLES, 0, NumVertices);
glBindVertexArray( vao[2] );
// Draw planet Two
light_ambient = color4( 0.2, 0.2, 0.2, 1.0 );
light_diffuse = color4( 1.0, 1.0, 1.0, 1.0 );
light_specular = color4( 1.0, 1.0, 1.0, 1.0 );
material_ambient = color4( 0.5, 0.8, 1.0, 1.0 );
material_diffuse = color4( 0.5, 0.8, 0.0, 1.0 );
material_specular = color4( 0.5, 0.8, 0.0, 1.0 );
material_shininess = 10.0;
shading_type = 1;
glUniform1f(ShadingTypeLoc, shading_type);
glUniform4fv( AmbientProductLoc, 1, light_ambient * material_ambient );
glUniform4fv( DiffuseProductLoc, 1, light_diffuse * material_diffuse );
glUniform4fv( SpecularProductLoc, 1, light_specular * material_specular );
glUniform1f( ShininessLoc, material_shininess );
glUniformMatrix4fv(TransformLoc, 1, GL_TRUE, planetTwo);
glDrawArrays( GL_TRIANGLES, 0, NumVertices);
glBindVertexArray( vao[3] );
// Draw planet Three
light_ambient = color4( 0.2, 0.2, 0.2, 1.0 );
light_diffuse = color4( 1.0, 1.0, 1.0, 1.0 );
light_specular = color4( 1.0, 1.0, 1.0, 1.0 );
material_ambient = color4( 0.5, 0.5, 1.0, 1.0 );
material_diffuse = color4( 0.5, 0.5, 1.0, 1.0 );
material_specular = color4( 0.5, 0.5, 1.0, 1.0 );
material_shininess = 10.0;
shading_type = 2;
glUniform1f(ShadingTypeLoc, shading_type);
glUniform4fv( AmbientProductLoc, 1, light_ambient * material_ambient );
glUniform4fv( DiffuseProductLoc, 1, light_diffuse * material_diffuse );
glUniform4fv( SpecularProductLoc, 1, light_specular * material_specular );
glUniform1f( ShininessLoc, material_shininess );
glUniformMatrix4fv(TransformLoc, 1, GL_TRUE, planetThree);
glDrawArrays( GL_TRIANGLES, 0, NumVertices);
glBindVertexArray( vao[4] );
// Draw planet Four
light_ambient = color4( 0.2, 0.2, 0.2, 1.0 );
light_diffuse = color4( 1.0, 1.0, 1.0, 1.0 );
light_specular = color4( 0.0, 0.0, 0.0, 1.0 );
material_ambient = color4( 0.55, 0.27, 0.07, 1.0 );
material_diffuse = color4( 0.55, 0.27, 0.07, 1.0 );
material_specular = color4( 0.0, 0.0, 0.0, 1.0 );
material_shininess = 5.0;
shading_type = 1;
glUniform1f(ShadingTypeLoc, shading_type);
glUniform4fv( AmbientProductLoc, 1, light_ambient * material_ambient );
glUniform4fv( DiffuseProductLoc, 1, light_diffuse * material_diffuse );
glUniform4fv( SpecularProductLoc, 1, light_specular * material_specular );
glUniform1f( ShininessLoc, material_shininess );
glUniformMatrix4fv(TransformLoc, 1, GL_TRUE, planetFour);
glDrawArrays( GL_TRIANGLES, 0, NumVertices);
glBindVertexArray( vao[5] );
// Draw planet Two's Moon
light_ambient = color4( 0.2, 0.2, 0.2, 1.0 );
light_diffuse = color4( 1.0, 1.0, 1.0, 1.0 );
light_specular = color4( 0.0, 0.0, 0.0, 1.0 );
material_ambient = color4( 0.33, 0.15, 0.07, 1.0 );
material_diffuse = color4( 0.55, 0.74, 0.07, 1.0 );
material_specular = color4( 0.0, 0.0, 0.0, 1.0 );
material_shininess = 10.0;
shading_type = 2;
glUniform1f(ShadingTypeLoc, shading_type);
glUniform4fv( AmbientProductLoc, 1, light_ambient * material_ambient );
glUniform4fv( DiffuseProductLoc, 1, light_diffuse * material_diffuse );
glUniform4fv( SpecularProductLoc, 1, light_specular * material_specular );
glUniform1f( ShininessLoc, material_shininess );
glUniformMatrix4fv(TransformLoc, 1, GL_TRUE, planetMoon);
glDrawArrays( GL_TRIANGLES, 0, NumVertices);
glutSwapBuffers();
}
// Called when the window is resized.
void callbackReshape(int width, int height)
{
//glViewport( 0, 0, width, height );
GLfloat left = -2.0, right = 2.0;
GLfloat top = 2.0, bottom = -2.0;
GLfloat aspect = GLfloat(width)/height;
if ( aspect > 1.0 ) {
left *= aspect;
right *= aspect;
}
else {
top /= aspect;
bottom /= aspect;
}
//mat4 projection = Ortho( left, right, bottom, top, zNear, zFar );
mat4 projection = Perspective(45.0, aspect, 0.5, 500);
glUniformMatrix4fv( Projection, 1, GL_TRUE, projection );
}
// Called for special keyboard inputs
void callbackSpecial(int key, int x, int y) {
// Look up (Rotate camera up)
if (key == GLUT_KEY_UP) {
static float u = 1;
model_view = RotateX(-u) * model_view;
altitudeAngle = reduceAngle(altitudeAngle + u);
//altitudeAngle += u;
}
// Decrease altitude
if (key == GLUT_KEY_DOWN) {
static float d = 1;
model_view = RotateX(d) * model_view;
altitudeAngle = reduceAngle(altitudeAngle - d);
//altitudeAngle -= d;
}
// Head left
if (key == GLUT_KEY_LEFT) {
static float l = 1;
model_view = RotateY(-l) * model_view;
azimuthAngle = reduceAngle(azimuthAngle + l);
//azimuthAngle += l;
}
// Head right
if (key == GLUT_KEY_RIGHT) {
static float r = 1;
model_view = RotateY(r) * model_view;
azimuthAngle = reduceAngle(azimuthAngle - r);
//azimuthAngle -= r;
}
glutPostRedisplay();
}
// Called when a key is pressed. x, y is the current mouse position.
void callbackKeyboard(unsigned char key, int x, int y)
{
// Exit application
if (key == 'q' || key == 'Q') {
exit(0);
}
// Translate forward
if (key == 'w' || key == 'W') {
//model_view = model_view * Translate(0.0, 0.0, 1.5);
model_view = Translate(0.0, 0.0, 1.5) * model_view;
}
// Translate backwards
if (key == 's' || key == 'S') {
//model_view = model_view * Translate(0.0, 0.0, -1.5);
model_view = Translate(0.0, 0.0, -1.5) * model_view;
}
// Translate left
if (key == 'a' || key == 'A') {
//model_view = model_view * Translate(1.5, 0.0, 0.0);
model_view = Translate(1.5, 0.0, 0.0) * model_view;
}
// Translate right
if (key == 'd' || key == 'D') {
//model_view = model_view * Translate(-1.5, 0.0, 0.0);
model_view = Translate(-1.5, 0.0, 0.0) * model_view;
}
// Translate up
if (key == 'o' || key == 'O') {
//model_view = model_view * Translate(0.0, -1.5, 0.0);
model_view = Translate(0.0, -1.5, 0.0) * model_view;
}
// Translate down
if (key == 'l' || key == 'L') {
//model_view = model_view * Translate(0.0, 1.5, 0.0);
model_view = Translate(0.0, 1.5, 0.0) * model_view;
}
// Reset the view
if (key == 'r' || key == 'R') {
model_view = initial_model_view;
azimuthAngle = 0;
altitudeAngle = -init_angle;
}
glutPostRedisplay();
}
// Called when a mouse button is pressed or released
void callbackMouse(int button, int state, int x, int y)
{
}
// Called when the mouse is moved with a button pressed
void callbackMotion(int x, int y)
{
}
// Called when the mouse is moved with no buttons pressed
void callbackPassiveMotion(int x, int y)
{
}
// Called when the system is idle. Can be called many times per frame.
void callbackIdle()
{
// Rotate planet One
planetOne = RotateY(thetaOne) * p1;
thetaOne += 0.25;
// Rotate planet Two
planetTwo = RotateY(thetaTwo) * p2;
thetaTwo += 0.10;
// Planet Two's moon
planetMoon = RotateY(thetaTwo) * p2trans * RotateY(thetaMoon) * Translate(5.0, 0, 0);
thetaMoon += 0.3;
// Rotate planet Three
planetThree = RotateY(thetaThree) * p3;
thetaThree += 0.08;
// Rotate planet Four
planetFour = RotateY(thetaFour) * p4;
thetaFour += 0.05;
vec4 dd = (RotateY(+azimuthAngle) * RotateX(+altitudeAngle) * model_view) * vec4(1.0, 1.0, 1.0, 1.0);
light_position = point4( -dd.x, -dd.y, -dd.z, 0.0 );
glutPostRedisplay();
}
// Called when the timer expires
void callbackTimer(int)
{
glutTimerFunc(1000/30, callbackTimer, 0);
glutPostRedisplay();
}
void initGlut(int& argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 50);
glutInitWindowSize(1200, 800);
glutCreateWindow("Assignment 3");
}
void initCallbacks()
{
glutDisplayFunc(callbackDisplay);
glutReshapeFunc(callbackReshape);
glutKeyboardFunc(callbackKeyboard);
glutSpecialFunc(callbackSpecial);
glutMouseFunc(callbackMouse);
glutMotionFunc(callbackMotion);
glutPassiveMotionFunc(callbackPassiveMotion);
glutIdleFunc(callbackIdle);
glutTimerFunc(1000/30, callbackTimer, 0);
}
int main(int argc, char** argv)
{
initGlut(argc, argv);
glewInit();
initCallbacks();
glutInitContextVersion( 3, 2 );
glutInitContextProfile( GLUT_CORE_PROFILE );
// Generate spheres (solar system)
init();
glutMainLoop();
}