Bonjour a tous,

j'ai un problème de compilation d'un projet openGL. (Sa fait une éternité que j'ai pas fait de C alors soyer indulgent :-° )


voici ce que j'ai comme code:

salle.c
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
#include "header.h"
 
 
//angle de la vue
double beta=0;
double alpha=0.2;
 
//distance de la camera au point vise
double distance_du_point_vise=100;
 
//Position de la souris au dernier recalcul
double x_pos_souris=0;
double y_pos_souris=0;
 
//Position de la vue
double x_obs=-100.0;
double y_obs=175.0;
double z_obs=-100.0;
 
double x_vise=605.0/2.0;
double y_vise=275.0/2.0;
double z_vise=976.0/2.0;
 
double x_ass=0.0;
double y_ass=1.0;
double z_ass=0.0;
 
double teta=0.0;
 
GLuint table, salle,chaise,clavier,tour,ecran, chaisePlace,clavierPlace,tourPlace,ecranPlace;
 
//id des textures :
GLuint texture_ecran, texture_chaise, texture_table, texture_sol, texture_clavier, texture_plafond, texture_tour;
/**
 * Dimension des element d'une table
 */
//les pied
float largeurPied=5.;
float hauteurPied=70.0;
float longueurPied=5.0;
//le plateau
float largeurPlateau=80.;
float hauteurPlateau=2.;
float longueurPlateau=160.;
 
/**
 * Dimension de la salle
 */
float longueurSalle=976.0;
float hauteurSalle=275.0;
float largeurSalle=605.0;
 
/**
 * Dimension de la chaise
 */
 
//les pieds
float largeurPiedChaise=5.;
float hauteurPiedChaise=50.0;
float longueurPiedChaise=5.0;
 
//le dossier
float largeurDossierChaise=2.;
float hauteurDossierChaise=50.;
float longueurDossierChaise=50.;
 
//le plateau
float longueurPlateauChaise=50.0;
float hauteurPlateauChaise=2.0;
float largeurPlateauChaise=50.0;
 
 
/**
 * Dimension Clavier
 */
float longueurClavier=22.5;
float hauteurClavier=3.0;
float largeurClavier=49.5;
 
 
/**
 * Dimension Tour
 */
float longueurTour=50.;
float hauteurTour=60.;
float largeurTour=25.;
 
/**
 * Dimension Ecran
 */
 
// base ecran
float longueurBaseEcran=20.;
float hauteurBaseEcran=5.;
float largeurBaseEcran=35.;
 
// pied ecran
float longueurPiedEcran=5.;
float hauteurPiedEcran=7.5;
float largeurPiedEcran=15.;
 
// dalle ecran
float longueurDalleEcran=5.;
float hauteurDalleEcran=30.;
float largeurDalleEcran=45.;
 
/**************** FONCTION DE CREATION DE LISTE *********************/
 
 
/**
 * Fonction qui permet de créer la liste de l'ecran
 */
void creerListeEcran(){
	ecran=glGenLists(1);
	glNewList(ecran, GL_COMPILE);
		glColor3f(0.5,0.5,0);
		glTranslatef(0.0, hauteurPied+hauteurPlateau+hauteurBaseEcran/2., 0.0);
		// base ecran
		glPushMatrix();
			glScalef(largeurBaseEcran, hauteurBaseEcran, longueurBaseEcran);
			glutWireCube(1);
		glPopMatrix();
 
		// pied ecran
		glPushMatrix();
			glTranslatef(0, hauteurBaseEcran/2.+hauteurPiedEcran/2., -longueurBaseEcran/2.+longueurPiedEcran/2.+5);
			glScalef(largeurPiedEcran, hauteurPiedEcran, longueurPiedEcran);
			glutWireCube(1);
		glPopMatrix();
 
		// dalle ecran
		glPushMatrix();
			glTranslatef(0, hauteurBaseEcran/2.+hauteurPiedEcran+hauteurDalleEcran/2.,-longueurBaseEcran/2.+longueurDalleEcran/2.+5);
			glScalef(largeurDalleEcran, hauteurDalleEcran, longueurDalleEcran);
			glutWireCube(1);
		glPopMatrix();
	glEndList();
}
 
/**
 * Fonction qui permet de creer une liste de tous les ecrans
 * placé dans la salle
 */
void creerListeEcranPlace(){
 
	ecranPlace=glGenLists(1);
	glNewList(ecranPlace, GL_COMPILE);
 
	//premiere rangé
	glPushMatrix();
		glPushMatrix();
			glTranslatef(largeurSalle-longueurPlateau+longueurPlateau/2., 0.0, 200.0+15);
			glRotatef(angleAleat(-15,15),0,1,0);
			glCallList(ecran);
		glPopMatrix();
		glPushMatrix();
			glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/2., 0.0, 200.0+15);
			glRotatef(angleAleat(-15,15),0,1,0);
			glCallList(ecran);
		glPopMatrix();
		glPushMatrix();
			glTranslatef(largeurSalle-3*longueurPlateau+longueurPlateau/2., 0.0, 200.0+15);
			glRotatef(angleAleat(-15,15),0,1,0);
			glCallList(ecran);
		glPopMatrix();
	glPopMatrix();
 
	int i;
	for(i=1;i<4;i++){
 
		glPushMatrix();
			glTranslatef(0.0, 0.0, 200.0+(float)(i)*90.0+(float)(i)*largeurPlateau);
			glPushMatrix();
				glTranslatef(largeurSalle-longueurPlateau+longueurPlateau/2., 0.0, 15);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(ecran);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/2., 0.0, 15);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(ecran);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(largeurSalle-3*longueurPlateau+longueurPlateau/2., 0.0, 15);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(ecran);
			glPopMatrix();
		glPopMatrix();
 
	}
	glEndList();
}
 
/**
 * Fonction qui permet de créer la liste de la tour
 */
void creerListeTour(){
	tour=glGenLists(1);
	glNewList(tour, GL_COMPILE);
		glColor3f(0.5,0,0.5);
		glTranslatef(0.0, hauteurPied+hauteurPlateau+hauteurTour/2., 0.0);
		glScalef(largeurTour, hauteurTour, longueurTour);
		glutWireCube(1);
	glEndList();
}
 
/**
 * Fonction qui permet de creer une liste de toutes les tours
 * placé dans la salle
 */
