|
1
|
+#include <math.h> |
|
2
|
+#include <iostream> |
|
3
|
+#include <vector> |
|
4
|
+#include "stim/math/vector.h" |
|
5
|
+//#include <GL/gl.h> |
|
6
|
+#include <GL/glew.h> |
|
7
|
+#include <GL/glut.h> |
|
8
|
+//#include <GL/freeglut.h> |
|
9
|
+//#include <GL/glext.h> |
|
10
|
+#include "stim/gl/gl_spider.h" |
|
11
|
+#include "stim/gl/gl_texture.h" |
|
12
|
+#include "stim/gl/error.h" |
|
13
|
+#include "stim/visualization/camera.h" |
|
14
|
+#define VERTICAL 1 |
|
15
|
+#define HORIZONTAL 1 |
|
16
|
+ stim::camera cam; |
|
17
|
+ stim::camera Parker; |
|
18
|
+ GLuint texID; |
|
19
|
+ GLuint texID2; |
|
20
|
+// GLuint fboId; |
|
21
|
+ stim::vec<float> D; |
|
22
|
+// GLuint rboId; |
|
23
|
+// GLuint pbo; |
|
24
|
+ float a = -1.0; |
|
25
|
+ float b = 1.0; |
|
26
|
+ GLsizei size[2] = {900,900}; |
|
27
|
+ GLfloat Normals[6][3] = |
|
28
|
+ {{ -1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, |
|
29
|
+ {0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}}; |
|
30
|
+ GLint faces[6][4] = |
|
31
|
+ {{0, 1, 2, 3}, {4, 5, 7, 6}, {1, 5, 7, 2}, |
|
32
|
+ {3, 2, 7, 6}, {0, 4, 6, 3}, {0, 1, 5, 4}}; |
|
33
|
+ GLfloat vertex[8][3] = |
|
34
|
+ {{0.0, 0.0, 1.0}, {1.0, 0.0, 1.0}, {1.0, 1.0, 1.0}, |
|
35
|
+ {0.0, 1.0, 1.0}, {0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, |
|
36
|
+ {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0}}; |
|
37
|
+ |
|
38
|
+ GLint lines[24] = {0,1,1,2,2,3,0,3,4,5,5,7,7,6,6,4,3,6,2,7,1,5,0,4}; |
|
39
|
+ GLfloat vertexDrw[8][3] = |
|
40
|
+ {{a, a, b}, {b, a, b}, {b, b, b}, |
|
41
|
+ {a, b, b}, {a, a, a}, {b, a, a}, |
|
42
|
+ {a, b, a}, {b, b, a}}; |
|
43
|
+ static float mousePos[2] = {0,0}; |
|
44
|
+ static float prevmousePos[2] = {0,0}; |
|
45
|
+ unsigned long tick = 0; |
|
46
|
+ stim::vec<float> p; |
|
47
|
+ stim::vec<float> up; |
|
48
|
+ stim::vec<float> d; |
|
49
|
+ static bool button1 = false; |
|
50
|
+ static bool button_shift = false; |
|
51
|
+ static float degtorad = 360/(2*M_PI); |
|
52
|
+ static GLfloat adjustTex = 1.0/426.0; |
|
53
|
+ static GLfloat adjustDrw = 2.0/426.0; |
|
54
|
+ static GLfloat oriTex[3] = {adjustTex*213+adjustTex/2 |
|
55
|
+ ,adjustTex*213+adjustTex/2 |
|
56
|
+ ,adjustTex*213+adjustTex/2}; |
|
57
|
+ static GLfloat oriDrw[3] = {adjustDrw/2 |
|
58
|
+ ,adjustDrw/2 |
|
59
|
+ ,adjustDrw/2}; |
|
60
|
+ static GLfloat org[2] = {adjustTex/2,adjustTex/2+425*adjustTex}; |
|
61
|
+ stim::gl_spider<float> spidey; |
|
62
|
+ stim::vec<float>p1; |
|
63
|
+ stim::vec<float>p2; |
|
64
|
+ stim::vec<float>p3; |
|
65
|
+ stim::vec<float>p4; |
|
66
|
+//init for a cube |
|
67
|
+/*void |
|
68
|
+GenerateFBO(unsigned int width, unsigned int height) |
|
69
|
+{ |
|
70
|
+ glGenFramebuffers(1, &fboId); |
|
71
|
+ glBindFramebuffer(GL_FRAMEBUFFER, fboId); |
|
72
|
+ int numChannels = 3; |
|
73
|
+ unsigned char* texels = new unsigned char[width * height * numChannels]; |
|
74
|
+ glGenTextures(1, &texID2); |
|
75
|
+ glBindTexture(GL_TEXTURE_2D, texID2); |
|
76
|
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
|
77
|
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
|
78
|
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
|
79
|
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
80
|
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, |
|
81
|
+ width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, texels); |
|
82
|
+ delete[] texels; |
|
83
|
+ glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
84
|
+}*/ |
|
85
|
+ |
|
86
|
+void |
|
87
|
+glInit() |
|
88
|
+{ |
|
89
|
+ CHECK_OPENGL_ERROR |
|
90
|
+ glEnable(GL_TEXTURE_3D); |
|
91
|
+ glEnable(GL_DEPTH_TEST); |
|
92
|
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
|
93
|
+ glClearColor(0.0, 0.0, 0.0, 0.0); |
|
94
|
+ glColor4d(0.0, 0.0, 0.0, 1.0); |
|
95
|
+ glShadeModel(GL_FLAT); |
|
96
|
+ cam.setPosition(3.0,3.0,3.0); |
|
97
|
+ cam.setFocalDistance(6.0); |
|
98
|
+ cam.LookAt(0.0, 0.0, 0.0); |
|
99
|
+ p = cam.getPosition(); |
|
100
|
+ up = cam.getUp(); |
|
101
|
+ d = cam.getLookAt(); |
|
102
|
+ glViewport(0, 0, size[0], size[1]); |
|
103
|
+ glMatrixMode(GL_PROJECTION); |
|
104
|
+ glLoadIdentity(); |
|
105
|
+ glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0); |
|
106
|
+ glMatrixMode(GL_MODELVIEW); |
|
107
|
+ spidey = stim::gl_spider<float>(0.515372, 0.564174, 0.494553, |
|
108
|
+ 0.130563, -0.98295, -0.129467, |
|
109
|
+ 0.03, 0.03); |
|
110
|
+ spidey.attachSpider(texID); |
|
111
|
+ Parker.setPosition(spidey.getPosition()); |
|
112
|
+ Parker.LookAt(spidey.getDirection()); |
|
113
|
+// GenerateFBO(400, 200); |
|
114
|
+ spidey.initCuda(); |
|
115
|
+ //glGenRenderbuffers(1, &rboId); |
|
116
|
+ //glBindRenderbuffer(GL_RENDERBUFFER, rboId); |
|
117
|
+ //GLuint rboId; |
|
118
|
+ //glGenRenderbuffers(1, &rboId); |
|
119
|
+ //glBindRenderbuffer(GL_RENDERBUFFER, rboId); |
|
120
|
+ //glGenBuffers(1, &pbo); |
|
121
|
+ //glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbo); |
|
122
|
+ //glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, 426*426*sizeof(uchar4), NULL, GL_DYNAMIC_DRAW_ARB); |
|
123
|
+ CHECK_OPENGL_ERROR |
|
124
|
+} |
|
125
|
+ |
|
126
|
+ |
|
127
|
+void |
|
128
|
+DrawCube() |
|
129
|
+{ |
|
130
|
+ glLineWidth(2.5); |
|
131
|
+ glColor3f(1.0,0.0,0.0); |
|
132
|
+ glBegin(GL_LINES); |
|
133
|
+ |
|
134
|
+ for (int i = 0; i < 24; i++) |
|
135
|
+ { |
|
136
|
+ glVertex3f(vertexDrw[lines[i]][0], |
|
137
|
+ vertexDrw[lines[i]][1], |
|
138
|
+ vertexDrw[lines[i]][2]); |
|
139
|
+ } |
|
140
|
+ glEnd(); |
|
141
|
+} |
|
142
|
+ |
|
143
|
+void |
|
144
|
+DrawPlanes() |
|
145
|
+{ |
|
146
|
+ glEnable(GL_TEXTURE_3D); |
|
147
|
+ glBindTexture(GL_TEXTURE_3D, texID); |
|
148
|
+ p1 = spidey.ver.p(1,1); |
|
149
|
+ p2 = spidey.ver.p(1,0); |
|
150
|
+ p3 = spidey.ver.p(0,0); |
|
151
|
+ p4 = spidey.ver.p(0,1); |
|
152
|
+ //glPushName(VERTICAL); |
|
153
|
+ glBegin(GL_QUADS); |
|
154
|
+ glTexCoord3f( |
|
155
|
+ p1[0], |
|
156
|
+ p1[1], |
|
157
|
+ p1[2] |
|
158
|
+ ); |
|
159
|
+ glVertex3f( |
|
160
|
+ p1[0], |
|
161
|
+ p1[1], |
|
162
|
+ p1[2] |
|
163
|
+ ); |
|
164
|
+ glTexCoord3f( |
|
165
|
+ p2[0], |
|
166
|
+ p2[1], |
|
167
|
+ p2[2] |
|
168
|
+ ); |
|
169
|
+ glVertex3f( |
|
170
|
+ p2[0], |
|
171
|
+ p2[1], |
|
172
|
+ p2[2] |
|
173
|
+ ); |
|
174
|
+ glTexCoord3f( |
|
175
|
+ p3[0], |
|
176
|
+ p3[1], |
|
177
|
+ p3[2] |
|
178
|
+ ); |
|
179
|
+ glVertex3f( |
|
180
|
+ p3[0], |
|
181
|
+ p3[1], |
|
182
|
+ p3[2] |
|
183
|
+ ); |
|
184
|
+ glTexCoord3f( |
|
185
|
+ p4[0], |
|
186
|
+ p4[1], |
|
187
|
+ p4[2] |
|
188
|
+ ); |
|
189
|
+ glVertex3f( |
|
190
|
+ p4[0], |
|
191
|
+ p4[1], |
|
192
|
+ p4[2] |
|
193
|
+ ); |
|
194
|
+ glEnd(); |
|
195
|
+ //glPopName(); |
|
196
|
+ p1 = spidey.hor.p(1,1); |
|
197
|
+ p2 = spidey.hor.p(1,0); |
|
198
|
+ p3 = spidey.hor.p(0,0); |
|
199
|
+ p4 = spidey.hor.p(0,1); |
|
200
|
+ //glPushName(HORIZONTAL); |
|
201
|
+ glBegin(GL_QUADS); |
|
202
|
+ glTexCoord3f( |
|
203
|
+ p1[0], |
|
204
|
+ p1[1], |
|
205
|
+ p1[2] |
|
206
|
+ ); |
|
207
|
+ glVertex3f( |
|
208
|
+ p1[0], |
|
209
|
+ p1[1], |
|
210
|
+ p1[2] |
|
211
|
+ ); |
|
212
|
+ glTexCoord3f( |
|
213
|
+ p2[0], |
|
214
|
+ p2[1], |
|
215
|
+ p2[2] |
|
216
|
+ ); |
|
217
|
+ glVertex3f( |
|
218
|
+ p2[0], |
|
219
|
+ p2[1], |
|
220
|
+ p2[2] |
|
221
|
+ ); |
|
222
|
+ glTexCoord3f( |
|
223
|
+ p3[0], |
|
224
|
+ p3[1], |
|
225
|
+ p3[2] |
|
226
|
+ ); |
|
227
|
+ glVertex3f( |
|
228
|
+ p3[0], |
|
229
|
+ p3[1], |
|
230
|
+ p3[2] |
|
231
|
+ ); |
|
232
|
+ glTexCoord3f( |
|
233
|
+ p4[0], |
|
234
|
+ p4[1], |
|
235
|
+ p4[2] |
|
236
|
+ ); |
|
237
|
+ glVertex3f( |
|
238
|
+ p4[0], |
|
239
|
+ p4[1], |
|
240
|
+ p4[2] |
|
241
|
+ ); |
|
242
|
+ glEnd(); |
|
243
|
+ //glPopName(); |
|
244
|
+ glBindTexture(GL_TEXTURE_3D, 0); |
|
245
|
+ glDisable(GL_TEXTURE_3D); |
|
246
|
+} |
|
247
|
+void |
|
248
|
+DrawSpiders() |
|
249
|
+{ |
|
250
|
+ glEnable(GL_TEXTURE_3D); |
|
251
|
+ glBindTexture(GL_TEXTURE_3D, texID); |
|
252
|
+ p1 = spidey.hor.p(1,1); |
|
253
|
+ p2 = spidey.hor.p(1,0); |
|
254
|
+ p3 = spidey.hor.p(0,0); |
|
255
|
+ p4 = spidey.hor.p(0,1); |
|
256
|
+ glBegin(GL_QUADS); |
|
257
|
+ glTexCoord3f( |
|
258
|
+ p1[0], |
|
259
|
+ p1[1], |
|
260
|
+ p1[2] |
|
261
|
+ ); |
|
262
|
+ glVertex2f(0.0,0.0); |
|
263
|
+ glTexCoord3f( |
|
264
|
+ p2[0], |
|
265
|
+ p2[1], |
|
266
|
+ p2[2] |
|
267
|
+ ); |
|
268
|
+ glVertex2f(1.0, 0.0); |
|
269
|
+ glTexCoord3f( |
|
270
|
+ p3[0], |
|
271
|
+ p3[1], |
|
272
|
+ p3[2] |
|
273
|
+ ); |
|
274
|
+ glVertex2f(1.0, 2.0); |
|
275
|
+ glTexCoord3f( |
|
276
|
+ p4[0], |
|
277
|
+ p4[1], |
|
278
|
+ p4[2] |
|
279
|
+ ); |
|
280
|
+ glVertex2f(0.0, 2.0); |
|
281
|
+ glEnd(); |
|
282
|
+ p1 = spidey.ver.p(1,1); |
|
283
|
+ p2 = spidey.ver.p(1,0); |
|
284
|
+ p3 = spidey.ver.p(0,0); |
|
285
|
+ p4 = spidey.ver.p(0,1); |
|
286
|
+ |
|
287
|
+ glBegin(GL_QUADS); |
|
288
|
+ glTexCoord3f( |
|
289
|
+ p1[0], |
|
290
|
+ p1[1], |
|
291
|
+ p1[2] |
|
292
|
+ ); |
|
293
|
+ glVertex2f(1.0, 0.0); |
|
294
|
+ glTexCoord3f( |
|
295
|
+ p2[0], |
|
296
|
+ p2[1], |
|
297
|
+ p2[2] |
|
298
|
+ ); |
|
299
|
+ glVertex2f(2.0, 0.0); |
|
300
|
+ glTexCoord3f( |
|
301
|
+ p3[0], |
|
302
|
+ p3[1], |
|
303
|
+ p3[2] |
|
304
|
+ ); |
|
305
|
+ glVertex2f(2.0, 2.0); |
|
306
|
+ glTexCoord3f( |
|
307
|
+ p4[0], |
|
308
|
+ p4[1], |
|
309
|
+ p4[2] |
|
310
|
+ ); |
|
311
|
+ glVertex2f(1.0, 2.0); |
|
312
|
+ glEnd(); |
|
313
|
+ glBindTexture(GL_TEXTURE_3D, 0); |
|
314
|
+ glDisable(GL_TEXTURE_3D); |
|
315
|
+} |
|
316
|
+ |
|
317
|
+//render cube |
|
318
|
+ |
|
319
|
+void |
|
320
|
+renderScene() |
|
321
|
+{ |
|
322
|
+ glViewport(0, 0, size[0], size[1]); |
|
323
|
+ glMatrixMode(GL_PROJECTION); |
|
324
|
+ glLoadIdentity(); |
|
325
|
+ glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0); |
|
326
|
+ glMatrixMode(GL_MODELVIEW); |
|
327
|
+ glInitNames(); |
|
328
|
+ glClearColor(0,0,0,0); |
|
329
|
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
330
|
+ glMatrixMode(GL_MODELVIEW); |
|
331
|
+ glLoadIdentity(); |
|
332
|
+ p = cam.getPosition(); |
|
333
|
+ up = cam.getUp(); |
|
334
|
+ d = cam.getLookAt(); |
|
335
|
+ gluLookAt(p[0], p[1], p[2], d[0], d[1], d[2], up[0], up[1], up[2]); |
|
336
|
+ DrawPlanes(); |
|
337
|
+ DrawCube(); |
|
338
|
+ //glEnable(GL_TEXTURE_2D); |
|
339
|
+ |
|
340
|
+ |
|
341
|
+ //glBindTexture(GL_TEXTURE_2D, texID); |
|
342
|
+ /*glBindFramebuffer(GL_FRAMEBUFFER, fboId); |
|
343
|
+ glFramebufferTexture2D( |
|
344
|
+ GL_FRAMEBUFFER, |
|
345
|
+ GL_COLOR_ATTACHMENT0, |
|
346
|
+ GL_TEXTURE_2D, |
|
347
|
+ texID2, |
|
348
|
+ 0 |
|
349
|
+ ); |
|
350
|
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texID2, 0); |
|
351
|
+ glBindFramebuffer(GL_FRAMEBUFFER, fboId); |
|
352
|
+ GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; |
|
353
|
+ glDrawBuffers(1, DrawBuffers); |
|
354
|
+ if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) |
|
355
|
+ std::cout << "damn" << std::endl; |
|
356
|
+ glBindTexture(GL_TEXTURE_2D, texID2); |
|
357
|
+ glClearColor(1,1,1,1); |
|
358
|
+ glClear(GL_COLOR_BUFFER_BIT); |
|
359
|
+ //glLoadIdentity(); |
|
360
|
+ //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
361
|
+ CHECK_OPENGL_ERROR |
|
362
|
+ glMatrixMode(GL_PROJECTION); |
|
363
|
+ glLoadIdentity(); |
|
364
|
+ glMatrixMode(GL_MODELVIEW); |
|
365
|
+ glLoadIdentity(); |
|
366
|
+ glViewport(0,0,400,200); |
|
367
|
+ gluOrtho2D(0.0, 2.0, 0.0, 2.0); |
|
368
|
+ DrawSpiders(); |
|
369
|
+ //glPopMatrix(); |
|
370
|
+ //DrawSpiders2(); |
|
371
|
+ //glFlush(); |
|
372
|
+ //glFinish(); |
|
373
|
+ CHECK_OPENGL_ERROR |
|
374
|
+ glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
375
|
+ glBindTexture(GL_TEXTURE_2D, 0);*/ |
|
376
|
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, spidey.getFB()); |
|
377
|
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); |
|
378
|
+ glBlitFramebuffer(0,0,800,400, 0, 0, 800, 400, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
|
379
|
+ CHECK_OPENGL_ERROR |
|
380
|
+ //glBindFramebuffer(GL_FRAMEBUFFER,0); |
|
381
|
+ //glBindTexture(GL_TEXTURE_3D, texID); |
|
382
|
+ //glGenerateMipmap(GL_TEXTURE_3D); |
|
383
|
+ //glBindTexture(GL_TEXTURE_3D, 0); |
|
384
|
+ //glViewport(0,0, 800,800); |
|
385
|
+ |
|
386
|
+ //GLint curbuf; |
|
387
|
+ //glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &curbuf); |
|
388
|
+ //std::cout << curbuf << std::endl; |
|
389
|
+ |
|
390
|
+ //glViewport(0,0,600,600); |
|
391
|
+ //glBindFramebuffer(GL_FRAMEBUFFER, fboId); |
|
392
|
+ |
|
393
|
+ //glDrawBuffer(GL_FRAMEBUFFER0); |
|
394
|
+ //glDrawBuffer(fboId); |
|
395
|
+ //glClearColor(1,1,1,1); |
|
396
|
+ //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
397
|
+ //glLoadIdentity(); |
|
398
|
+ //std::cout << fboId << std::endl; |
|
399
|
+ //DrawSpiders(); |
|
400
|
+ |
|
401
|
+ //glBlitFramebuffer(0.0,0.0,1,1,0.0,0.0,1,1, GL_COLOR_BUFFER_BIT, GL_LINEAR); |
|
402
|
+ //gluOrtho2D(-5.0, -3.0, -5.0, -1.0); |
|
403
|
+ //glClearColor(1,1,1,1); |
|
404
|
+ //glBindTexture(GL_TEXTURE_3D, texID); |
|
405
|
+ //glPushMatrix(); |
|
406
|
+ //glGenerateMipmap(GL_TEXTURE_3D); |
|
407
|
+ //glBindTexture(GL_TEXTURE_3D, 0); |
|
408
|
+ //glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &curbuf); |
|
409
|
+ //std::cout << curbuf << std::endl; |
|
410
|
+ |
|
411
|
+// glCopyImageSubData(fboId, GL_FRAMEBUFFER, 0, 0, 0, 0, GL_FRONT_AND_BACK, GL_NONE, 0, 0, 0, 0, 20, 20, 0); |
|
412
|
+ |
|
413
|
+ |
|
414
|
+ glutSwapBuffers(); |
|
415
|
+} |
|
416
|
+ |
|
417
|
+ |
|
418
|
+void |
|
419
|
+MouseButton(int button, int state, int x, int y) |
|
420
|
+{ |
|
421
|
+ |
|
422
|
+ if (button == GLUT_LEFT_BUTTON) |
|
423
|
+ { |
|
424
|
+ button1 = (state == GLUT_DOWN) ? true : false; |
|
425
|
+ button_shift = glutGetModifiers(); |
|
426
|
+ prevmousePos[0] = (float)x; |
|
427
|
+ prevmousePos[1] = (float)y; |
|
428
|
+ } |
|
429
|
+ if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) |
|
430
|
+ { |
|
431
|
+ std::cout << spidey.getPosition() << std::endl |
|
432
|
+ << spidey.getDirection() << std::endl; |
|
433
|
+ std::cout << spidey.getCost() << std::endl; |
|
434
|
+ } |
|
435
|
+} |
|
436
|
+ |
|
437
|
+void MouseMotion(int x, int y) |
|
438
|
+{ |
|
439
|
+ if(button1 && !button_shift) |
|
440
|
+ { |
|
441
|
+ mousePos[0] = (prevmousePos[0] - (float) x)*0.0005; |
|
442
|
+ mousePos[1] = ((float)y - prevmousePos[1])*0.0005; |
|
443
|
+ prevmousePos[0] = (float)x; |
|
444
|
+ prevmousePos[1] = (float)y; |
|
445
|
+ cam.OrbitFocus(mousePos[0]*degtorad, mousePos[1]*degtorad); |
|
446
|
+ } |
|
447
|
+ if(button1 && button_shift) |
|
448
|
+ { |
|
449
|
+ mousePos[0] = (prevmousePos[0] - (float) x)*0.00001; |
|
450
|
+ mousePos[1] = ((float)y - prevmousePos[1])*0.00001; |
|
451
|
+ prevmousePos[0] = (float)x; |
|
452
|
+ prevmousePos[1] = (float)y; |
|
453
|
+ Parker.Pan(mousePos[0]*degtorad); |
|
454
|
+ Parker.Tilt(mousePos[1]*degtorad); |
|
455
|
+ spidey.setDirection(Parker.getDirection()); |
|
456
|
+ spidey.Update(); |
|
457
|
+ std::cout << Parker.getLookAt() << std::endl; |
|
458
|
+ } |
|
459
|
+} |
|
460
|
+ |
|
461
|
+void |
|
462
|
+idleFunction() |
|
463
|
+{ |
|
464
|
+ tick += 10; |
|
465
|
+ glutPostRedisplay(); |
|
466
|
+} |
|
467
|
+ |
|
468
|
+void |
|
469
|
+printCost() |
|
470
|
+{ |
|
471
|
+ |
|
472
|
+} |
|
473
|
+ |
|
474
|
+ |
|
475
|
+void |
|
476
|
+processSpecialKeys(int key, int xx, int yy) |
|
477
|
+{ |
|
478
|
+switch(key) { |
|
479
|
+ case GLUT_KEY_UP: |
|
480
|
+ oriTex[2] = oriTex[2]+adjustTex; |
|
481
|
+ if (oriTex[2] > org[1]){ |
|
482
|
+ oriTex[2] = org[1]; |
|
483
|
+ } |
|
484
|
+ else{ |
|
485
|
+ oriDrw[2] = oriDrw[2] + adjustDrw; |
|
486
|
+ } |
|
487
|
+ if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) |
|
488
|
+ { |
|
489
|
+ stim::vec<float> temp = spidey.getPosition(); |
|
490
|
+ temp[1] += 0.001; |
|
491
|
+ spidey.setPosition(temp); |
|
492
|
+ spidey.Update(); |
|
493
|
+ } |
|
494
|
+ if (glutGetModifiers() == GLUT_ACTIVE_CTRL) |
|
495
|
+ { |
|
496
|
+ //stim::vec<float> temp = Parker.getDirection(); |
|
497
|
+ //temp[1] += 0.001; |
|
498
|
+ Parker.Pan(0.01); |
|
499
|
+ spidey.setDirection(Parker.getDirection()); |
|
500
|
+ spidey.Update(); |
|
501
|
+ } |
|
502
|
+ break; |
|
503
|
+ case GLUT_KEY_DOWN: |
|
504
|
+ oriTex[2] = oriTex[2]-adjustTex; |
|
505
|
+ if (oriTex[2] < org[0]){ |
|
506
|
+ oriTex[2] = org[0]; |
|
507
|
+ } |
|
508
|
+ else{ |
|
509
|
+ oriDrw[2] = oriDrw[2] - adjustDrw; |
|
510
|
+ } |
|
511
|
+ if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) |
|
512
|
+ { |
|
513
|
+ stim::vec<float> temp = spidey.getPosition(); |
|
514
|
+ temp[1] -= 0.001; |
|
515
|
+ spidey.setPosition(temp); |
|
516
|
+ spidey.Update(); |
|
517
|
+ } |
|
518
|
+ if (glutGetModifiers() == GLUT_ACTIVE_CTRL) |
|
519
|
+ { |
|
520
|
+ //stim::vec<float> temp = Parker.getDirection(); |
|
521
|
+ //temp[1] -= 0.001; |
|
522
|
+ Parker.Pan(-0.01); |
|
523
|
+ spidey.setDirection(Parker.getDirection()); |
|
524
|
+ spidey.Update(); |
|
525
|
+ } |
|
526
|
+ break; |
|
527
|
+ case GLUT_KEY_LEFT: |
|
528
|
+ oriTex[1] = oriTex[1]+adjustTex; |
|
529
|
+ if (oriTex[1] > org[1]){ |
|
530
|
+ oriTex[1] = org[1]; |
|
531
|
+ } |
|
532
|
+ else{ |
|
533
|
+ oriDrw[1] = oriDrw[1] + adjustDrw; |
|
534
|
+ } |
|
535
|
+ if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) |
|
536
|
+ { |
|
537
|
+ stim::vec<float> temp = spidey.getPosition(); |
|
538
|
+ temp[0] += 0.001; |
|
539
|
+ spidey.setPosition(temp); |
|
540
|
+ spidey.Update(); |
|
541
|
+ } |
|
542
|
+ if (glutGetModifiers() == GLUT_ACTIVE_CTRL) |
|
543
|
+ { |
|
544
|
+ //stim::vec<float> temp = Parker.getDirection(); |
|
545
|
+ //temp[0] += 0.001; |
|
546
|
+ Parker.Tilt(0.01); |
|
547
|
+ spidey.setDirection(Parker.getDirection()); |
|
548
|
+ spidey.Update(); |
|
549
|
+ } |
|
550
|
+ break; |
|
551
|
+ case GLUT_KEY_RIGHT: |
|
552
|
+ oriTex[1] = oriTex[1]-adjustTex; |
|
553
|
+ if (oriTex[1] < org[0]){ |
|
554
|
+ oriTex[1] = org[0]; |
|
555
|
+ } |
|
556
|
+ else{ |
|
557
|
+ oriDrw[1] = oriDrw[1] - adjustDrw; |
|
558
|
+ } |
|
559
|
+ if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) |
|
560
|
+ { |
|
561
|
+ stim::vec<float> temp = spidey.getPosition(); |
|
562
|
+ temp[0] -= 0.001; |
|
563
|
+ spidey.setPosition(temp); |
|
564
|
+ spidey.Update(); |
|
565
|
+ } |
|
566
|
+ if (glutGetModifiers() == GLUT_ACTIVE_CTRL) |
|
567
|
+ { |
|
568
|
+ //stim::vec<float> temp = Parker.getDirection(); |
|
569
|
+ //temp[0] -= 0.001; |
|
570
|
+ Parker.Tilt(-0.01); |
|
571
|
+ spidey.setDirection(Parker.getDirection()); |
|
572
|
+ spidey.Update(); |
|
573
|
+ } |
|
574
|
+ break; |
|
575
|
+ } |
|
576
|
+ glutPostRedisplay(); |
|
577
|
+} |
|
578
|
+ |
|
579
|
+void |
|
580
|
+processKeys(unsigned char key, int x, int y) |
|
581
|
+{ |
|
582
|
+ if (key == 27) |
|
583
|
+ exit(0); |
|
584
|
+ if (key == 32) |
|
585
|
+ { |
|
586
|
+ spidey.Step(); |
|
587
|
+ std::cout << "Took a step" << std::endl; |
|
588
|
+ } |
|
589
|
+ if (key == 43) |
|
590
|
+ { |
|
591
|
+ stim::vec<float> temp = spidey.getMagnitude(); |
|
592
|
+ temp = temp + 0.001; |
|
593
|
+ spidey.setMagnitude(temp); |
|
594
|
+ spidey.Update(); |
|
595
|
+ } |
|
596
|
+ if (key == 45) |
|
597
|
+ { |
|
598
|
+ stim::vec<float> temp = spidey.getMagnitude(); |
|
599
|
+ temp = temp - 0.001; |
|
600
|
+ spidey.setMagnitude(temp); |
|
601
|
+ spidey.Update(); |
|
602
|
+ } |
|
603
|
+} |
|
604
|
+ |
|
605
|
+ |
|
606
|
+void |
|
607
|
+changeSize(int w, int h) |
|
608
|
+{ |
|
609
|
+ glViewport(0,0,w,h); |
|
610
|
+ glMatrixMode(GL_PROJECTION); |
|
611
|
+ glLoadIdentity(); |
|
612
|
+ glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0); |
|
613
|
+ //gluPerspective(90, 4.0/3.0, 0.1, 100.0); |
|
614
|
+ glMatrixMode(GL_MODELVIEW); |
|
615
|
+} |
|
616
|
+ |
|
617
|
+ |
|
618
|
+int |
|
619
|
+main(int argc, char **argv) |
|
620
|
+{ |
|
621
|
+ CHECK_OPENGL_ERROR |
|
622
|
+ glutInit(&argc, argv); |
|
623
|
+ glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); |
|
624
|
+ glutInitWindowSize(size[0], size[1]); |
|
625
|
+ glutCreateWindow("gl_texture"); |
|
626
|
+ //std::cout << " Initialization is complete in Glut" << std::endl; |
|
627
|
+ |
|
628
|
+ CHECK_OPENGL_ERROR |
|
629
|
+ glutKeyboardFunc(processKeys); |
|
630
|
+ CHECK_OPENGL_ERROR |
|
631
|
+ glutSpecialFunc(processSpecialKeys); |
|
632
|
+ CHECK_OPENGL_ERROR |
|
633
|
+ glutReshapeFunc(changeSize); |
|
634
|
+ CHECK_OPENGL_ERROR |
|
635
|
+ glutDisplayFunc(renderScene); |
|
636
|
+ CHECK_OPENGL_ERROR |
|
637
|
+ glutMouseFunc(MouseButton); |
|
638
|
+ CHECK_OPENGL_ERROR |
|
639
|
+ glutMotionFunc(MouseMotion); |
|
640
|
+ |
|
641
|
+ //std::cerr << " Keyboard and Reshape is complete in Glut" << std::endl; |
|
642
|
+ GLenum err = glewInit(); |
|
643
|
+ if (GLEW_OK != err) |
|
644
|
+ { |
|
645
|
+ std::cerr << "Failed" << std::endl; |
|
646
|
+ fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); |
|
647
|
+ } |
|
648
|
+ stim::gl_texture<unsigned char> stack ("/home/pavel/Documents/Test_Data/"); |
|
649
|
+ //stack.setDimensions(1.0,1.0,1.0); |
|
650
|
+ //D = stack.getDimensions(); |
|
651
|
+ stack.createTexture(); |
|
652
|
+ texID = stack.getTexture(); |
|
653
|
+ //std::cout << ("I have started an instance of the class") << std::endl; |
|
654
|
+ |
|
655
|
+ |
|
656
|
+ glInit(); |
|
657
|
+ CHECK_OPENGL_ERROR |
|
658
|
+ glutIdleFunc(idleFunction); |
|
659
|
+ CHECK_OPENGL_ERROR |
|
660
|
+ glutMainLoop(); |
|
661
|
+ CHECK_OPENGL_ERROR |
|
662
|
+ return 0; |
|
663
|
+} |
|
664
|
+ |
|
665
|
+ |
|
666
|
+//old code |
|
667
|
+ |
|
668
|
+ /* |
|
669
|
+ for (int i = 0; i < 6; i++) |
|
670
|
+ { |
|
671
|
+ //first vertex |
|
672
|
+ glTexCoord3f(vertex[faces[i][0]][0], |
|
673
|
+ vertex[faces[i][0]][1], |
|
674
|
+ vertex[faces[i][0]][2]); |
|
675
|
+ |
|
676
|
+ glVertex3f(vertex[faces[i][0]][0], |
|
677
|
+ vertex[faces[i][0]][1], |
|
678
|
+ vertex[faces[i][0]][2]); |
|
679
|
+ |
|
680
|
+ //second vertex |
|
681
|
+ glTexCoord3f(vertex[faces[i][1]][0], |
|
682
|
+ vertex[faces[i][1]][1], |
|
683
|
+ vertex[faces[i][1]][2]); |
|
684
|
+ |
|
685
|
+ glVertex3f(vertex[faces[i][1]][0], |
|
686
|
+ vertex[faces[i][1]][1], |
|
687
|
+ vertex[faces[i][1]][2]); |
|
688
|
+ //third vertex |
|
689
|
+ glTexCoord3f(vertex[faces[i][2]][0], |
|
690
|
+ vertex[faces[i][2]][1], |
|
691
|
+ vertex[faces[i][2]][2]); |
|
692
|
+ |
|
693
|
+ glVertex3f(vertex[faces[i][2]][0], |
|
694
|
+ vertex[faces[i][2]][1], |
|
695
|
+ vertex[faces[i][2]][2]); |
|
696
|
+ |
|
697
|
+ //fourth vertex |
|
698
|
+ glTexCoord3f(vertex[faces[i][3]][0], |
|
699
|
+ vertex[faces[i][3]][1], |
|
700
|
+ vertex[faces[i][3]][2]); |
|
701
|
+ |
|
702
|
+ glVertex3f(vertex[faces[i][3]][0], |
|
703
|
+ vertex[faces[i][3]][1], |
|
704
|
+ vertex[faces[i][3]][2]); |
|
705
|
+ |
|
706
|
+ |
|
707
|
+ }*/ |
|
708
|
+ |
|
709
|
+//init for a square. |
|
710
|
+/*void |
|
711
|
+glInitSquare(int w, int h) |
|
712
|
+{ |
|
713
|
+ glEnable(GL_TEXTURE_3D); |
|
714
|
+ glEnable(GL_DEPTH_TEST); |
|
715
|
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
|
716
|
+ glClearColor(0.0, 0.0, 0.0, 0.0); |
|
717
|
+ glColor4d(0.0, 0.0, 0.0, 1.0); |
|
718
|
+ //glPointSize(3.0); |
|
719
|
+ glShadeModel(GL_FLAT); |
|
720
|
+ |
|
721
|
+ glViewport(0, 0, (GLsizei) 900, (GLsizei) 900); |
|
722
|
+ glMatrixMode(GL_PROJECTION); |
|
723
|
+ glLoadIdentity(); |
|
724
|
+ gluPerspective(90, 4.0/3.0, 0.1, 100.0); |
|
725
|
+ glMatrixMode(GL_MODELVIEW); |
|
726
|
+ |
|
727
|
+} |
|
728
|
+//render square |
|
729
|
+void |
|
730
|
+renderSceneSquare() |
|
731
|
+{ |
|
732
|
+ glEnable(GL_TEXTURE_3D); |
|
733
|
+ glBindTexture(GL_TEXTURE_3D, texID); |
|
734
|
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
735
|
+ glMatrixMode(GL_MODELVIEW); |
|
736
|
+ glLoadIdentity(); |
|
737
|
+ glTranslatef(-0.5, -0.5, -pos); |
|
738
|
+ glBegin(GL_QUADS); |
|
739
|
+ glTexCoord3f(vertexTex[faces[1][0]][0], |
|
740
|
+ vertexTex[faces[1][0]][1], |
|
741
|
+ oriTex[2]); |
|
742
|
+ |
|
743
|
+ glVertex3f(vertexDrw[faces[1][0]][0], |
|
744
|
+ vertexDrw[faces[1][0]][1], |
|
745
|
+ vertexDrw[faces[1][0]][2]); |
|
746
|
+ |
|
747
|
+ //second vertex |
|
748
|
+ glTexCoord3f(vertexTex[faces[1][1]][0], |
|
749
|
+ vertexTex[faces[1][1]][1], |
|
750
|
+ oriTex[2]); |
|
751
|
+ |
|
752
|
+ glVertex3f(vertexDrw[faces[1][1]][0], |
|
753
|
+ vertexDrw[faces[1][1]][1], |
|
754
|
+ vertexDrw[faces[1][1]][2]); |
|
755
|
+ |
|
756
|
+ //third vertex |
|
757
|
+ glTexCoord3f(vertexTex[faces[1][2]][0], |
|
758
|
+ vertexTex[faces[1][2]][1], |
|
759
|
+ oriTex[2]); |
|
760
|
+ |
|
761
|
+ glVertex3f(vertexDrw[faces[1][2]][0], |
|
762
|
+ vertexDrw[faces[1][2]][1], |
|
763
|
+ vertexDrw[faces[1][2]][2]); |
|
764
|
+ |
|
765
|
+ //fourth vertex |
|
766
|
+ glTexCoord3f(vertexTex[faces[1][3]][0], |
|
767
|
+ vertexTex[faces[1][3]][1], |
|
768
|
+ oriTex[2]); |
|
769
|
+ |
|
770
|
+ glVertex3f(vertexDrw[faces[1][3]][0], |
|
771
|
+ vertexDrw[faces[1][3]][1], |
|
772
|
+ vertexDrw[faces[1][3]][2]); |
|
773
|
+ glEnd(); |
|
774
|
+ |
|
775
|
+ CHECK_OPENGL_ERROR |
|
776
|
+ glutSwapBuffers(); |
|
777
|
+}*/ |
|
778
|
+ //GLint faces[6][4] = |
|
779
|
+ // {{0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4}, |
|
780
|
+ // {4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3}}; |
|
781
|
+ //GLfloat vertex[8][3] = |
|
782
|
+ // {{0.0, 0.0, 1.0}, {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, |
|
783
|
+ // {0.0, 1.0, 1.0}, {1.0, 0.0, 1.0}, {1.0, 0.0, 0.0}, |
|
784
|
+ // {1.0, 1.0, 0.0}, {1.0, 1.0, 1.0}}; |
|
785
|
+ //GLfloat vertex[8][3] = |
|
786
|
+ // {{-1.0, -1.0, 1.0}, {-1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, |
|
787
|
+ // {-1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, |
|
788
|
+ // {1.0, 1.0, -1.0}, {1.0, 1.0, 1.0}}; |
|
789
|
+/* |
|
790
|
+void |
|
791
|
+DrawPlanes() |
|
792
|
+{ |
|
793
|
+ glPushName(VERTICAL); |
|
794
|
+ glBegin(GL_QUADS); |
|
795
|
+ glTexCoord3f( |
|
796
|
+ vertexTex[0][0], |
|
797
|
+ vertexTex[0][1], |
|
798
|
+ oriTex[2] |
|
799
|
+ ); |
|
800
|
+ glVertex3f( |
|
801
|
+ vertexDrw[0][0], |
|
802
|
+ vertexDrw[0][1], |
|
803
|
+ oriDrw[2] |
|
804
|
+ ); |
|
805
|
+ glTexCoord3f( |
|
806
|
+ vertexTex[1][0], |
|
807
|
+ vertexTex[1][1], |
|
808
|
+ oriTex[2] |
|
809
|
+ ); |
|
810
|
+ glVertex3f( |
|
811
|
+ vertexDrw[1][0], |
|
812
|
+ vertexDrw[1][1], |
|
813
|
+ oriDrw[2] |
|
814
|
+ ); |
|
815
|
+ glTexCoord3f( |
|
816
|
+ vertexTex[2][0], |
|
817
|
+ vertexTex[2][1], |
|
818
|
+ oriTex[2] |
|
819
|
+ ); |
|
820
|
+ glVertex3f( |
|
821
|
+ vertexDrw[2][0], |
|
822
|
+ vertexDrw[2][1], |
|
823
|
+ oriDrw[2] |
|
824
|
+ ); |
|
825
|
+ glTexCoord3f( |
|
826
|
+ vertexTex[3][0], |
|
827
|
+ vertexTex[3][1], |
|
828
|
+ oriTex[2] |
|
829
|
+ ); |
|
830
|
+ glVertex3f( |
|
831
|
+ vertexDrw[3][0], |
|
832
|
+ vertexDrw[3][1], |
|
833
|
+ oriDrw[2] |
|
834
|
+ ); |
|
835
|
+ glEnd(); |
|
836
|
+ glPopName(); |
|
837
|
+ glPushName(HORIZONTAL); |
|
838
|
+ glBegin(GL_QUADS); |
|
839
|
+ glTexCoord3f( |
|
840
|
+ vertexTex[3][0], |
|
841
|
+ oriTex[1], |
|
842
|
+ vertexTex[3][2] |
|
843
|
+ ); |
|
844
|
+ glVertex3f( |
|
845
|
+ vertexDrw[3][0], |
|
846
|
+ oriDrw[1], |
|
847
|
+ vertexDrw[3][2] |
|
848
|
+ ); |
|
849
|
+ glTexCoord3f( |
|
850
|
+ vertexTex[2][0], |
|
851
|
+ oriTex[1], |
|
852
|
+ vertexTex[2][2] |
|
853
|
+ ); |
|
854
|
+ glVertex3f( |
|
855
|
+ vertexDrw[2][0], |
|
856
|
+ oriDrw[1], |
|
857
|
+ vertexDrw[2][2] |
|
858
|
+ ); |
|
859
|
+ glTexCoord3f( |
|
860
|
+ vertexTex[7][0], |
|
861
|
+ oriTex[1], |
|
862
|
+ vertexTex[7][2] |
|
863
|
+ ); |
|
864
|
+ glVertex3f( |
|
865
|
+ vertexDrw[7][0], |
|
866
|
+ oriDrw[1], |
|
867
|
+ vertexDrw[7][2] |
|
868
|
+ ); |
|
869
|
+ glTexCoord3f( |
|
870
|
+ vertexTex[6][0], |
|
871
|
+ oriTex[1], |
|
872
|
+ vertexTex[6][2] |
|
873
|
+ ); |
|
874
|
+ glVertex3f( |
|
875
|
+ vertexDrw[6][0], |
|
876
|
+ oriDrw[1], |
|
877
|
+ vertexDrw[6][2] |
|
878
|
+ ); |
|
879
|
+ glEnd(); |
|
880
|
+ glPopName(); |
|
881
|
+} |
|
882
|
+*/ |
|
883
|
+/* |
|
884
|
+void |
|
885
|
+renderScene() |
|
886
|
+ { |
|
887
|
+ glEnable(GL_TEXTURE_3D); |
|
888
|
+ glBindTexture(GL_TEXTURE_3D, texID); |
|
889
|
+ CHECK_OPENGL_ERROR |
|
890
|
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
891
|
+ glMatrixMode(GL_PROJECTION); |
|
892
|
+ //glMatrixMode(GL_MODELVIEW); |
|
893
|
+ glLoadIdentity(); |
|
894
|
+ glTranslatef(-0.4, -0.4, 0.4); |
|
895
|
+ //gluLookAt(0,0, -viewDistance, 0, 0, -1, 0, 1, 0); |
|
896
|
+ //gluLookAt(0,0, 0, 0, 0, 0, 0, 0, 0); |
|
897
|
+ glRotatef(-90, 1.0, 0.0, 0.0); |
|
898
|
+ glRotatef((float)tick/100.0, 1.0, 1.0, 1.0); |
|
899
|
+ CHECK_OPENGL_ERROR |
|
900
|
+ //glVertex3f(0.0, 0.0, 0.0); |
|
901
|
+ //glVertex3f(0.0, 1.0, 0.0); |
|
902
|
+ //glVertex3f(1.0, 1.0, 0.0); |
|
903
|
+ //glVertex3f(1.0, 0.0, 0.0); |
|
904
|
+ glBegin(GL_QUADS); |
|
905
|
+ for (int i = 0; i < 6; i++) { |
|
906
|
+ //first vertex |
|
907
|
+// std::cout << "setting vertex 1 of face " << i |
|
908
|
+ << " vertex located at " << |
|
909
|
+ "[" << vertex[faces[i][0]][0] << "," |
|
910
|
+ << vertex[faces[i][0]][1] << "," |
|
911
|
+ << vertex[faces[i][0]][2] << "]" << std::endl;// |
|
912
|
+ glTexCoord3f(vertex[faces[i][0]][0], |
|
913
|
+ vertex[faces[i][0]][1], |
|
914
|
+ vertex[faces[i][0]][2]); |
|
915
|
+ |
|
916
|
+ glVertex3f(vertex[faces[i][0]][0], |
|
917
|
+ vertex[faces[i][0]][1], |
|
918
|
+ vertex[faces[i][0]][2]); |
|
919
|
+ |
|
920
|
+ //second vertex |
|
921
|
+ glTexCoord3f(vertex[faces[i][1]][0], |
|
922
|
+ vertex[faces[i][1]][1], |
|
923
|
+ vertex[faces[i][1]][2]); |
|
924
|
+ |
|
925
|
+ glVertex3f(vertex[faces[i][1]][0], |
|
926
|
+ vertex[faces[i][1]][1], |
|
927
|
+ vertex[faces[i][1]][2]); |
|
928
|
+ |
|
929
|
+ //third vertex |
|
930
|
+ glTexCoord3f(vertex[faces[i][2]][0], |
|
931
|
+ vertex[faces[i][2]][1], |
|
932
|
+ vertex[faces[i][2]][2]); |
|
933
|
+ |
|
934
|
+ glVertex3f(vertex[faces[i][2]][0], |
|
935
|
+ vertex[faces[i][2]][1], |
|
936
|
+ vertex[faces[i][2]][2]); |
|
937
|
+ |
|
938
|
+ //fourth vertex |
|
939
|
+ glTexCoord3f(vertex[faces[i][3]][0], |
|
940
|
+ vertex[faces[i][3]][1], |
|
941
|
+ vertex[faces[i][3]][2]); |
|
942
|
+ |
|
943
|
+ glVertex3f(vertex[faces[i][3]][0], |
|
944
|
+ vertex[faces[i][3]][1], |
|
945
|
+ vertex[faces[i][3]][2]); |
|
946
|
+ } |
|
947
|
+ glEnd(); |
|
948
|
+ |
|
949
|
+ CHECK_OPENGL_ERROR |
|
950
|
+ glutSwapBuffers(); |
|
951
|
+ //glutPostRedisplay(); |
|
952
|
+ } |
|
953
|
+*/ |
...
|
...
|
|