-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtanques.cpp
2930 lines (2721 loc) · 144 KB
/
tanques.cpp
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
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sysexits.h>
#include <sys/time.h>
#include <GL/glut.h>
#include <TriMesh.h>
#include <png.h>
#include "objLoader.h"
#ifdef AUDIO
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#endif
#define DELAY_PBALA 500
#define MIN_A_CANNON 0.0
#define MAX_A_CANNON 85.0
#define MIN_A_TURRET -120.0
#define MAX_A_TURRET 120.0
#define MIN_V_PBALA 0.01
#define MAX_V_PBALA 0.10
#define N_DELTAS 50
#define N_BALAS 2
#define N_PBALAS 3
#define MIN_BALA_LIGHT 3
#define H_TABLERO 250.0
#define W_TABLERO 250.0
#define D_TABLERO 2.0
#define H_WALL 10.0
#define W_WALL 7.5
#define D_WALL 1.0
#define V_WALL 1
#define L_WALL 3.0
#define H_TANQUE 1.5
#define W_TANQUE 5.0
#define D_TANQUE 1.5
#define H_SEGMENT 2.0
#define W_SEGMENT 5.0
#define W_SEGMENT_T 1.0
#define V_X 0.0020
#define V_Y 0.0020
#define V_BALA_MAX 0.0425
#define V_BALA_MIN 0.0150
#define V_NAVE 0.01
#define V_FACTOR 1.15
#define T_BALA 1000
#define T_NAVE 3000
#define DIGITS_SCORE 2
#define PTS_WALL (-30)
#define COSA 3
#define LIVES 0
#define BALAS 10
#define N_BOOMS 50
#define N_BOOM_SETS 10
#define T_BOOM 3000
#define GRAVEDAD (-0.00003)
#define N_DIVS 30
#define N_DIVS_HD 300
#define L_CANNON 2.5
#define D_CANNON 0.5
#define N_SLICES_RINGBASE 12
#define N_SLICES 36
#define N_LOOPS 10
#define W_BARRA 0.25
#define H_BARRA 0.50
#define TURRET_Z -0.782
#define THREAD_X 2.83
#define CANNON_Y 3.826
#define CANNON_Z 3.252
#define H_LIGHT_TABLERO 25.0
#define H_OVERHEAD 50.0
#define N_LISTS 15
#define T_CAM_OLD 500.0
#define T_RINGS 5000.0
#define H_RINGBASE 0.3
#define H_RING 1.0
#define D_RING 10.0
#define S_RING 1.0
#define D_RING_GLOW 2.0
#define BLUR_TEXTURE_SIZE 512
#define N_BLURS 8
#define D_BLUR 0.05
#define BOOM_SCALE 0.2
int cuadrado, cuadrado_hd, cuadrado_simple, cubo, cubo_simple, checker, borde, light_cone, bala, segmento, barra, cielo, veleta, ringbase, ring;
enum mesh_enum {
MESH_BRAIN = 0,
MESH_SPIDER,
MESH_TIE,
MESH_TANK,
MESH_TURRET,
MESH_CANNON,
MESH_T0,
MESH_T1,
MESH_T2,
MESH_T3,
MESH_T4,
MESH_T5,
MESH_T6,
MESH_T7,
MESH_T8,
MESH_T9
};
#define N_MESH (MESH_T9+1)
enum cam_enum {
CAM_OVERHEAD = 0,
CAM_FPS,
CAM_TPS,
CAM_MANUAL,
CAM_RINGS
};
#define N_CAMS 4
/*
GLfloat vx1 = 0;
GLfloat vx2 = 0;
GLfloat vy1 = 0;
GLfloat vy2 = 0;
GLfloat vz1 = 0;
GLfloat vz2 = 0;
*/
int ww = 800;
int wh = 600;
int pass;
enum passes {
PASS_BLUR = 0,
PASS_LAST
};
#define FIRST_PASS PASS_BLUR
#define N_PASSES 2
int level;
enum levels {
LEVEL_DESERT = 0,
LEVEL_SKY,
LEVEL_SPACE
};
#define START_LEVEL LEVEL_DESERT
#define N_LEVELS 3
GLfloat aspectratio = 4.0/3.0;
GLfloat fov = 60.0;
GLfloat znear = 0.01;
GLfloat zfar = 1000.0;
GLfloat cam_x = 0.0;
GLfloat cam_y = 0.0;
GLfloat cam_z = 12.0;
GLfloat cam_rotx = 0.0;
GLfloat cam_roty = 0.0;
GLfloat cam_old_x;
GLfloat cam_old_y;
GLfloat cam_old_z;
GLfloat cam_old_rotx;
GLfloat cam_old_roty;
int cam_old_t;
int cam_old_adj;
int key_fwd = 'w';
int key_back = 's';
int key_left = 'a';
int key_right = 'd';
int key_use_l = 'q';
int key_use_r = 'e';
int key_lights_up = '.';
int key_lights_down = ',';
int key_cam_up = 'p';
int key_cam_down = ';';
int key_cam_left = 'j';
int key_cam_right = 'l';
int key_cam_fwd = 'i';
int key_cam_back = 'k';
int key_cam_rotup = 'y';
int key_cam_rotdown = 'h';
int key_cam_rotleft = 'u';
int key_cam_rotright = 'o';
int key_cam_switch = '\t';
int key_shoot = ' ';
int key_enter = 13;
int key_blur_toggle = 'b';
int keystate_fwd = 0;
int keystate_back = 0;
int keystate_left = 0;
int keystate_right = 0;
int keystate_use_l = 0;
int keystate_use_r = 0;
int keystate_lights_up = 0;
int keystate_lights_down = 0;
int keystate_cam_up = 0;
int keystate_cam_down = 0;
int keystate_cam_left = 0;
int keystate_cam_right = 0;
int keystate_cam_fwd = 0;
int keystate_cam_back = 0;
int keystate_cam_rotup = 0;
int keystate_cam_rotdown = 0;
int keystate_cam_rotleft = 0;
int keystate_cam_rotright = 0;
int keystate_shoot = 0;
int keystate_enter = 0;
int keystate_l = 0;
int keystate_r = 0;
int keystate_u = 0;
int keystate_d = 0;
int cosa = 0;
int cam = 0;
int posneg;
int deltas[N_DELTAS];
int deltas_cur = 0;
int deltas_sum = 0;
int delta;
int delay = 0;
int new_time;
int old_time;
float max_frame_delay;
float frame_delay;
int bala_t;
int frozen;
int rings_t;
int rings_s;
int rings_d;
int old_cam;
float windx, windy;
#ifdef AUDIO
int key_music = 'm';
int keystate_music = 0;
Mix_Chunk *phaser = NULL;
Mix_Chunk *motorL = NULL;
Mix_Chunk *motorC = NULL;
Mix_Chunk *moveL = NULL;
Mix_Chunk *moveC = NULL;
Mix_Chunk *reverseL = NULL;
Mix_Chunk *reverseC = NULL;
Mix_Chunk *fireL = NULL;
Mix_Chunk *fireC = NULL;
Mix_Chunk *turretL = NULL;
Mix_Chunk *turretC = NULL;
Mix_Chunk *exploL = NULL;
Mix_Chunk *exploC = NULL;
Mix_Chunk *buho = NULL;
Mix_Music *music = NULL;
int musicflag;
int motorChannel;
int moveChannel = -1;
int reverseChannel = -1;
//TODO: Esto es necesario?
int fireChannel = -1;
int turretChannel = -1;
int exploChannel = -1;
#endif
GLfloat black4f[4] = {0, 0, 0, 1};
GLfloat white4f[4] = {1, 1, 1, 1};
GLfloat light_pos[4] = {0, 0, 0, 1};
GLfloat light_diffuse[4] = {1, 1, 1, 1};
GLfloat bala_light_diffuse[4] = {1, 1, 0.8, 1};
GLfloat bala_light_dir[3] = {0, 0, 0};
GLfloat bala_light_pos[4] = {0, 0, 0, 1};
GLubyte color_ss_on[4] = {255, 0, 0, 160};
GLubyte color_ss_off[4] = { 50, 0, 0, 160};
GLubyte color_borde[4] = { 90, 60, 30, 255};
GLubyte color_mesa[4] = { 45, 130, 70, 255};
GLubyte color_inicial[4] = {124, 252, 0, 255};
GLubyte color_medio[4] = {255, 235, 0, 255};
GLubyte color_lleno[4] = {255, 0, 0, 255};
GLubyte color_empty[4] = {139, 136, 120, 255};
struct mesh_data {
int list;
float size_x, size_y, size_z;
float xm, ym, zm;
float xM, yM, zM;
} mesh[N_MESH];
struct boom_data {
float x[N_BOOMS];
float y[N_BOOMS];
float z[N_BOOMS];
float rx[N_BOOMS];
float ry[N_BOOMS];
float rz[N_BOOMS];
float a[N_BOOMS];
float s[N_BOOMS];
float vx[N_BOOMS];
float vy[N_BOOMS];
float vz[N_BOOMS];
float va[N_BOOMS];
float r[N_BOOMS];
float g[N_BOOMS];
float b[N_BOOMS];
int on;
int level;
} boom[N_BOOM_SETS];
int nboom;
/*
struct wall {
float x, y, z;
int life;
int pts;
} w[N_WALLS];
*/
bool blur;
float px, py, pz, prz, pv, pvx, pvy, pvz, pvrz;
float thread_l, thread_r;
float v_x;
float v_y;
float v_cannon;
float a_cannon; // TODO: velocidad e inercia para el cañón?
float a_turret; // TODO: velocidad e inercia para la torreta?
float retract;
int pb[N_PBALAS];
int pbl[N_PBALAS];
float pbx[N_PBALAS], pby[N_PBALAS], pbz[N_PBALAS], pbvx[N_PBALAS], pbvy[N_PBALAS], pbvz[N_PBALAS];
float pbv[N_PBALAS];
int pbi, pbn;
int win;
int lose;
int c_bala, c_nave;
int pts;
int bi;
float bx[N_BALAS];
float by[N_BALAS];
float bz[N_BALAS];
int b[N_BALAS];
int bl[N_BALAS];
int i, j, k;
int lives;
int balas;
float light_intensity;
float headlights;
int ss[12][7] = {
{1, 1, 1, 1, 1, 1, 0}, /* 0 */
{0, 1, 1, 0, 0, 0, 0}, /* 1 */
{1, 1, 0, 1, 1, 0, 1}, /* 2 */
{1, 1, 1, 1, 0, 0, 1}, /* 3 */
{0, 1, 1, 0, 0, 1, 1}, /* 4 */
{1, 0, 1, 1, 0, 1, 1}, /* 5 */
{1, 0, 1, 1, 1, 1, 1}, /* 6 */
{1, 1, 1, 0, 0, 0, 0}, /* 7 */
{1, 1, 1, 1, 1, 1, 1}, /* 8 */
{1, 1, 1, 1, 0, 1, 1}, /* 9 */
{0, 0, 0, 0, 0, 0, 1}, /* - */
{0, 0, 0, 0, 0, 0, 0} /* */
};
int segs[12];
GLubyte *tstars_img, *tdesert_img, *tcielo_img, *tbumpmetal_img, *tbrushmetal_img, *troca_img, *tcamobump_img, *tcamoline_img, *ttriangles_img, *tplates_img, *tblue_img, *trust_img, *tcorroded_img, *tcarved_img;
GLuint tstars, tdesert, tcielo, tbumpmetal, tbrushmetal, troca, tcamobump, tcamoline , ttriangles , tplates , tblue , trust , tcorroded , tcarved;
GLuint tblur;
int tw, th, ta;
int power(int b, unsigned int e) {
int r = 1;
for (; e > 0; e--) {
r *= b;
}
return r;
}
int loadPNG(char *name, int *outWidth, int *outHeight, int *outHasAlpha, GLubyte **outData) {
png_structp png_ptr;
png_infop info_ptr;
unsigned int sig_read = 0;
FILE *fp;
if (outWidth == NULL || outHeight == NULL || outHasAlpha == NULL) return -1;
if ((fp = fopen(name, "rb")) == NULL) return -1;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) {
fclose(fp);
return -1;
}
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return -1;
}
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fclose(fp);
return -1;
}
png_init_io(png_ptr, fp);
png_set_sig_bytes(png_ptr, sig_read);
png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_EXPAND, png_voidp_NULL);
*outWidth = info_ptr->width;
*outHeight = info_ptr->height;
switch (info_ptr->color_type) {
case PNG_COLOR_TYPE_RGBA:
*outHasAlpha = 1;
break;
case PNG_COLOR_TYPE_RGB:
*outHasAlpha = 0;
break;
default:
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
fclose(fp);
return false;
}
unsigned int row_bytes = png_get_rowbytes(png_ptr, info_ptr);
*outData = (unsigned char*) malloc(row_bytes * (*outHeight));
png_bytepp row_pointers = png_get_rows(png_ptr, info_ptr);
for (int i = 0; i < *outHeight; i++) {
memcpy(*outData + (row_bytes*((*outHeight) - 1 - i)), row_pointers[i], row_bytes);
}
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fclose(fp);
return 1;
}
void initJuego() {
#ifdef AUDIO
musicflag = 0;
Mix_ExpireChannel(motorChannel, 1);
if(cam>0){
motorChannel = Mix_PlayChannel(-1, motorC, -1);
}
else{
motorChannel = Mix_PlayChannel(-1, motorL, -1);
}
#endif
nboom = 0;
for (i = 0; i < N_BOOM_SETS; i++) {
boom[i].on = 0;
}
frozen = 0;
level = START_LEVEL;
rings_t = 0;
bala_t = 0;
cam_old_t = 0;
headlights = 0.5;
px = 0;
py = 0;
pz = -mesh[MESH_T0].ym;
pv = 0;
prz = 0;
pvx = 0;
pvy = 0;
pvz = 0;
pvrz = 0;
thread_l = 0;
thread_r = 0;
v_x = V_X;
v_y = V_Y;
pbi = 0;
pbn = 0;
for (i = 0; i < N_PBALAS; i++) {
pb[i] = 0;
pbv[i] = V_BALA_MAX;
}
win = 0;
lose = 0;
pts = 0;
lives = LIVES + 1;
balas = BALAS;
c_bala = 0;
c_nave = 0;
a_turret = 0;
a_cannon = 20;
v_cannon = V_BALA_MIN;
retract = 1;
bi = 0;
for (i = 0; i < N_BALAS; i++) {
b[i] = 0;
}
// windx = (0.5 - (((float)rand())/((float)RAND_MAX)));
// windy = (0.5 - (((float)rand())/((float)RAND_MAX)));
windx = 0;
windy = 0;
posneg = 0;
}
void buildLists() {
int p;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &tblur);
glBindTexture(GL_TEXTURE_2D, tblur);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
{
int size = 4 * BLUR_TEXTURE_SIZE * BLUR_TEXTURE_SIZE * sizeof(GLuint);
GLuint *tblur_data = (GLuint *)malloc(size);
memset(tblur_data, 0, size);
glTexImage2D(GL_TEXTURE_2D, 0, 4, BLUR_TEXTURE_SIZE, BLUR_TEXTURE_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, tblur_data);
free(tblur_data);
}
glGenTextures(1, &tstars);
glBindTexture(GL_TEXTURE_2D, tstars);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/stars.png", &tw, &th, &ta, &tstars_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tstars_img);
glGenTextures(1, &tdesert);
glBindTexture(GL_TEXTURE_2D, tdesert);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/desert.png", &tw, &th, &ta, &tdesert_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tdesert_img);
glGenTextures(1, &tcielo);
glBindTexture(GL_TEXTURE_2D, tcielo);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/cielo.png", &tw, &th, &ta, &tcielo_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tcielo_img);
glGenTextures(1, &troca);
glBindTexture(GL_TEXTURE_2D, troca);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/roca.png", &tw, &th, &ta, &troca_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, troca_img);
glGenTextures(1, &tbumpmetal);
glBindTexture(GL_TEXTURE_2D, tbumpmetal);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/bumpmetal.png", &tw, &th, &ta, &tbumpmetal_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tbumpmetal_img);
glGenTextures(1, &tbrushmetal);
glBindTexture(GL_TEXTURE_2D, tbrushmetal);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/brushmetal.png", &tw, &th, &ta, &tbrushmetal_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tbrushmetal_img);
glGenTextures(1, &tcamobump);
glBindTexture(GL_TEXTURE_2D, tcamobump);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/camobump.png", &tw, &th, &ta, &tcamobump_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tcamobump_img);
glGenTextures(1, &tcamoline);
glBindTexture(GL_TEXTURE_2D, tcamoline);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/camoline.png", &tw, &th, &ta, &tcamoline_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tcamoline_img);
glGenTextures(1, &tplates);
glBindTexture(GL_TEXTURE_2D, tplates);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/plates.png", &tw, &th, &ta, &tplates_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tplates_img);
glGenTextures(1, &tcorroded);
glBindTexture(GL_TEXTURE_2D, tcorroded);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/corroded.png", &tw, &th, &ta, &tcorroded_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tcorroded_img);
glGenTextures(1, &trust);
glBindTexture(GL_TEXTURE_2D, trust);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/rust.png", &tw, &th, &ta, &trust_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, trust_img);
glGenTextures(1, &tblue);
glBindTexture(GL_TEXTURE_2D, tblue);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/blue.png", &tw, &th, &ta, &tblue_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tblue_img);
glGenTextures(1, &ttriangles);
glBindTexture(GL_TEXTURE_2D, ttriangles);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/triangles.png", &tw, &th, &ta, &ttriangles_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, ttriangles_img);
glGenTextures(1, &tcarved);
glBindTexture(GL_TEXTURE_2D, tcarved);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
loadPNG((char *)"png/carved.png", &tw, &th, &ta, &tcarved_img);
glTexImage2D(GL_TEXTURE_2D, 0, ta ? 4 : 3, tw, th, 0, ta ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, tcarved_img);
if ((cuadrado = glGenLists(N_LISTS + 12 + N_MESH)) == 0) exit(EX_OSERR);
cuadrado_hd = cuadrado + 1;
cuadrado_simple = cuadrado + 2;
cubo = cuadrado + 3;
cubo_simple = cuadrado + 4;
checker = cuadrado + 5;
borde = cuadrado + 6;
bala = cuadrado + 7;
barra = cuadrado + 8;
cielo = cuadrado + 9;
veleta = cuadrado + 10;
segmento = cuadrado + 11;
ringbase = cuadrado + 12;
ring = cuadrado + 13;
light_cone = cuadrado + 14;
for (i = 0; i <= 11; i++) {
segs[i] = cuadrado + N_LISTS + i;
}
for (i = 0; i < N_MESH; i++) {
mesh[i].list = N_LISTS + 12 + i;
}
glNewList(cuadrado, GL_COMPILE);
glBegin(GL_TRIANGLES);
glNormal3f(0, 0, 1);
for (i = 0; i < N_DIVS; i++) {
for (j = 0; j < N_DIVS; j++) {
glTexCoord2f( (((float)(i ))/((float)N_DIVS)), (((float)(j ))/((float)N_DIVS)) );
glVertex3f(-0.5 + (((float)(i ))/((float)N_DIVS)), -0.5 + (((float)(j ))/((float)N_DIVS)), 0.0);
glTexCoord2f( (((float)(i + 1))/((float)N_DIVS)), (((float)(j ))/((float)N_DIVS)) );
glVertex3f(-0.5 + (((float)(i + 1))/((float)N_DIVS)), -0.5 + (((float)(j ))/((float)N_DIVS)), 0.0);
glTexCoord2f( (((float)(i + 1))/((float)N_DIVS)), (((float)(j + 1))/((float)N_DIVS)) );
glVertex3f(-0.5 + (((float)(i + 1))/((float)N_DIVS)), -0.5 + (((float)(j + 1))/((float)N_DIVS)), 0.0);
glTexCoord2f( (((float)(i + 1))/((float)N_DIVS)), (((float)(j + 1))/((float)N_DIVS)) );
glVertex3f(-0.5 + (((float)(i + 1))/((float)N_DIVS)), -0.5 + (((float)(j + 1))/((float)N_DIVS)), 0.0);
glTexCoord2f( (((float)(i ))/((float)N_DIVS)), (((float)(j + 1))/((float)N_DIVS)) );
glVertex3f(-0.5 + (((float)(i ))/((float)N_DIVS)), -0.5 + (((float)(j + 1))/((float)N_DIVS)), 0.0);
glTexCoord2f( (((float)(i ))/((float)N_DIVS)), (((float)(j ))/((float)N_DIVS)) );
glVertex3f(-0.5 + (((float)(i ))/((float)N_DIVS)), -0.5 + (((float)(j ))/((float)N_DIVS)), 0.0);
}
}
glEnd();
glEndList();
glNewList(cuadrado_hd, GL_COMPILE);
glBegin(GL_TRIANGLES);
glNormal3f(0, 0, 1);
for (i = 0; i < N_DIVS_HD; i++) {
for (j = 0; j < N_DIVS_HD; j++) {
glTexCoord2f( (((float)(i ))/((float)N_DIVS_HD)), (((float)(j ))/((float)N_DIVS_HD)) );
glVertex3f(-0.5 + (((float)(i ))/((float)N_DIVS_HD)), -0.5 + (((float)(j ))/((float)N_DIVS_HD)), 0.0);
glTexCoord2f( (((float)(i + 1))/((float)N_DIVS_HD)), (((float)(j ))/((float)N_DIVS_HD)) );
glVertex3f(-0.5 + (((float)(i + 1))/((float)N_DIVS_HD)), -0.5 + (((float)(j ))/((float)N_DIVS_HD)), 0.0);
glTexCoord2f( (((float)(i + 1))/((float)N_DIVS_HD)), (((float)(j + 1))/((float)N_DIVS_HD)) );
glVertex3f(-0.5 + (((float)(i + 1))/((float)N_DIVS_HD)), -0.5 + (((float)(j + 1))/((float)N_DIVS_HD)), 0.0);
glTexCoord2f( (((float)(i + 1))/((float)N_DIVS_HD)), (((float)(j + 1))/((float)N_DIVS_HD)) );
glVertex3f(-0.5 + (((float)(i + 1))/((float)N_DIVS_HD)), -0.5 + (((float)(j + 1))/((float)N_DIVS_HD)), 0.0);
glTexCoord2f( (((float)(i ))/((float)N_DIVS_HD)), (((float)(j + 1))/((float)N_DIVS_HD)) );
glVertex3f(-0.5 + (((float)(i ))/((float)N_DIVS_HD)), -0.5 + (((float)(j + 1))/((float)N_DIVS_HD)), 0.0);
glTexCoord2f( (((float)(i ))/((float)N_DIVS_HD)), (((float)(j ))/((float)N_DIVS_HD)) );
glVertex3f(-0.5 + (((float)(i ))/((float)N_DIVS_HD)), -0.5 + (((float)(j ))/((float)N_DIVS_HD)), 0.0);
}
}
glEnd();
glEndList();
glNewList(cuadrado_simple, GL_COMPILE);
glBegin(GL_TRIANGLES);
glNormal3f(0, 0, 1);
glTexCoord2f(0, 0); glVertex3f(-0.5, -0.5, 0.0);
glTexCoord2f(1, 0); glVertex3f( 0.5, -0.5, 0.0);
glTexCoord2f(1, 1); glVertex3f( 0.5, 0.5, 0.0);
glTexCoord2f(1, 1); glVertex3f( 0.5, 0.5, 0.0);
glTexCoord2f(0, 1); glVertex3f(-0.5, 0.5, 0.0);
glTexCoord2f(0, 0); glVertex3f(-0.5, -0.5, 0.0);
glEnd();
glEndList();
glNewList(cubo, GL_COMPILE);
glPushMatrix();
glTranslatef(0, 0, 0.5);
glCallList(cuadrado);
glPopMatrix();
glPushMatrix();
glTranslatef(0, 0, -0.5);
glRotatef(180, 0, 1, 0);
glCallList(cuadrado);
glPopMatrix();
glPushMatrix();
glTranslatef(0, 0.5, 0);
glRotatef(-90, 1, 0, 0);
glCallList(cuadrado);
glPopMatrix();
glPushMatrix();
glTranslatef(0, -0.5, 0);
glRotatef(90, 1, 0, 0);
glCallList(cuadrado);
glPopMatrix();
glPushMatrix();
glTranslatef(0.5, 0, 0);
glRotatef(90, 0, 1, 0);
glCallList(cuadrado);
glPopMatrix();
glPushMatrix();
glTranslatef(-0.5, 0, 0);
glRotatef(-90, 0, 1, 0);
glCallList(cuadrado);
glPopMatrix();
glEndList();
glNewList(cubo_simple, GL_COMPILE);
glPushMatrix();
glTranslatef(0, 0, 0.5);
glCallList(cuadrado_simple);
glPopMatrix();
glPushMatrix();
glTranslatef(0, 0, -0.5);
glRotatef(180, 0, 1, 0);
glCallList(cuadrado_simple);
glPopMatrix();
glPushMatrix();
glTranslatef(0, 0.5, 0);
glRotatef(-90, 1, 0, 0);
glCallList(cuadrado_simple);
glPopMatrix();
glPushMatrix();
glTranslatef(0, -0.5, 0);
glRotatef(90, 1, 0, 0);
glCallList(cuadrado_simple);
glPopMatrix();
glPushMatrix();
glTranslatef(0.5, 0, 0);
glRotatef(90, 0, 1, 0);
glCallList(cuadrado_simple);
glPopMatrix();
glPushMatrix();
glTranslatef(-0.5, 0, 0);
glRotatef(-90, 0, 1, 0);
glCallList(cuadrado_simple);
glPopMatrix();
glEndList();
glNewList(checker, GL_COMPILE);
glBegin(GL_QUADS);
glNormal3f(0, 1, 0);
p = 0;
for (i = -100; i < 100; i += 1) {
for (j = -100; j < 100; j++) {
p ^= 1;
if (p) continue;
glVertex3f(i , 0, j );
glVertex3f(i + 1, 0, j );
glVertex3f(i + 1, 0, j + 1);
glVertex3f(i , 0, j + 1);
}
p ^= 1;
}
glEnd();
glEndList();
glNewList(borde, GL_COMPILE);
glPushMatrix();
glTranslatef(0, H_TABLERO / 2.0, 0);
glScalef(W_TABLERO + (2 * D_TABLERO), D_TABLERO, 1);
glTranslatef(0, 0.5, 0);
glColor4ubv(color_borde);
glCallList(cubo);
glPopMatrix();
glPushMatrix();
glTranslatef(0, -H_TABLERO / 2.0, 0);
glScalef(W_TABLERO + (2 * D_TABLERO), D_TABLERO, 1);
glTranslatef(0, -0.5, 0);
glColor4ubv(color_borde);
glCallList(cubo);
glPopMatrix();
glPushMatrix();
glTranslatef(W_TABLERO / 2.0, 0, 0);
glScalef(D_TABLERO, H_TABLERO, 1);
glTranslatef(0.5, 0, 0);
glColor4ubv(color_borde);
glCallList(cubo);
glPopMatrix();
glPushMatrix();
glTranslatef(-W_TABLERO / 2.0, 0, 0);
glScalef(D_TABLERO, H_TABLERO, 1);
glTranslatef(-0.5, 0, 0);
glColor4ubv(color_borde);
glCallList(cubo);
glPopMatrix();
glEndList();
glNewList(bala, GL_COMPILE);
glPushMatrix();
glScalef(D_CANNON, L_CANNON, D_CANNON);
glRotatef(-90, 1, 0, 0);
glTranslatef(0, 0, -0.55);
{
GLUquadric *quad = gluNewQuadric();
gluQuadricTexture(quad, GL_TRUE);
gluQuadricDrawStyle(quad, GLU_FILL);
gluQuadricNormals(quad, GLU_SMOOTH);
glPushMatrix();
gluQuadricOrientation(quad, GLU_INSIDE);
gluDisk(quad, 0, 0.6, N_SLICES, N_LOOPS);
gluQuadricOrientation(quad, GLU_OUTSIDE);
gluCylinder(quad, 0.6, 0.6, 1.0/3.0, N_SLICES, N_LOOPS);
glTranslatef(0, 0, 1.0/3.0);
gluCylinder(quad, 0.6, 0, 1.0/6.0, N_SLICES, N_LOOPS);
glPopMatrix();
gluDeleteQuadric(quad);
}
glPopMatrix();
glEndList();
glNewList(barra, GL_COMPILE);
glPushMatrix();
glBegin(GL_QUADS);
glVertex3f(-1, -1, 0);
glVertex3f( 1, -1, 0);
glVertex3f( 1, 1, 0);
glVertex3f(-1, 1, 0);
glEnd();
glPopMatrix();
glEndList();
glNewList(cielo, GL_COMPILE);
{
GLUquadric *quad = gluNewQuadric();
gluQuadricTexture(quad, GL_TRUE);
gluQuadricDrawStyle(quad, GLU_FILL);
gluQuadricNormals(quad, GLU_SMOOTH);
gluQuadricOrientation(quad, GLU_INSIDE);
gluSphere(quad, 400.0, 100, 100);
gluDeleteQuadric(quad);
}
glEndList();
glNewList(veleta, GL_COMPILE);
{
GLUquadric *quad = gluNewQuadric();
gluQuadricTexture(quad, GL_TRUE);
gluQuadricDrawStyle(quad, GLU_FILL);
gluQuadricNormals(quad, GLU_SMOOTH);
gluQuadricOrientation(quad, GLU_OUTSIDE);
for (i = 0; i < 10; i++) {
if (i % 2 == 0) glColor4ub(255, 70, 0, 255);
else glColor4ub(255, 255, 255, 255);
gluCylinder(quad, 1.0 - 0.1 * i, 0.9 - 0.1 * i, 0.1, N_SLICES, N_LOOPS);
glTranslatef(0, 0, 0.1);
}
gluDeleteQuadric(quad);
}
glEndList();
glNewList(segmento, GL_COMPILE);
glBegin(GL_TRIANGLES);
glVertex3f(-W_SEGMENT / 2.0 , H_SEGMENT / 2.0, 0);
glVertex3f(-W_SEGMENT / 2.0 - W_SEGMENT_T, 0, 0);
glVertex3f(-W_SEGMENT / 2.0 , -H_SEGMENT / 2.0, 0);
glVertex3f( W_SEGMENT / 2.0, H_SEGMENT / 2.0, 0);
glVertex3f(-W_SEGMENT / 2.0, H_SEGMENT / 2.0, 0);
glVertex3f(-W_SEGMENT / 2.0, -H_SEGMENT / 2.0, 0);
glVertex3f(-W_SEGMENT / 2.0, -H_SEGMENT / 2.0, 0);
glVertex3f( W_SEGMENT / 2.0, -H_SEGMENT / 2.0, 0);
glVertex3f( W_SEGMENT / 2.0, H_SEGMENT / 2.0, 0);
glVertex3f( W_SEGMENT / 2.0 , -H_SEGMENT / 2.0, 0);
glVertex3f( W_SEGMENT / 2.0 + W_SEGMENT_T, 0 , 0);
glVertex3f( W_SEGMENT / 2.0 , H_SEGMENT / 2.0, 0);
glEnd();
glLineWidth(1);
glBegin(GL_LINE_LOOP);
glColor4ub(0, 0, 0, 255);
glVertex3f(-W_SEGMENT / 2.0 , H_SEGMENT / 2.0, 0);
glVertex3f(-W_SEGMENT / 2.0 - W_SEGMENT_T, 0, 0);
glVertex3f(-W_SEGMENT / 2.0 , -H_SEGMENT / 2.0, 0);
glVertex3f( W_SEGMENT / 2.0 , -H_SEGMENT / 2.0, 0);
glVertex3f( W_SEGMENT / 2.0 + W_SEGMENT_T, 0, 0);
glVertex3f( W_SEGMENT / 2.0 , H_SEGMENT / 2.0, 0);
glEnd();
glEndList();
glNewList(ringbase, GL_COMPILE);
glPushMatrix();
glScalef(D_RING, D_RING, H_RINGBASE * 10.0);
glMatrixMode(GL_TEXTURE);
glScalef(10, 10, 1);
glMatrixMode(GL_MODELVIEW);
glColor4ub(127, 127, 127, 255);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, tplates);
glEnable(GL_TEXTURE_2D);
glTranslatef(0, 0, -0.05);
{
GLUquadric *quad = gluNewQuadric();
gluQuadricTexture(quad, GL_TRUE);
gluQuadricDrawStyle(quad, GLU_FILL);
gluQuadricNormals(quad, GLU_SMOOTH);
gluQuadricOrientation(quad, GLU_INSIDE);
gluDisk(quad, 0.8, 1.0, N_SLICES_RINGBASE, N_LOOPS);
glMatrixMode(GL_TEXTURE);
glScalef(4, 0.1, 1);
glMatrixMode(GL_MODELVIEW);
gluCylinder(quad, 0.8, 0.8, 0.1, N_SLICES_RINGBASE, 1);
gluQuadricOrientation(quad, GLU_OUTSIDE);
gluCylinder(quad, 1.0, 1.0, 0.1, N_SLICES_RINGBASE, 1);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glScalef(10, 10, 1);
glMatrixMode(GL_MODELVIEW);
glTranslatef(0, 0, 0.1);
gluDisk(quad, 0.8, 1.0, N_SLICES_RINGBASE, N_LOOPS);
glTranslatef(0, 0, -0.05);
glBindTexture(GL_TEXTURE_2D, tcarved);
glMatrixMode(GL_TEXTURE);
glScalef(0.5, 0.5, 1);
gluDisk(quad, 0.0, 1.0, N_SLICES_RINGBASE, N_LOOPS);
glMatrixMode(GL_MODELVIEW);
gluDeleteQuadric(quad);
}
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEndList();
glNewList(ring, GL_COMPILE);
glPushMatrix();
glScalef(D_RING, D_RING, H_RING * 10.0);
glMatrixMode(GL_TEXTURE);
glScalef(10, 10, 1);
glMatrixMode(GL_MODELVIEW);
glColor4ub(127, 127, 127, 255);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, trust);
glEnable(GL_TEXTURE_2D);
{
GLUquadric *quad = gluNewQuadric();
gluQuadricTexture(quad, GL_TRUE);
gluQuadricDrawStyle(quad, GLU_FILL);