void creerListeTourPlace(){
	tourPlace=glGenLists(1);
	glNewList(tourPlace, GL_COMPILE);
 
	//premiere rangé
	glPushMatrix();
		glTranslatef(largeurSalle-longueurPlateau+longueurPlateau/1.2, 0.0, 200.0+35);
		glRotatef(angleAleat(-15,15),0,1,0);
		glCallList(tour);
	glPopMatrix();
	glPushMatrix();
		glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/1.2, 0.0, 200.0+35);
		glRotatef(angleAleat(-15,15),0,1,0);
		glCallList(tour);
	glPopMatrix();
	glPushMatrix();
		glTranslatef(largeurSalle-3*longueurPlateau+longueurPlateau/1.2, 0.0, 200.0+35);
		glRotatef(angleAleat(-15,15),0,1,0);
		glCallList(tour);
	glPopMatrix();
 
 
	int i;
	for(i=1;i<4;i++){
 
		glPushMatrix();
			glTranslatef(0.0, 0.0, 200.0+(float)(i)*90.0+(float)(i)*largeurPlateau);
			glPushMatrix();
				glTranslatef(largeurSalle-longueurPlateau+longueurPlateau/1.2, 0.0, 35);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(tour);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/1.2, 0.0, 35);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(tour);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(largeurSalle-3*longueurPlateau+longueurPlateau/1.2, 0.0, 35);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(tour);
			glPopMatrix();
		glPopMatrix();
 
	}
 
	glEndList();
}
 
/**
 * Fonction qui permet de créer la liste du clavier
 */
void creerListeClavier(){
	clavier=glGenLists(1);
	glNewList(clavier, GL_COMPILE);
		glColor3f(1,0,0);
		glTranslatef(0.0, hauteurPied+hauteurPlateau+hauteurClavier/2., 0.0);
		glScalef(largeurClavier, hauteurClavier, longueurClavier);
		glutWireCube(1);
	glEndList();
 
}
 
/**
 * Fonction qui permet de creer une liste de tous les claviers
 * placé dans la salle
 */
void creerListeClavierPlace(){
	clavierPlace=glGenLists(1);
	glNewList(clavierPlace, GL_COMPILE);
	//premiere rangé
	glPushMatrix();
		glPushMatrix();
			glTranslatef(largeurSalle-longueurPlateau+longueurPlateau/2.0, 0.0, 200.0+largeurPlateau-largeurClavier/2.);
			glRotatef(angleAleat(-15,15),0,1,0);
			glCallList(clavier);
		glPopMatrix();
		glPushMatrix();
			glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/2.0, 0.0, 200.0+largeurPlateau-largeurClavier/2.);
			glRotatef(angleAleat(-15,15),0,1,0);
			glCallList(clavier);
		glPopMatrix();
		glPushMatrix();
			glTranslatef(largeurSalle-3*longueurPlateau+longueurPlateau/2.0, 0.0, 200.0+largeurPlateau-largeurClavier/2.);
			glRotatef(angleAleat(-15,15),0,1,0);
			glCallList(clavier);
		glPopMatrix();
	glPopMatrix();
 
 
	int i;
	for(i=1;i<4;i++){
 
		glPushMatrix();
			glTranslatef(0.0, 0.0, 200.0+(float)(i)*90.0+(float)(i)*largeurPlateau);
			glPushMatrix();
				glTranslatef(largeurSalle-longueurPlateau+longueurPlateau/2.0, 0.0, largeurPlateau/2.0+largeurClavier/2.-10);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(clavier);
			glPopMatrix();
 
			glPushMatrix();
				glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/2.0, 0.0, largeurPlateau/2.0+largeurClavier/2.-10);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(clavier);
			glPopMatrix();
 
			glPushMatrix();
				glTranslatef(largeurSalle-3*longueurPlateau+longueurPlateau/2.0, 0.0, largeurPlateau/2.0+largeurClavier/2.-10);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(clavier);
			glPopMatrix();
		glPopMatrix();
 
	}
	glEndList();
}
 
 
/**
 * Fonction qui permet de créer la liste de la chaise
 */
void creerListeChaise(){
	chaise=glGenLists(1);
	glNewList(chaise, GL_COMPILE);
		glColor3f(0,1,0);
		//le plateau de la chaise
		glPushMatrix();
			glTranslatef(0.0, hauteurPiedChaise+hauteurPlateauChaise/2.0, 0.0);
			glScalef(largeurPlateauChaise, hauteurPlateauChaise, longueurPlateauChaise);
			glutWireCube(1);
		glPopMatrix();
 
		//***********les pieds de la chaise
 
		//le pied a gauche au fond
		glPushMatrix();
			glTranslatef(3+longueurPiedChaise/2.0-longueurPlateauChaise/2., hauteurPiedChaise/2.0, 3+largeurPiedChaise/2.0-largeurPlateauChaise/2.0);
			glScalef(longueurPiedChaise, hauteurPiedChaise, largeurPiedChaise);
			glutWireCube(1);
		glPopMatrix();
 
		//le pied a droite au fond
		glPushMatrix();
			glTranslatef(-3-longueurPiedChaise/2.0+longueurPlateauChaise/2., hauteurPiedChaise/2.0, 3+largeurPiedChaise/2.0-largeurPlateauChaise/2.0);
			glScalef(longueurPiedChaise, hauteurPiedChaise, largeurPiedChaise);
			glutWireCube(1);
		glPopMatrix();
 
		//le pied a gauche devant
		glPushMatrix();
			glTranslatef(3+longueurPiedChaise/2.0-longueurPlateauChaise/2., hauteurPiedChaise/2.0, -3-largeurPiedChaise/2.0+largeurPlateauChaise/2.0);
			glScalef(longueurPiedChaise, hauteurPiedChaise, largeurPiedChaise);
			glutWireCube(1);
		glPopMatrix();
 
		//le pied a droite devant
		glPushMatrix();
			glTranslatef(-3-longueurPiedChaise/2.0+longueurPlateauChaise/2., hauteurPiedChaise/2.0, -3-largeurPiedChaise/2.0+largeurPlateauChaise/2.0);
			glScalef(longueurPiedChaise, hauteurPiedChaise, largeurPiedChaise);
			glutWireCube(1);
		glPopMatrix();
 
		//dossier de la chaise
		glPushMatrix();
			glTranslatef(0.,hauteurDossierChaise+hauteurPiedChaise/2,largeurDossierChaise/2.+largeurPlateauChaise/2.+largeurDossierChaise);
			glRotatef(10.,1,0,0);
			glScalef(longueurDossierChaise, hauteurDossierChaise, largeurDossierChaise);
			glutWireCube(1);
		glPopMatrix();
 
	glEndList();
}
 
