-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
516 lines (485 loc) · 15.6 KB
/
main.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
#include <windows.h>
#include <fstream>
#include <gl/gl.h>
#include <gl/glut.h>
#include <iostream>
#include "imageloader.h"
using namespace std;
GLuint _wall;
GLuint _roof;
GLuint _door;
GLuint _small_gate;
GLuint _picture1;
GLuint _window1;
GLuint _floor1;
static double angle=0;
static int begin;
static int spin = 90;
#define langkah 1.0
#define navigasi 10.0
#define spot 5.0
int depth;
int posisi = 0;
float camera_x = 7.5;
float camera_y = 3.7;
float camera_z = -30.0;
float camera_angle = 0.0;
float camera_rotate = 7.5;
float flashlight = 7.5;
void handleResize(int w, int h) {
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);
glMatrixMode(GL_MODELVIEW);
}
//cara load texture
GLuint loadTexture(Image* image) {
GLuint textureId;
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
glTexImage2D(GL_TEXTURE_2D, //Always GL_TEXTURE_2D
0, //0 for now
GL_RGB, //Format OpenGL uses for image
image->width, image->height, //Width and height
0, //The border of the image
GL_RGB, //GL_RGB, because pixels are stored in RGB format
GL_UNSIGNED_BYTE, //GL_UNSIGNED_BYTE, because pixels are stored
//as unsigned numbers
image->pixels); //The actual pixel data
return textureId;
}
void initRendering() {
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
//glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_TEXTURE_2D);
//dinding
Image* image1 = loadBMP("wood_texture_2.bmp");
_wall = loadTexture(image1);
delete image1;
//roof
Image* image2 = loadBMP("roof_texture_1.bmp");
_roof = loadTexture(image2);
delete image2;
//pintu
Image* image3 = loadBMP("door_texture_1.bmp");
_door = loadTexture(image3);
delete image3;
//pagar kecil
Image* image4 = loadBMP("wood_texture_3.bmp");
_small_gate = loadTexture(image4);
delete image4;
//lukisan
Image* image5 = loadBMP("picture_texture_1.bmp");
_picture1 = loadTexture(image5);
delete image5;
//cendela
Image* image6 = loadBMP("window_texture_1.bmp");
_window1 = loadTexture(image6);
delete image6;
//lantai
Image* image7 = loadBMP("wood_texture_1.bmp");
_floor1 = loadTexture(image7);
delete image7;
}
void
movelight(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
begin = x;
}
}
void
motion(int x, int y)
{
spin = (spin - (x - begin)) % 360;
begin = x;
glutPostRedisplay();
}
void myinit(void){
glViewport(0,0,640,480);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
depth = 1;
//atur cahaya
GLfloat ambientLight[] = {0.3f, 0.3f, 0.3f, 1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);
GLfloat lightColor[] = {0.7f, 0.7f, 0.7f, 1.0f};
GLfloat lightPos[] = {-2 * 10, 10, 4 * 10, 1.0f};
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
}
void display(void){
GLfloat position[] =
//{7.5, 0.0, -50.5, 1.0};
//{flashlight, 0.0, -100.5, 0.0};
{flashlight, 0.0, -100.5, 0.0};
if (depth)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
else
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotated((GLdouble) spin, 0.0, 1.0, 0.0);
glRotated(0.0, 1.0, 0.0, 0.0);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glTranslated(0.0, -0.25, 1.5);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glColor3f(0.0, 1.0, 1.0);
glutWireCube(0.07);
glEnable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glColor3f(1.0, 1.0, 1.0);
glPopMatrix();
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glPushMatrix();
//if (posisi == 0)
gluLookAt(camera_x, camera_y, camera_z, camera_rotate, camera_angle, 100.0, 0.0, 1.0, 0.0);
glTranslatef(7.5,0.0,0.0);
//if (posisi == 1)
// gluLookAt(camera_x+(-1*langkah), camera_y, camera_z, 7.5, 0.0, 1000.0, 0.0, 1.0, 0.0);
//glTranslatef(x+(-1*langkah), y, z);
//if (posisi == 2)
//camera_z = camera_z + langkah;
// gluLookAt(camera_x, camera_y, camera_z+langkah, 7.5, 0.0, 1000.0, 0.0, 1.0, 0.0);
//glTranslatef(x, y, z+(-1*langkah));
//if (posisi == 3)
// gluLookAt(camera_x+langkah, camera_y, camera_z, 7.5, 0.0, 1000.0, 0.0, 1.0, 0.0);
//glTranslatef(x+langkah, y, z);
//if (posisi == 4)
// gluLookAt(camera_x, camera_y, camera_z+(-1*langkah), 7.5, 0.0, 1000.0, 0.0, 1.0, 0.0);
//glTranslatef(x, y, z+langkah);
//glRotatef(angle, 0.0f, 1.0f, 0.0f);
//angle+=0.05;
//set gambar
glBindTexture(GL_TEXTURE_2D, _wall);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//depan banget
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(2.5f, 0.0f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(7.5f, 0.0f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(7.5f, 7.0f, -5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(2.5f, 7.0f, -5.0f);
glEnd();
//set gambar
glBindTexture(GL_TEXTURE_2D, _door);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//pintu
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(0.0f, 0.2f, -2.1f);
glTexCoord2f(0.0, 0.0); glVertex3f(2.0f, 0.2f, -2.1f);
glTexCoord2f(1.0, 0.0); glVertex3f(2.0f, 6.0f, -2.1f);
glTexCoord2f(1.0, 1.0); glVertex3f(0.0f, 6.0f, -2.1f);
glEnd();
//depan menjorok
glBindTexture(GL_TEXTURE_2D, _wall);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(-7.5f, 0.0f, -2.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(2.5f, 0.0f, -2.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(2.5f, 7.0f, -2.0f);
glTexCoord2f(1.0, 1.0); glVertex3f( -7.5f, 7.0f, -2.0f);
glEnd();
//penyambung depan banget dan menjorok
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(2.5f, 0.0f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(2.5f, 0.0f, -2.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(2.5f, 7.0f, -2.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(2.5f, 7.0f, -5.0f);
glEnd();
//pagar kecil bagian batangan
glBindTexture(GL_TEXTURE_2D, _small_gate);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBegin(GL_QUADS);
double simpan = -7.0;
for(int a=0;a<15;a++)
{
if(a%2==0)
{
glTexCoord2f(0.0, 1.0); glVertex3f(simpan-0.2, 0.0f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(simpan, 0.0f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(simpan, 2.0f, -5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(simpan-0.2, 2.0f, -5.0f);
}
simpan += 0.5;
}
simpan = -7.0;
for(int a=0;a<15;a++)
{
if(a%2==0)
{
glTexCoord2f(0.0, 1.0); glVertex3f(simpan-0.2, 0.0f, -4.7f);
glTexCoord2f(0.0, 0.0); glVertex3f(simpan, 0.0f, -4.7f);
glTexCoord2f(1.0, 0.0); glVertex3f(simpan, 2.0f, -4.7f);
glTexCoord2f(1.0, 1.0); glVertex3f(simpan-0.2, 2.0f, -4.7f);
}
simpan += 0.5;
}
simpan = -7.0;
for(int a=0;a<15;a++)
{
if(a%2==0)
{
glTexCoord2f(0.0, 1.0); glVertex3f(simpan, 0.0f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(simpan, 0.0f, -4.7f);
glTexCoord2f(1.0, 0.0); glVertex3f(simpan, 2.0f, -4.7f);
glTexCoord2f(1.0, 1.0); glVertex3f(simpan, 2.0f, -5.0f);
}
simpan += 0.5;
}
simpan = -7.0;
for(int a=0;a<15;a++)
{
if(a%2==0)
{
glTexCoord2f(0.0, 1.0); glVertex3f(simpan-0.2, 0.0f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(simpan-0.2, 0.0f, -4.7f);
glTexCoord2f(1.0, 0.0); glVertex3f(simpan-0.2, 2.0f, -4.7f);
glTexCoord2f(1.0, 1.0); glVertex3f(simpan-0.2, 2.0f, -5.0f);
}
simpan += 0.5;
}
glEnd();
//pagar kecil bagian batangan
glBegin(GL_QUADS);
//atas
glTexCoord2f(0.0, 1.0); glVertex3f(-7.3, 2.2f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(simpan-0.5, 2.2f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(simpan-0.5, 2.2f, -4.7f);
glTexCoord2f(1.0, 1.0); glVertex3f(-7.3, 2.2f, -4.7f);
//bawah
glTexCoord2f(0.0, 1.0); glVertex3f(-7.3, 2.0f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(simpan-0.5, 2.0f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(simpan-0.5, 2.0f, -4.7f);
glTexCoord2f(1.0, 1.0); glVertex3f(-7.3, 2.0f, -4.7f);
//depan
glTexCoord2f(0.0, 1.0); glVertex3f(-7.3, 2.0f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(simpan-0.5, 2.0f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(simpan-0.5, 2.2f, -5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(-7.3, 2.2f, -5.0f);
//belakang
glTexCoord2f(0.0, 1.0); glVertex3f(-7.3, 2.0f, -4.7f);
glTexCoord2f(0.0, 0.0); glVertex3f(simpan-0.5, 2.0f, -4.7f);
glTexCoord2f(1.0, 0.0); glVertex3f(simpan-0.5, 2.2f, -4.7f);
glTexCoord2f(1.0, 1.0); glVertex3f(-7.3, 2.2f, -4.7f);
glEnd();
//lukisan
glBindTexture(GL_TEXTURE_2D, _picture1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(-7.2f, 3.0f, -4.5f);
glTexCoord2f(1.0, 0.0); glVertex3f(-7.2f, 5.0f, -4.5f);
glTexCoord2f(1.0, 1.0); glVertex3f(-7.2f, 5.0f, -3.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(-7.2f, 3.0f, -3.0f);
glEnd();
//cendela menjorok
glBindTexture(GL_TEXTURE_2D, _window1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBegin(GL_QUADS);
glTexCoord2f(1.0, 1.0); glVertex3f(-6.5f, 2.0f, -2.1f);
glTexCoord2f(0.0, 1.0); glVertex3f(-2.5f, 2.0f, -2.1f);
glTexCoord2f(0.0, 0.0); glVertex3f(-2.5f, 5.0f, -2.1f);
glTexCoord2f(1.0, 0.0); glVertex3f( -6.5f, 5.0f, -2.1f);
glEnd();
glBindTexture(GL_TEXTURE_2D, _wall);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//kanan
glBegin(GL_QUADS);
glTexCoord2f(1.0, 1.0); glVertex3f(7.5f, 0.0f, -5.0f);
glTexCoord2f(0.0, 1.0); glVertex3f(7.5f, 7.0f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(7.5f, 7.0f, 5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(7.5f, 0.0f, 5.0f);
glEnd();
//kiri
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(-7.3f, 0.0f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(-7.3f, 7.0f, -5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(-7.3f, 7.0f, 5.0f);
glTexCoord2f(0.0, 1.0); glVertex3f(-7.3f, 0.0f, 5.0f);
glEnd();
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(-7.5f, 0.0f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(-7.5f, 7.0f, -5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(-7.5f, 7.0f, 5.0f);
glTexCoord2f(0.0, 1.0); glVertex3f(-7.5f, 0.0f, 5.0f);
glEnd();
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(-7.5f, 0.0f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(-7.3f, 0.0f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(-7.3f, 7.0f, -5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f( -7.5f, 7.0f, -5.0f);
glEnd();
//belakang
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(-7.5f, 0.0f, 5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(7.5f, 0.0f, 5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(7.5f, 7.0f, 5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f( -7.5f, 7.0f, 5.0f);
glEnd();
glBindTexture(GL_TEXTURE_2D, _roof);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//atas depan
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0, 0.0); glVertex3f(-7.5f, 7.0f, -5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(0.0f, 10.0f, 0.0f);
glTexCoord2f(2.0, 0.0); glVertex3f(7.5f, 7.0f, -5.0f);
glEnd();
//atas belakang
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0, 0.0); glVertex3f(-7.5f, 7.0f, 5.0f);
glTexCoord2f(2.0, 0.0); glVertex3f(7.5f, 7.0f, 5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(0.0f, 10.0f, 0.0f);
glEnd();
//atas kiri
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0, 0.0); glVertex3f(-7.5f, 7.0f, -5.0f);
glTexCoord2f(2.0, 0.0); glVertex3f(-7.5f, 7.0f, 5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(0.0f, 10.0f, 0.0f);
glEnd();
//atas kanan
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0, 0.0); glVertex3f(7.5f, 7.0f, -5.0f);
glTexCoord2f(2.0, 0.0); glVertex3f(7.5f, 7.0f, 5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(0.0f, 10.0f, 0.0f);
glEnd();
glBindTexture(GL_TEXTURE_2D, _floor1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//bawah
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(-7.5f, 0.0f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(7.5f, 0.0f, -5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(7.5f, 0.0f, 5.0f);
glTexCoord2f(0.0, 1.0); glVertex3f(-7.5f, 0.0f, 5.0f);
glEnd();
//sebagai pondasi
glBindTexture(GL_TEXTURE_2D, _wall);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//kiri pondasi
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(-7.5f, -0.5f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(-7.5f, 0.0f, -5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(-7.5f, 0.0f, 5.0f);
glTexCoord2f(0.0, 1.0); glVertex3f(-7.5f, -0.5f, 5.0f);
glEnd();
//kanan pondasi
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(7.5f, 0.0f, 5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(7.5f, -0.5f, 5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(7.5f, -0.5f, -5.0f);
glTexCoord2f(0.0, 1.0); glVertex3f(7.5f, 0.0f, -5.0f);
glEnd();
//depan pondasi
//glColor3d(1,0,0);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(-7.5f, 0.0f, -5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(7.5f, 0.0f, -5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(7.5f, -0.5f, -5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(-7.5f, -0.5f, -5.0f);
glEnd();
//belakang pondasi
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(-7.5f, -0.5f, 5.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(7.5f, -0.5f, 5.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(7.5f, 0.0f, 5.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(-7.5f, 0.0f, 5.0f);
glEnd();
glFlush();
glPopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
void keyboard(unsigned char key, int x, int y)
{
/* Petunjuk navigasi cursor:
"a": Bergerak ke kiri
"d": Bergerak ke kanan
"w": Bergerak maju
"s": Bergerak mundur
"t": Mengatur keberadaan kedalaman
*/
switch (key)
{
case 'a':
case 'A':
//glTranslatef(langkah, 0.0, 0.0);
camera_x = camera_x + langkah;
//posisi = 1;
break;
case 'd':
case 'D':
//glTranslatef((-1*langkah), 0.0, 0.0);
camera_x = camera_x - langkah;
//posisi = 3;
break;
case 'w':
case 'W':
//glTranslatef(0.0, 0.0, langkah);
camera_z = camera_z + langkah;
//posisi = 2;
break;
case 's':
case 'S':
//glTranslatef(0.0, 0.0, (-1*langkah));
camera_z = camera_z - langkah;
//posisi = 4;
break;
case 'i':
case 'I':
//glTranslatef(0.0, 0.0, (-1*langkah));
camera_angle = camera_angle + navigasi;
//posisi = 4;
break;
case 'k':
case 'K':
//glTranslatef(0.0, 0.0, (-1*langkah));
camera_angle = camera_angle - navigasi;
//posisi = 4;
break;
case 'j':
case 'J':
//glRotatef(-1.0, 0.0f, 1.0f, 0.0f);
camera_rotate = camera_rotate + navigasi;
flashlight = flashlight + spot;
break;
case 'l':
case 'L':
//glRotatef(1.0, 0.0f, 1.0f, 0.0f);
camera_rotate = camera_rotate - navigasi;
flashlight = flashlight - spot;
break;
case 't':
case 'T':
if (depth)
{
depth = 0;
glDisable(GL_DEPTH_TEST);
}
else
{
depth = 1;
glEnable(GL_DEPTH_TEST);
}
}
display();
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(640,480);
glutInitWindowPosition(10, 10);
glutCreateWindow("FP_Grafkom");
myinit();
glutMouseFunc(movelight);
glutMotionFunc(motion);
glutKeyboardFunc(keyboard);
initRendering();
glutReshapeFunc(handleResize);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}