/**
 * Fonction qui permet de creer une liste de toutes les chaises
 * placé dans la salle
 */
void creerListeChaisePlace(){
	chaisePlace=glGenLists(1);
	glNewList(chaisePlace, GL_COMPILE);
		//chaise prof
		glPushMatrix();
			glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/2.0, 0.0, 200.0-largeurPlateau-5);
			glRotatef(194,0,1,0);
			glCallList(chaise);
		glPopMatrix();
 
		//chaise premiere rangé
		glPushMatrix();
			glTranslatef(0.0, 0.0, 200.0+largeurPlateau/2.+largeurPlateauChaise/2.);
			glPushMatrix();
				glTranslatef(largeurSalle-longueurPlateau+longueurPlateau/2.0,0.,0.);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(chaise);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/2.0,0.,0.);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(chaise);
			glPopMatrix();
			glPushMatrix();
				glTranslatef(largeurSalle-3*longueurPlateau+longueurPlateau/2.0,0.,0.);
				glRotatef(angleAleat(-15,15),0,1,0);
				glCallList(chaise);
			glPopMatrix();
		glPopMatrix();
 
		int i;
		for(i=1;i<4;i++){
 
 
			glPushMatrix();
				glTranslatef(0.0, 0.0, 200.0+largeurPlateau+largeurPlateauChaise/2.+(float)(i)*95.0+(float)(i)*(largeurPlateau/2.+largeurPlateauChaise/2.));
				glPushMatrix();
 
					glTranslatef(largeurSalle-longueurPlateau+longueurPlateau/2.0,0.,0.);
					glRotatef(angleAleat(-15,15),0,1,0);
					glCallList(chaise);
				glPopMatrix();
				glPushMatrix();
					glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/2.0,0.,0.);
					glRotatef(angleAleat(-15,15),0,1,0);
					glCallList(chaise);
				glPopMatrix();
				glPushMatrix();
					glTranslatef(largeurSalle-3*longueurPlateau+longueurPlateau/2.0,0.,0.);
					glRotatef(angleAleat(-15,15),0,1,0);
					glCallList(chaise);
				glPopMatrix();
			glPopMatrix();
 
		}
	glEndList();
}
 
 
/**
 * Fonction qui permet de créer la liste de la salle
 */
void creerListeSalle(){
	salle=glGenLists(1);
	glNewList(salle, GL_COMPILE);
		glPushMatrix();
			glTranslatef(largeurSalle/2.0, hauteurSalle/2.0, longueurSalle/2.0);
			glScalef(largeurSalle, hauteurSalle, longueurSalle);
			glutWireCube(1);
		glPopMatrix();
	glEndList();
}
 
 
/**
 * Fonction qui permet de créer la liste de la table
 */
void creerListeTable(){
	table=glGenLists(1);
	glNewList(table, GL_COMPILE);
		glColor3f(0,0,1);
		//Le plateau
		glPushMatrix();
			glTranslatef(0.0, hauteurPied+hauteurPlateau/2.0, 0.0);
			glScalef(longueurPlateau, hauteurPlateau, largeurPlateau);
			creerCube(texture_table, 0, 0, 0, 0, 0);
			//glutWireCube(1);
		glPopMatrix();
 
		//le pied a gauche au fond
		glPushMatrix();
			glTranslatef(3+longueurPied/2.0-longueurPlateau/2., hauteurPied/2.0, 3+largeurPied/2.0-largeurPlateau/2.0);
			glScalef(longueurPied, hauteurPied, largeurPied);
			glutWireCube(1);
		glPopMatrix();
 
		//le pied a droite au fond
		glPushMatrix();
			glTranslatef(-3-longueurPied/2.0+longueurPlateau/2., hauteurPied/2.0, 3+largeurPied/2.0-largeurPlateau/2.0);
			glScalef(longueurPied, hauteurPied, largeurPied);
			glutWireCube(1);
		glPopMatrix();
 
		//le pied a gauche devant
		glPushMatrix();
			glTranslatef(3+longueurPied/2.0-longueurPlateau/2., hauteurPied/2.0, -3-largeurPied/2.0+largeurPlateau/2.0);
			glScalef(longueurPied, hauteurPied, largeurPied);
			glutWireCube(1);
		glPopMatrix();
 
		//le pied a droite devant
		glPushMatrix();
			glTranslatef(-3-longueurPied/2.0+longueurPlateau/2., hauteurPied/2.0, -3-largeurPied/2.0+largeurPlateau/2.0);
			glScalef(longueurPied, hauteurPied, largeurPied);
			glutWireCube(1);
		glPopMatrix();
	glEndList();
}
 
 
/********************** FONCTION D'AFFICHAGE DES DIFFERENTS OBJETS ***********************/
 
/**
 * Fonction qui permet d'afficher les ecrans
 * aux bonnes positions dans la salle
 */
void afficheEcran(){
	glPushMatrix();
		glCallList(ecranPlace);
	glPopMatrix();
}
 
 
/**
 * Fonction qui permet d'afficher les tours
 * aux bonnes positions dans la salle
 */
void afficheTour(){
	glPushMatrix();
		glCallList(tourPlace);
	glPopMatrix();
}
 
 
/**
 * Fonction qui permet d'afficher les claviers
 * aux bonnes positions dans la salle
 */
void afficheClavier(){
	glPushMatrix();
		glCallList(clavierPlace);
	glPopMatrix();
}
 
 
/**
 * Fonction qui permet d'afficher les chaises
 * aux bonnes positions dans la salle
 */
void afficheChaise(){
	glPushMatrix();
		glCallList(chaisePlace);
	glPopMatrix();
}
 
 
/**
 * Fonction qui permet d'afficher les tables
 * aux bonnes positions dans la salle
 */
void afficheTable(){
 
	//bureau du prof
	glPushMatrix();
		glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/2.0, 0.0, 200.0-largeurPlateau/2.0-5);
		glCallList(table);
	glPopMatrix();
 
	//premiere range
	glPushMatrix();
		glTranslatef(0.0, 0.0, 200.0);
		glPushMatrix();
			glTranslatef(largeurSalle-longueurPlateau+longueurPlateau/2.0, 0.0, largeurPlateau/2.0);
			glCallList(table);
		glPopMatrix();
 
		glPushMatrix();
			glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/2.0, 0.0, largeurPlateau/2.0);
			glCallList(table);
		glPopMatrix();
 
		glPushMatrix();
			glTranslatef(largeurSalle-3*longueurPlateau+longueurPlateau/2.0, 0.0, largeurPlateau/2.0);
			glCallList(table);
		glPopMatrix();
	glPopMatrix();
 
	//les 3 autres
	int i;
	for(i=1; i<4; i++){
		glPushMatrix();
			glTranslatef(0.0, 0.0, 200.0+(float)(i)*90.0+(float)(i)*largeurPlateau);
			glPushMatrix();
				glTranslatef(largeurSalle-longueurPlateau+longueurPlateau/2.0, 0.0, largeurPlateau/2.0);
				glCallList(table);
			glPopMatrix();
 
			glPushMatrix();
				glTranslatef(largeurSalle-2*longueurPlateau+longueurPlateau/2.0, 0.0, largeurPlateau/2.0);
				glCallList(table);
			glPopMatrix();
 
			glPushMatrix();
				glTranslatef(largeurSalle-3*longueurPlateau+longueurPlateau/2.0, 0.0, largeurPlateau/2.0);
				glCallList(table);
			glPopMatrix();
		glPopMatrix();
	}
 
}
 
/************************ AUTRES FONCTIONS *********************/
 
void creerCube(GLuint id1, GLuint id2, GLuint id3, GLuint id4, GLuint id5, GLuint id6){
	//Premiere face
	glBindTexture(GL_TEXTURE_2D, id1);
	glBegin(GL_QUADS);
		glNormal3f(0, 0, 1);
		glTexCoord2f(0, 0);
		glVertex3f(0, 0, 0);
 
		glTexCoord2f(1, 0);
		glVertex3f(1, 0, 0);
 
		glTexCoord2f(1, 1);
		glVertex3f(1, 1, 0);
 
		glTexCoord2f(0, 1);
		glVertex3f(0, 1, 0);
	glEnd();
 
	//deuxieme face
	glBindTexture(GL_TEXTURE_2D, id2);
	glBegin(GL_QUADS);
		glNormal3f(-1, 0, 0);
		glTexCoord2f(0, 0);
		glVertex3f(0, 0, 0);
 
		glTexCoord2f(1, 0);
		glVertex3f(0, 0, -1);
 
		glTexCoord2f(0, 1);
		glVertex3f(0, 1, 0);
 
		glTexCoord2f(1, 1);
		glVertex3f(0, 1, -1);
	glEnd();
 
	//troisieme face
	glBindTexture(GL_TEXTURE_2D, id3);
	glBegin(GL_QUADS);
		glNormal3f(0, 1, 0);
		glTexCoord2f(0, 0);
		glVertex3f(0, 1, 0);
 
		glTexCoord2f(0, 1);
		glVertex3f(0, 1, -1);
 
		glTexCoord2f(1, 1);
		glVertex3f(1, 1, -1);
 
		glTexCoord2f(1, 0);
		glVertex3f(1, 1, 0);
	glEnd();
 
	//quatrieme face
	glBindTexture(GL_TEXTURE_2D, id4);
	glBegin(GL_QUADS);
		glNormal3f(0, -1, 0);
		glTexCoord2f(0, 0);
		glVertex3f(0, 0, 0);
 
		glTexCoord2f(0, 1);
		glVertex3f(0, 0, -1);
 
		glTexCoord2f(1, 1);
		glVertex3f(1, 0, -1);
 
		glTexCoord2f(1, 0);
		glVertex3f(1, 0, 0);
	glEnd();
 
	//cinquieme face
	glBindTexture(GL_TEXTURE_2D, id5);
	glBegin(GL_QUADS);
		glNormal3f(0, 0, -1);
		glTexCoord2f(0, 0);
		glVertex3f(0, 0, -1);
 
		glTexCoord2f(0, 1);
		glVertex3f(0, 1, -1);
 
		glTexCoord2f(1, 1);
		glVertex3f(1, 1, -1);
 
		glTexCoord2f(1, 0);
		glVertex3f(1, 0, -1);
	glEnd();
 
	//sixieme face
	glBindTexture(GL_TEXTURE_2D, id6);
	glBegin(GL_QUADS);
		glNormal3f(1, 0, 0);
		glTexCoord2f(0, 0);
		glVertex3f(1, 0, 0);
 
		glTexCoord2f(0, 1);
		glVertex3f(1, 1, 0);
 
		glTexCoord2f(1, 1);
		glVertex3f(1, 1, -1);
 
		glTexCoord2f(1, 0);
		glVertex3f(1, 0, -1);
	glEnd();
 
	glBindTexture(GL_TEXTURE_2D, 0);
}
void afficher()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(x_obs, y_obs, z_obs,  x_vise, y_vise, z_vise,   x_ass, y_ass, z_ass);
 
	glColor3f(1,1,1);
 
 
	float pos[]={605.0/2.0, 275.0/2.0, 976.0/2.0, 1.};
	glLightfv(GL_LIGHT0, GL_POSITION, pos);
 
	float couleurAmb2[]={0.23125,0.23125,0.23125, 1.};
	float couleurDiff2[]={0.2775,0.2775,0.8775, 1.};
	float couleurSpec2[]={0.773911,0.773911,0.773911, 1.};
	float shininess[]={89.6};
	glMaterialfv(GL_FRONT, GL_AMBIENT, couleurAmb2);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, couleurDiff2);
	glMaterialfv(GL_FRONT, GL_SPECULAR, couleurSpec2);
	glMaterialfv(GL_FRONT, GL_SHININESS, shininess);
 
	// la salle
	glPushMatrix();
		glCallList(salle);
	glPopMatrix();
 
	// les tables
	afficheTable();
 
	// les chaises
	afficheChaise();
 
	// les claviers
	afficheClavier();
 
	// les tours
	afficheTour();
 
	// les ecrans
	afficheEcran();
 
 
 
	// affichage du point visé
	glPushMatrix();
		glColor3f(1,0, 0);
		glTranslatef(x_vise, y_vise, z_vise);
		glutWireCube(5);
	glPopMatrix();
 
	if(glGetError()!=0)
		printf("erreur\n");
	glutSwapBuffers();
}
 
/**
 * Fonction qui permet de rafraichir la visualisation
 */
void rafraichir(int width, int height)
{
	/* PROJECTION : définition du volume de vue */
 
	glViewport( 0,0, width,height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
 
	//glFrustum(-5*tan(M_PI/3.0),5*tan(M_PI/3.0),-6.49,6.49,5,1000.0);
 
	gluPerspective(90.0,(float)(width)/(float)(height), 5.0, 1500.0);
}
 
/**
 * Fonction qui permet de calculer les coordonnées de vue
 */
void calculObs(){
	x_obs=x_vise+distance_du_point_vise*cos(beta)*cos(alpha);
	y_obs=y_vise+distance_du_point_vise*sin(alpha);
	z_obs=z_vise+distance_du_point_vise*sin(beta)*cos(alpha);
}
 
/**
 * Fonction qui permet de retourner un entier
 * aléatoire entre les bornes a et b
 */
int angleAleat(int a, int b){
    	return rand()%(b-a) +a;
}
 
/**
 * Fonction qui permet de deplacer le point visé
 * Touche z et s deplacement sur l'axe x
 * Touche d et q deplacement sur l'axe z
 * Touche r et f deplacement sur l'axe y
 */
void keyboard(unsigned char key, int x, int y){
 
	switch(key){
		case 'z':
			x_vise+=2;
			break;
		case 's':
			x_vise-=2;
			break;
		case 'd':
			z_vise+=2;
			break;
		case 'q':
			z_vise-=2;
			break;
		case 'r':
			y_vise+=2;
			break;
		case 'f':
			y_vise-=2;
			break;
 
	}
 
	calculObs();
	glutPostRedisplay();
}
 
/**
 * Fonction qui permet de modifier la distance de l'observateur
 * par rapport au point visé
 * Touche fleche haut et fleche bas
 */
void special(int key, int x, int y){
	switch(key){
		case GLUT_KEY_DOWN :
			distance_du_point_vise-=5;
			break;
		case GLUT_KEY_UP :
			distance_du_point_vise+=5;
			break;
	}
 
	calculObs();
	glutPostRedisplay();
}
 
/**
 * Fonction qui permet de deplacer l'observateur
 * sur une sphere autour du point visé
 */
void motion(int x, int y){
	beta+=(x-x_pos_souris)*0.01;
 
	alpha+=(y-y_pos_souris)*0.01;
 
 
	x_pos_souris=x;
	y_pos_souris=y;
 
	calculObs();
	glutPostRedisplay();
}
 
void initialiserLumiere(){
	float couleurAmb[]={1., 1., 1., 1.};
	float couleurDiff[]={0.5, 0.5, 0.5, 1.};
	float couleurSpec[]={0.5, 0.5, 0.5, 1.};
	glLightfv(GL_LIGHT0, GL_AMBIENT, couleurAmb);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, couleurDiff);
	glLightfv(GL_LIGHT0, GL_SPECULAR, couleurSpec);
}
 
void initialiserTexture(){
	int level=0;
	int border=0;
	gl_texture_t* texture;
 
	glGenTextures(1, &texture_table);
	texture=ReadTGAFile("./texture_table.tga");
	glBindTexture(GL_TEXTURE_2D, texture_table);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexImage2D(GL_TEXTURE_2D, level, texture->internalFormat, texture->width, texture->height, border, texture->format, GL_UNSIGNED_BYTE, texture->texels);
 
	/*glGenTextures(1, &texture_sol);
	texture=ReadTGAFile("./texture_sol.tga");
	glBindTexture(GL_TEXTURE_2D, texture_sol);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexImage2D(GL_TEXTURE_2D, level, texture->internalFormat, texture->width, texture->height, border, texture->format, GL_UNSIGNED_BYTE, texture->texels);
 
	glGenTextures(1, &texture_clavier);
	texture=ReadTGAFile("./texture_clavier.tga");
	glBindTexture(GL_TEXTURE_2D, texture_clavier);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexImage2D(GL_TEXTURE_2D, level, texture->internalFormat, texture->width, texture->height, border, texture->format, GL_UNSIGNED_BYTE, texture->texels);
 
	glGenTextures(1, &texture_plafond);
	texture=ReadTGAFile("./texture_plafond.tga");
	glBindTexture(GL_TEXTURE_2D, texture_plafond);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexImage2D(GL_TEXTURE_2D, level, texture->internalFormat, texture->width, texture->height, border, texture->format, GL_UNSIGNED_BYTE, texture->texels);
 
	glGenTextures(1, &texture_tour);
	texture=ReadTGAFile("./texture_tour.tga");
	glBindTexture(GL_TEXTURE_2D, texture_tour);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexImage2D(GL_TEXTURE_2D, level, texture->internalFormat, texture->width, texture->height, border, texture->format, GL_UNSIGNED_BYTE, texture->texels);
 
	glGenTextures(1, &texture_chaise);
	texture=ReadTGAFile("./texture_chaise.tga");
	glBindTexture(GL_TEXTURE_2D, texture_tour);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexImage2D(GL_TEXTURE_2D, level, texture->internalFormat, texture->width, texture->height, border, texture->format, GL_UNSIGNED_BYTE, texture->texels);
	*/
 
 
}
 
 
 
int main(int argc, char **argv)
{
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(800,600);
	glutInitWindowPosition(10,10);
	glutCreateWindow("La salle");
 
 
	/**
          * gestion de la lumiere
          */
	initialiserLumiere();
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_DEPTH_TEST);
 
	/**
          * gestion des texture
          */
	initialiserTexture();
	glEnable(GL_TEXTURE_2D);
 
	// Initialisation des listes
	creerListeSalle();
	creerListeTable();
	creerListeChaise();
	creerListeChaisePlace();
	creerListeClavier();
	creerListeClavierPlace();
	creerListeTour();
	creerListeTourPlace();
	creerListeEcran();
	creerListeEcranPlace();
 
	glutDisplayFunc(&afficher);
	glutReshapeFunc(&rafraichir);
	glutKeyboardFunc(&keyboard);
	glutSpecialFunc(&special);
	glutMotionFunc(&motion);
	//glutPassiveMotionFunc(&pMotion);
 
	// activation des textures
	glEnable(GL_TEXTURE_2D);
 
 
	glutMainLoop();
 
	return 0;
}

tga.c
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
/*
 * tga.c -- tga texture loader
 * last modification: dec. 15, 2005
 *
 * Copyright (c) 2005 David HENRY
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * gcc -Wall -ansi -L/usr/X11R6/lib -lGL -lGLU -lglut tga.c -o tga
 */
 
#include "header.h"
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
 
 
/* OpenGL texture info */
typedef struct
{
  GLsizei width;
  GLsizei height;
 
  GLenum format;
  GLint	internalFormat;
  GLuint id;
 
  GLubyte *texels;
 
} gl_texture_t;
 
 
#pragma pack(push, 1)
/* tga header */
typedef struct
{
  GLubyte id_lenght;          /* size of image id */
  GLubyte colormap_type;      /* 1 is has a colormap */
  GLubyte image_type;         /* compression type */
 
  short	cm_first_entry;       /* colormap origin */
  short	cm_length;            /* colormap length */
  GLubyte cm_size;            /* colormap size */
 
  short	x_origin;             /* bottom left x coord origin */
  short	y_origin;             /* bottom left y coord origin */
 
  short	width;                /* picture width (in pixels) */
  short	height;               /* picture height (in pixels) */
 
  GLubyte pixel_depth;        /* bits per pixel: 8, 16, 24 or 32 */
  GLubyte image_descriptor;   /* 24 bits = 0x00; 32 bits = 0x80 */
 
} tga_header_t;
#pragma pack(pop)
 
 
/* texture id for exemple */
GLuint texId = 0;
 
 
void GetTextureInfo (tga_header_t *header, gl_texture_t *texinfo)
{
  texinfo->width = header->width;
  texinfo->height = header->height;
 
  switch (header->image_type)
    {
    case 3:  /* grayscale 8 bits */
    case 11: /* grayscale 8 bits (RLE) */
      {
	if (header->pixel_depth == 8)
	  {
	    texinfo->format = GL_LUMINANCE;
	    texinfo->internalFormat = 1;
	  }
	else /* 16 bits */
	  {
	    texinfo->format = GL_LUMINANCE_ALPHA;
	    texinfo->internalFormat = 2;
	  }
 
	break;
      }
 
    case 1:  /* 8 bits color index */
    case 2:  /* BGR 16-24-32 bits */
    case 9:  /* 8 bits color index (RLE) */
    case 10: /* BGR 16-24-32 bits (RLE) */
      {
	/* 8 bits and 16 bits images will be converted to 24 bits */
	if (header->pixel_depth <= 24)
	  {
	    texinfo->format = GL_RGB;
	    texinfo->internalFormat = 3;
	  }
	else /* 32 bits */
	  {
	    texinfo->format = GL_RGBA;
	    texinfo->internalFormat = 4;
	  }
 
	break;
      }
    }
}
 
 
void ReadTGA8bits (FILE *fp, GLubyte *colormap, gl_texture_t *texinfo)
{
  int i;
  GLubyte color;
 
  for (i = 0; i < texinfo->width * texinfo->height; ++i)
    {
      /* read index color byte */
      color = (GLubyte)fgetc (fp);
 
      /* convert to RGB 24 bits */
      texinfo->texels[(i * 3) + 2] = colormap[(color * 3) + 0];
      texinfo->texels[(i * 3) + 1] = colormap[(color * 3) + 1];
      texinfo->texels[(i * 3) + 0] = colormap[(color * 3) + 2];
    }
}
 
 
void ReadTGA16bits (FILE *fp, gl_texture_t *texinfo)
{
  int i;
  unsigned short color;
 
  for (i = 0; i < texinfo->width * texinfo->height; ++i)
    {
      /* read color word */
      color = fgetc (fp) + (fgetc (fp) << 8);
 
      /* convert BGR to RGB */
      texinfo->texels[(i * 3) + 0] = (GLubyte)(((color & 0x7C00) >> 10) << 3);
      texinfo->texels[(i * 3) + 1] = (GLubyte)(((color & 0x03E0) >>  5) << 3);
      texinfo->texels[(i * 3) + 2] = (GLubyte)(((color & 0x001F) >>  0) << 3);
    }
}
 
 
void ReadTGA24bits (FILE *fp, gl_texture_t *texinfo)
{
  int i;
 
  for (i = 0; i < texinfo->width * texinfo->height; ++i)
    {
      /* read and convert BGR to RGB */
      texinfo->texels[(i * 3) + 2] = (GLubyte)fgetc (fp);
      texinfo->texels[(i * 3) + 1] = (GLubyte)fgetc (fp);
      texinfo->texels[(i * 3) + 0] = (GLubyte)fgetc (fp);
    }
}
 
 
void ReadTGA32bits (FILE *fp, gl_texture_t *texinfo)
{
  int i;
 
  for (i = 0; i < texinfo->width * texinfo->height; ++i)
    {
      /* read and convert BGRA to RGBA */
      texinfo->texels[(i * 4) + 2] = (GLubyte)fgetc (fp);
      texinfo->texels[(i * 4) + 1] = (GLubyte)fgetc (fp);
      texinfo->texels[(i * 4) + 0] = (GLubyte)fgetc (fp);
      texinfo->texels[(i * 4) + 3] = (GLubyte)fgetc (fp);
    }
}
 
 
void ReadTGAgray8bits (FILE *fp, gl_texture_t *texinfo)
{
  int i;
 
  for (i = 0; i < texinfo->width * texinfo->height; ++i)
    {
      /* read grayscale color byte */
      texinfo->texels[i] = (GLubyte)fgetc (fp);
    }
}
 
 
void ReadTGAgray16bits (FILE *fp, gl_texture_t *texinfo)
{
  int i;
 
  for (i = 0; i < texinfo->width * texinfo->height; ++i)
    {
      /* read grayscale color + alpha channel bytes */
      texinfo->texels[(i * 2) + 0] = (GLubyte)fgetc (fp);
      texinfo->texels[(i * 2) + 1] = (GLubyte)fgetc (fp);
    }
}
 
 
void ReadTGA8bitsRLE (FILE *fp, GLubyte *colormap, gl_texture_t *texinfo)
{
  int i, size;
  GLubyte color;
  GLubyte packet_header;
  GLubyte *ptr = texinfo->texels;
 
  while (ptr < texinfo->texels + (texinfo->width * texinfo->height) * 3)
    {
      /* read first byte */
      packet_header = (GLubyte)fgetc (fp);
      size = 1 + (packet_header & 0x7f);
 
      if (packet_header & 0x80)
	{
	  /* run-length packet */
	  color = (GLubyte)fgetc (fp);
 
	  for (i = 0; i < size; ++i, ptr += 3)
	    {
	      ptr[0] = colormap[(color * 3) + 2];
	      ptr[1] = colormap[(color * 3) + 1];
	      ptr[2] = colormap[(color * 3) + 0];
	    }
	}
      else
	{
	  /* non run-length packet */
	  for (i = 0; i < size; ++i, ptr += 3)
	    {
	      color = (GLubyte)fgetc (fp);
 
	      ptr[0] = colormap[(color * 3) + 2];
	      ptr[1] = colormap[(color * 3) + 1];
	      ptr[2] = colormap[(color * 3) + 0];
	    }
	}
    }
}
 
 
void ReadTGA16bitsRLE (FILE *fp, gl_texture_t *texinfo)
{
  int i, size;
  unsigned short color;
  GLubyte packet_header;
  GLubyte *ptr = texinfo->texels;
 
  while (ptr < texinfo->texels + (texinfo->width * texinfo->height) * 3)
    {
      /* read first byte */
      packet_header = fgetc (fp);
      size = 1 + (packet_header & 0x7f);
 
      if (packet_header & 0x80)
	{
	  /* run-length packet */
	  color = fgetc (fp) + (fgetc (fp) << 8);
 
	  for (i = 0; i < size; ++i, ptr += 3)
	    {
	      ptr[0] = (GLubyte)(((color & 0x7C00) >> 10) << 3);
	      ptr[1] = (GLubyte)(((color & 0x03E0) >>  5) << 3);
	      ptr[2] = (GLubyte)(((color & 0x001F) >>  0) << 3);
	    }
	}
      else
	{
	  /* non run-length packet */
	  for (i = 0; i < size; ++i, ptr += 3)
	    {
	      color = fgetc (fp) + (fgetc (fp) << 8);
 
	      ptr[0] = (GLubyte)(((color & 0x7C00) >> 10) << 3);
	      ptr[1] = (GLubyte)(((color & 0x03E0) >>  5) << 3);
	      ptr[2] = (GLubyte)(((color & 0x001F) >>  0) << 3);
	    }
	}
    }
}
 
 
void ReadTGA24bitsRLE (FILE *fp, gl_texture_t *texinfo)
{
  int i, size;
  GLubyte rgb[3];
  GLubyte packet_header;
  GLubyte *ptr = texinfo->texels;
 
  while (ptr < texinfo->texels + (texinfo->width * texinfo->height) * 3)
    {
      /* read first byte */
      packet_header = (GLubyte)fgetc (fp);
      size = 1 + (packet_header & 0x7f);
 
      if (packet_header & 0x80)
	{
	  /* run-length packet */
	  fread (rgb, sizeof (GLubyte), 3, fp);
 
	  for (i = 0; i < size; ++i, ptr += 3)
	    {
	      ptr[0] = rgb[2];
	      ptr[1] = rgb[1];
	      ptr[2] = rgb[0];
	    }
	}
      else
	{
	  /* non run-length packet */
	  for (i = 0; i < size; ++i, ptr += 3)
	    {
	      ptr[2] = (GLubyte)fgetc (fp);
	      ptr[1] = (GLubyte)fgetc (fp);
	      ptr[0] = (GLubyte)fgetc (fp);
	    }
	}
    }
}
 
 
void ReadTGA32bitsRLE (FILE *fp, gl_texture_t *texinfo)
{
  int i, size;
  GLubyte rgba[4];
  GLubyte packet_header;
  GLubyte *ptr = texinfo->texels;
 
  while (ptr < texinfo->texels + (texinfo->width * texinfo->height) * 4)
    {
      /* read first byte */
      packet_header = (GLubyte)fgetc (fp);
      size = 1 + (packet_header & 0x7f);
 
      if (packet_header & 0x80)
	{
	  /* run-length packet */
	  fread (rgba, sizeof (GLubyte), 4, fp);
 
	  for (i = 0; i < size; ++i, ptr += 4)
	    {
	      ptr[0] = rgba[2];
	      ptr[1] = rgba[1];
	      ptr[2] = rgba[0];
	      ptr[3] = rgba[3];
	    }
	}
      else
	{
	  /* non run-length packet */
	  for (i = 0; i < size; ++i, ptr += 4)
	    {
	      ptr[2] = (GLubyte)fgetc (fp);
	      ptr[1] = (GLubyte)fgetc (fp);
	      ptr[0] = (GLubyte)fgetc (fp);
	      ptr[3] = (GLubyte)fgetc (fp);
	    }
	}
    }
}
 
 
void ReadTGAgray8bitsRLE (FILE *fp, gl_texture_t *texinfo)
{
  int i, size;
  GLubyte color;
  GLubyte packet_header;
  GLubyte *ptr = texinfo->texels;
 
  while (ptr < texinfo->texels + (texinfo->width * texinfo->height))
    {
      /* read first byte */
      packet_header = (GLubyte)fgetc (fp);
      size = 1 + (packet_header & 0x7f);
 
      if (packet_header & 0x80)
	{
	  /* run-length packet */
	  color = (GLubyte)fgetc (fp);
 
	  for (i = 0; i < size; ++i, ptr++)
	    *ptr = color;
	}
      else
	{
	  /* non run-length packet */
	  for (i = 0; i < size; ++i, ptr++)
	    *ptr = (GLubyte)fgetc (fp);
	}
    }
}
 
 
void ReadTGAgray16bitsRLE (FILE *fp, gl_texture_t *texinfo)
{
  int i, size;
  GLubyte color, alpha;
  GLubyte packet_header;
  GLubyte *ptr = texinfo->texels;
 
  while (ptr < texinfo->texels + (texinfo->width * texinfo->height) * 2)
    {
      /* read first byte */
      packet_header = (GLubyte)fgetc (fp);
      size = 1 + (packet_header & 0x7f);
 
      if (packet_header & 0x80)
	{
	  /* run-length packet */
	  color = (GLubyte)fgetc (fp);
	  alpha = (GLubyte)fgetc (fp);
 
	  for (i = 0; i < size; ++i, ptr += 2)
	    {
	      ptr[0] = color;
	      ptr[1] = alpha;
	    }
	}
      else
	{
	  /* non run-length packet */
	  for (i = 0; i < size; ++i, ptr += 2)
	    {
	      ptr[0] = (GLubyte)fgetc (fp);
	      ptr[1] = (GLubyte)fgetc (fp);
	    }
	}
    }
}
 
 
gl_texture_t *
ReadTGAFile (const char *filename)
{
  FILE *fp;
  gl_texture_t *texinfo;
  tga_header_t header;
  GLubyte *colormap = NULL;
 
  fp = fopen (filename, "rb");
  if (!fp)
    {
      fprintf (stderr, "error: couldn't open \"%s\"!\n", filename);
      return NULL;
    }
 
  /* read header */
  fread (&header, sizeof (tga_header_t), 1, fp);
 
  texinfo = (gl_texture_t *)malloc (sizeof (gl_texture_t));
  GetTextureInfo (&header, texinfo);
  fseek (fp, header.id_lenght, SEEK_CUR);
 
  /* memory allocation */
  texinfo->texels = (GLubyte *)malloc (sizeof (GLubyte) *
	texinfo->width * texinfo->height * texinfo->internalFormat);
  if (!texinfo->texels)
    {
      free (texinfo);
      return NULL;
    }
 
  /* read color map */
  if (header.colormap_type)
    {
      /* NOTE: color map is stored in BGR format */
      colormap = (GLubyte *)malloc (sizeof (GLubyte)
	* header.cm_length * (header.cm_size >> 3));
      fread (colormap, sizeof (GLubyte), header.cm_length
	* (header.cm_size >> 3), fp);
    }
 
  /* read image data */
  switch (header.image_type)
    {
    case 0:
      /* no data */
      break;
 
    case 1:
      /* uncompressed 8 bits color index */
      ReadTGA8bits (fp, colormap, texinfo);
      break;
 
    case 2:
      /* uncompressed 16-24-32 bits */
      switch (header.pixel_depth)
	{
	case 16:
	  ReadTGA16bits (fp, texinfo);
	  break;
 
	case 24:
	  ReadTGA24bits (fp, texinfo);
	  break;
 
	case 32:
	  ReadTGA32bits (fp, texinfo);
	  break;
	}
 
      break;
 
    case 3:
      /* uncompressed 8 or 16 bits grayscale */
      if (header.pixel_depth == 8)
	ReadTGAgray8bits (fp, texinfo);
      else /* 16 */
	ReadTGAgray16bits (fp, texinfo);
 
      break;
 
    case 9:
      /* RLE compressed 8 bits color index */
      ReadTGA8bitsRLE (fp, colormap, texinfo);
      break;
 
    case 10:
      /* RLE compressed 16-24-32 bits */
      switch (header.pixel_depth)
	{
	case 16:
	  ReadTGA16bitsRLE (fp, texinfo);
	  break;
 
	case 24:
	  ReadTGA24bitsRLE (fp, texinfo);
	  break;
 
	case 32:
	  ReadTGA32bitsRLE (fp, texinfo);
	  break;
	}
 
      break;
 
    case 11:
      /* RLE compressed 8 or 16 bits grayscale */
      if (header.pixel_depth == 8)
	ReadTGAgray8bitsRLE (fp, texinfo);
      else /* 16 */
	ReadTGAgray16bitsRLE (fp, texinfo);
 
      break;
 
    default:
      /* image type is not correct */
      fprintf (stderr, "error: unknown TGA image type %i!\n", header.image_type);
      free (texinfo->texels);
      free (texinfo);
      texinfo = NULL;
      break;
    }
 
  /* no longer need colormap data */
  if (colormap)
    free (colormap);
 
  fclose (fp);
  return texinfo;
}
et mon header
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
/*
 * header.h
 *
 *  Created on: 9 mai 2011
 *      Author: hannibal
 */
 
#ifndef HEADER_H_
#define HEADER_H_
 
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
 
 
void creerListeEcran();
void creerListeEcranPlace();
void creerListeTour();
void creerListeTourPlace();
void creerListeClavier();
void creerListeClavierPlace();
void creerListeChaise();
void creerListeChaisePlace();
void creerListeSalle();
void creerListeTable();
 
void afficheEcran();
void afficheTour();
void afficheClavier();
void afficheChaise();
void afficheTable();
 
void afficher();
void rafraichir(int width, int height);
void calculObs();
int angleAleat(int a, int b);
void keyboard(unsigned char key, int x, int y);
void special(int key, int x, int y);
void motion(int x, int y);
void initialiserLumiere();
void initialiserTexture();
void creerCube(GLuint id1, GLuint id2, GLuint id3, GLuint id4, GLuint id5, GLuint id6);
 
 
void GetTextureInfo (tga_header_t *header, gl_texture_t *texinfo);
void ReadTGA8bits (FILE *fp, GLubyte *colormap, gl_texture_t *texinfo);
void ReadTGA16bits (FILE *fp, gl_texture_t *texinfo);
void ReadTGA24bits (FILE *fp, gl_texture_t *texinfo);
void ReadTGA32bits (FILE *fp, gl_texture_t *texinfo);
void ReadTGAgray8bits (FILE *fp, gl_texture_t *texinfo);
void ReadTGAgray16bits (FILE *fp, gl_texture_t *texinfo);
void ReadTGA8bitsRLE (FILE *fp, GLubyte *colormap, gl_texture_t *texinfo);
void ReadTGA16bitsRLE (FILE *fp, gl_texture_t *texinfo);
void ReadTGA24bitsRLE (FILE *fp, gl_texture_t *texinfo);
void ReadTGA32bitsRLE (FILE *fp, gl_texture_t *texinfo);
void ReadTGAgray8bitsRLE (FILE *fp, gl_texture_t *texinfo);
void ReadTGAgray16bitsRLE (FILE *fp, gl_texture_t *texinfo);
ReadTGAFile (const char *filename);
 
#endif /* HEADER_H_ */

donc j'essaie de compilé tout cela sous eclispe et la j'ai ceci comme erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
Description	Resource	Path	Location	Type
‘gl_texture_t’ undeclared (first use in this function)	salle.c	/salleOpenGL	line 889	C/C++ Problem
‘texture’ undeclared (first use in this function)	salle.c	/salleOpenGL	line 889	C/C++ Problem
expected ‘)’ before ‘*’ token	header.h	/salleOpenGL	line 46	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 47	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 48	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 49	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 50	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 51	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 52	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 53	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 54	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 55	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 56	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 57	C/C++ Problem
expected declaration specifiers or ‘...’ before ‘gl_texture_t’	header.h	/salleOpenGL	line 58	C/C++ Problem
data definition has no type or storage class	header.h	/salleOpenGL	line 59	C/C++ Problem
type defaults to ‘int’ in declaration of ‘ReadTGAFile’	header.h	/salleOpenGL	line 59	C/C++ Problem


J'ai bien sur inclu mes lib opengl (glut).


Je vous remercie d'avance pour votre aide