2 #if defined(_WIN32) || defined(__WIN32__)
11 #include "trackball.h"
13 #include "runGlutMainLoop.h"
14 #include "../core/board.h"
15 #include "../threads/thread_controller.h"
18 # define byte unsigned char
22 #define glut_WINDOW_SIZE 500
23 #define glut_WINDOW_POS_X 500
24 #define glut_WINDOW_POS_Y 200
25 #define glut_WINDOW_TITLE "OpenGL GLUT - 3D miny"
26 #define glut_CUBE_SIZE 0.5f
27 #define glut_ANGLE 1.0f
28 #define TEXTURE_FILE "textury/all.sgi"
29 #define TEXTURE_OFFSET_UNIT_X 0.125f
30 #define TEXTURE_OFFSET_UNIT_Y 0.25f
31 #define ALPHA_CONST 0.8f
35 //void runGlutMainLoop(int x,int y,int z);
37 //void * runGlutMainLoop( void * args);
41 void reshape(int width
,int height
);
42 void keyboard_input(int key
,int x
,int y
);
44 void drawMines1(void);
45 void drawMine(int x
,int y
,int z
);
46 void initLights(void);
47 void mouse_input(int button
,int state
,int x
,int y
);
48 void motion(int x
,int y
);
49 void displaySub(void);
50 void makeTextures(void);
51 void motion_pas(int x
,int y
);
52 void forceRedraw(void);
53 void app_exiting(void);
69 int cropX_min
= 0,cropX_max
;
70 int cropY_min
= 0,cropY_max
;
71 int cropZ_min
= 0,cropZ_max
;
72 int last_x
,last_y
,last_z
;
74 float mouse_old_x
= 0, mouse_old_y
= 0;
77 Thread_controller
* thc
;
79 float curQuat
[4], incQuat
[4];
81 const char * strX
= "X: min max";
82 const char * strY
= "Y: min max";
83 const char * strZ
= "Z: min max";
89 GLfloat ambient
[] = { 1.0f
, 1.0f
, 1.0f
, 1.0f
};
91 GLfloat diffuse
[][4] =
93 { 0.9f
, 0.9f
, 0.9f
, 1.0f
}, // 0 light grey
94 { 0.0f
, 0.0f
, 1.0f
, 1.0f
}, // 1 blue
95 { 0.0f
, 1.0f
, 0.0f
, 1.0f
}, // 2 green
96 { 1.0f
, 0.0f
, 0.0f
, 1.0f
}, // 3 red
97 { 0.0f
, 0.0f
, 0.5f
, 1.0f
}, // 4 dark blue
98 { 0.7f
, 0.0f
, 0.7f
, 1.0f
}, // 5 purple
99 { 0.0f
, 0.5f
, 0.0f
, 1.0f
}, // 6 dark green
100 { 0.5f
, 0.0f
, 0.0f
, 1.0f
}, // 7 dark red
101 { 0.32f
, 0.32f
, 0.32f
, 1.0f
}, // 8 grey
102 { 0.0f
, 0.0f
, 0.0f
, 0.0f
} // 9 black
105 GLfloat sunDirection
[] = { 0.0f
, -1.0f
, 0.0f
};
106 GLfloat sunPosition
[3];
108 //void runGlutMainLoop(int x,int y,int z )
110 void forceRedraw(void)
118 void app_exiting(void)
123 void * runGlutMainLoop( void * args
)
125 char *argval
= new char [1];
126 char **argv
= new char* [1];
131 thc
= (Thread_controller
*)args
;
133 glutInit(&argc
,argv
);
134 glutInitDisplayMode(GLUT_DOUBLE
|GLUT_RGBA
| GLUT_DEPTH
);
135 glutInitWindowSize(glut_WINDOW_SIZE
,glut_WINDOW_SIZE
);
136 glutInitWindowPosition(glut_WINDOW_POS_X
,glut_WINDOW_POS_Y
);
137 win
= glutCreateWindow(glut_WINDOW_TITLE
);
138 w_height
= w_width
= glut_WINDOW_SIZE
;
140 drawMines
= drawMines1
;
144 glutDisplayFunc(display
);
145 glutReshapeFunc(reshape
);
148 glutMotionFunc(motion
);
149 glutSpecialFunc(keyboard_input
);
151 trackball(curQuat
,0.0,0.0,0.0,0.0);
153 subWin
= glutCreateSubWindow(win
, 0, 0, 340, 60);
154 glutDisplayFunc(displaySub
);
155 glutMouseFunc(mouse_input
);
156 glutPassiveMotionFunc(motion_pas
);
158 thc
->ptf
= &forceRedraw
;
159 thc
->ptf_end
= &app_exiting
;
169 glPolygonMode( GL_FRONT
, GL_FILL
);
170 glPolygonMode( GL_BACK
, GL_LINE
);
171 glCullFace( GL_BACK
);
173 minesX
= &thc
->dim
[0];
174 minesY
= &thc
->dim
[1];
175 minesZ
= &thc
->dim
[2];
177 sunPosition
[0] = 0.0f
;
178 sunPosition
[1] = 0.0f
;
179 sunPosition
[2] = (*minesY
) * 8 * glut_CUBE_SIZE
;
181 cropX_max
= last_x
= *minesX
;
182 cropY_max
= last_y
= *minesY
;
183 cropZ_max
= last_z
= *minesZ
;
185 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
186 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
188 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_MODULATE
);
189 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_FASTEST
);
191 if(!LoadRGBMipmapsUserAlpha(TEXTURE_FILE
, GL_RGBA
,ALPHA_CONST
)) {
192 printf("Error: couldn't load texture image\n");
195 glEnable(GL_TEXTURE_2D
);
196 glEnable(GL_LIGHTING
);
197 glEnable(GL_DEPTH_TEST
);
200 void initLights(void)
203 glLightf(GL_LIGHT0
,GL_SPOT_CUTOFF
,180);
205 glLightfv(GL_LIGHT0
,GL_POSITION
, sunPosition
);
206 glLightfv(GL_LIGHT0
,GL_SPOT_DIRECTION
,sunDirection
);
210 void displaySub(void)
212 glClearColor(0.2, 0.2, 0.2, 1.0);
213 glClear(GL_COLOR_BUFFER_BIT
);
215 glRasterPos2f(-0.95,0.5);
217 char * pom
= (char*)malloc(25*sizeof(char));
218 if (cropX_min
<= 9) sprintf(pom
," %i",cropX_min
);
219 else sprintf(pom
,"%i",cropX_min
);
222 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strX
[i
]);
224 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
226 if (cropX_max
<= 9) sprintf(pom
," %i",cropX_max
);
227 else sprintf(pom
,"%i",cropX_max
);
231 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strX
[i
]);
233 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
235 glRasterPos2f(-0.95,-0.1);
236 if (cropY_min
<= 9) sprintf(pom
," %i",cropY_min
);
237 else sprintf(pom
,"%i",cropY_min
);
240 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strY
[i
]);
242 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
244 if (cropY_max
<= 9) sprintf(pom
," %i",cropY_max
);
245 else sprintf(pom
,"%i",cropY_max
);
248 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strY
[i
]);
250 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
252 glRasterPos2f(-0.95,-0.7);
253 if (cropZ_min
<= 9) sprintf(pom
," %i",cropZ_min
);
254 else sprintf(pom
,"%i",cropZ_min
);
257 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strZ
[i
]);
259 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
261 if (cropZ_max
<= 9) sprintf(pom
," %i",cropZ_max
);
262 else sprintf(pom
,"%i",cropZ_max
);
265 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strZ
[i
]);
267 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
272 if (selectXYZ
== 8) glColor3f(1, 0, 0);
273 else glColor3f(1, 1, 0);
274 glRasterPos2f(-0.45,0.5);
275 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
277 if (selectXYZ
== 9) glColor3f(1, 0, 0);
278 else glColor3f(1, 1, 0);
279 glRasterPos2f(-0.38,0.5);
280 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
282 if (selectXYZ
== 10) glColor3f(1, 0, 0);
283 else glColor3f(1, 1, 0);
284 glRasterPos2f(0.03,0.5);
285 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
287 if (selectXYZ
== 11) glColor3f(1, 0, 0);
288 else glColor3f(1, 1, 0);
289 glRasterPos2f(0.10,0.5);
290 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
293 if (selectXYZ
== 4) glColor3f(1, 0, 0);
294 else glColor3f(1, 1, 0);
295 glRasterPos2f(-0.45,-0.1);
296 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
298 if (selectXYZ
== 5) glColor3f(1, 0, 0);
299 else glColor3f(1, 1, 0);
300 glRasterPos2f(-0.38,-0.1);
301 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
303 if (selectXYZ
== 6) glColor3f(1, 0, 0);
304 else glColor3f(1, 1, 0);
305 glRasterPos2f(0.03,-0.1);
306 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
308 if (selectXYZ
== 7) glColor3f(1, 0, 0);
309 else glColor3f(1, 1, 0);
310 glRasterPos2f(0.10,-0.1);
311 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
314 if (selectXYZ
== 0) glColor3f(1, 0, 0);
315 else glColor3f(1, 1, 0);
316 glRasterPos2f(-0.45,-0.7);
317 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
319 if (selectXYZ
== 1) glColor3f(1, 0, 0);
320 else glColor3f(1, 1, 0);
321 glRasterPos2f(-0.38,-0.7);
322 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
324 if (selectXYZ
== 2) glColor3f(1, 0, 0);
325 else glColor3f(1, 1, 0);
326 glRasterPos2f(0.03,-0.7);
327 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
329 if (selectXYZ
== 3) glColor3f(1, 0, 0);
330 else glColor3f(1, 1, 0);
331 glRasterPos2f(0.10,-0.7);
332 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
334 if (selectXYZ
== 12) glColor3f(1, 0, 0);
335 else glColor3f(1, 1, 0);
336 glRasterPos2f(0.2,0.5);
337 sprintf(pom
,"SWITCH MODE %i",mode
);
340 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
342 if (selectXYZ
== 13) glColor3f(1, 0, 0);
343 else glColor3f(1, 1, 0);
344 glRasterPos2f(0.2,-0.1);
345 const char * upn_str
;
346 if (update_nums
) upn_str
= "ON";
347 else upn_str
= "OFF";
349 sprintf(pom
,"UPDATE NUMS %s",upn_str
);
352 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
365 pthread_exit((void *)0);
367 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
375 pthread_exit((void *)0);
378 if ( last_x
!= *minesX
|| last_y
!= *minesY
|| last_z
!= *minesZ
)
380 cropX_max
= last_x
= *minesX
;
381 cropY_max
= last_y
= *minesY
;
382 cropZ_max
= last_z
= *minesZ
;
383 glutPostWindowRedisplay(win
);
386 glMatrixMode(GL_MODELVIEW
);
389 if (*minesY
> m
) m
= *minesY
;
390 if (*minesZ
> m
) m
= *minesZ
;
394 gluLookAt( 0.0, 0.0 , glut_CUBE_SIZE
* 6 * m
* zoom
,
401 if (thc
->b
!= 0) drawMines();
405 glMaterialfv(GL_FRONT
,GL_AMBIENT
,ambient
);
406 glMaterialfv(GL_FRONT
,GL_DIFFUSE
,diffuse
[0]);
419 void reshape(int width
,int height
)
423 pthread_exit((void *)0);
428 glViewport(0,0,width
,height
);
430 glMatrixMode(GL_PROJECTION
);
432 gluPerspective(60.0,(GLdouble
)width
/height
,0.1,200.0);
439 pthread_exit((void *)0);
443 glMatrixMode(GL_MODELVIEW
);
446 if (*minesY
> m
) m
= *minesY
;
447 if (*minesZ
> m
) m
= *minesZ
;
451 gluLookAt( 0.0, 0.0 , glut_CUBE_SIZE
* 6 * m
* zoom
,
463 void keyboard_input(int key
,int x
,int y
)
465 if (key
== GLUT_KEY_LEFT
) zoom
+= 0.025f
;
466 if (key
== GLUT_KEY_RIGHT
) zoom
-= 0.025f
;
470 void mouse_input(int button
,int state
,int x
,int y
)
473 if( button
== GLUT_LEFT_BUTTON
)
475 if (state
== GLUT_DOWN
)
483 if (update_nums
) update_nums
= 0;
484 else update_nums
= 1;
487 if (cropX_min
< *minesX
-1) cropX_min
+= 1;
490 if (cropX_min
> 0) cropX_min
-= 1;
493 if (cropX_max
< *minesX
) cropX_max
+= 1;
496 if (cropX_max
> 0) cropX_max
-= 1;
499 if (cropY_min
< *minesY
-1) cropY_min
+= 1;
502 if (cropY_min
> 0) cropY_min
-= 1;
505 if (cropY_max
< *minesY
) cropY_max
+= 1;
508 if (cropY_max
> 0) cropY_max
-= 1;
511 if (cropZ_min
< *minesZ
-1) cropZ_min
+= 1;
514 if (cropZ_min
> 0) cropZ_min
-= 1;
517 if (cropZ_max
< *minesZ
) cropZ_max
+= 1;
520 if (cropZ_max
> 0) cropZ_max
-= 1;
527 glutPostWindowRedisplay(win
);
531 void motion(int x
, int y
)
536 if (mouse_old_x
- x
> w_width
/ 100 ) x
= (int)mouse_old_x
- w_width
/ 100;
537 if (mouse_old_x
- x
< -w_width
/ 100) x
= (int)mouse_old_x
+ w_width
/ 100;
539 if (mouse_old_y
- y
> w_height
/ 100) y
= (int)mouse_old_y
- w_height
/ 100;
540 if (mouse_old_y
- y
< -w_height
/ 100) y
= (int)mouse_old_y
+ w_height
/ 100;
542 trackball(incQuat
, (2.0 * mouse_old_x
- w_width
) / w_width
,
543 (w_height
- 2.0 * mouse_old_y
) / w_height
,
544 (2.0 * x
- w_width
) / w_width
,
545 (w_height
- 2.0 * y
) / w_height
);
548 add_quats(incQuat
,curQuat
,curQuat
);
553 //glutPostRedisplay();
558 void drawMines1(void)
567 build_rotmatrix(m
,curQuat
);
568 glMultMatrixf(&m
[0][0]);
570 glDisable(GL_LIGHTING
);
571 glDisable(GL_TEXTURE_2D
);
574 glColor3f(1.0, 0.0, 0.0);
575 glVertex3f(0.0,0.0,0.0);
576 glVertex3f(glut_CUBE_SIZE
* 4 * *minesX
,0.0,0.0);
578 glVertex3f(glut_CUBE_SIZE
* 4 * *minesX
,0.0,0.0);
579 glVertex3f(glut_CUBE_SIZE
* 4 * *minesX
- 2,2.0,0.0);
580 glVertex3f(glut_CUBE_SIZE
* 4 * *minesX
,0.0,0.0);
581 glVertex3f(glut_CUBE_SIZE
* 4 * *minesX
- 2,-2.0,0.0);
583 glColor3f(0.0, 1.0, 0.0);
584 glVertex3f(0.0,0.0,0.0);
585 glVertex3f(0.0,glut_CUBE_SIZE
* 4 * *minesY
,0.0);
587 glVertex3f(0.0,glut_CUBE_SIZE
* 4 * *minesY
,0.0);
588 glVertex3f(2.0,glut_CUBE_SIZE
* 4 * *minesY
-2,0.0);
589 glVertex3f(0.0,glut_CUBE_SIZE
* 4 * *minesY
,0.0);
590 glVertex3f(-2.0,glut_CUBE_SIZE
* 4 * *minesY
-2,0.0);
592 glColor3f(0.0, 0.0, 1.0);
593 glVertex3f(0.0,0.0,0.0);
594 glVertex3f(0.0,0.0,glut_CUBE_SIZE
* 4 * *minesZ
);
596 glVertex3f(0.0,0.0,glut_CUBE_SIZE
* 4 * *minesZ
);
597 glVertex3f(2.0,0.0,glut_CUBE_SIZE
* 4 * *minesZ
-2);
598 glVertex3f(0.0,0.0,glut_CUBE_SIZE
* 4 * *minesZ
);
599 glVertex3f(-2.0,0.0,glut_CUBE_SIZE
* 4 * *minesZ
-2);
604 glEnable(GL_LIGHTING
);
605 glEnable(GL_TEXTURE_2D
);
608 glDepthMask (GL_FALSE
);
609 glBlendFunc (GL_SRC_ALPHA
,GL_ONE_MINUS_SRC_COLOR
);
611 //if (mode > 2) glTranslated(-4 * glut_CUBE_SIZE * thc->selected[1], 4 * glut_CUBE_SIZE * thc->selected[2],4 * glut_CUBE_SIZE * thc->selected[0] );
612 //else glTranslated( -2 * (*minesX-1) * glut_CUBE_SIZE,2 * (*minesY-1) * glut_CUBE_SIZE,2 * (*minesZ-1) * glut_CUBE_SIZE );
614 if (mode
> 2) glTranslated(-4 * glut_CUBE_SIZE
* thc
->selected
[2], 4 * glut_CUBE_SIZE
* thc
->selected
[1],4 * glut_CUBE_SIZE
* thc
->selected
[0] );
615 else glTranslated( -2 * (*minesX
-1) * glut_CUBE_SIZE
,2 * (*minesY
-1) * glut_CUBE_SIZE
,2 * (*minesZ
-1) * glut_CUBE_SIZE
);
617 glPushAttrib(GL_ALL_ATTRIB_BITS
);
619 for (i
= 0;i
< *minesX
;i
++ )
621 if ((i
< thc
->selected
[1]-2 || i
> thc
->selected
[1]+2) && mode
> 2 ) continue;
623 if (i
< cropX_min
|| i
> cropX_max
) continue;
625 for ( j
= 0;j
< *minesZ
; j
++ )
627 if ((j
< thc
->selected
[0]-2 || j
> thc
->selected
[0]+2) && mode
> 2 ) continue;
628 if (j
< cropZ_min
|| j
> cropZ_max
) continue;
629 for ( k
= 0;k
< *minesY
; k
++ )
631 if ((k
< thc
->selected
[2]-2 || k
> thc
->selected
[2]+2) && mode
> 2 ) continue;
632 if (k
< cropY_min
|| k
> cropY_max
) continue;
635 //glTranslated( 4 * i * glut_CUBE_SIZE, 4 * k * glut_CUBE_SIZE, -4 * j * glut_CUBE_SIZE );
637 glTranslated( 4 * k
* glut_CUBE_SIZE
, -4 * i
* glut_CUBE_SIZE
, -4 * j
* glut_CUBE_SIZE
);
639 glMaterialfv(GL_FRONT
, GL_AMBIENT
, ambient
);
640 glMaterialfv(GL_FRONT
, GL_DIFFUSE
, diffuse
[0]);
642 if ((thc
->selected
[0] == j
&& thc
->selected
[1] == i
&& thc
->selected
[2] == k
) || thc
->selected
[0] == -1 || mode
% 2 == 1)
644 glDepthMask (GL_TRUE
);
645 glDisable (GL_BLEND
);
647 if ((thc
->selected
[3] == j
&& thc
->selected
[4] == i
&& thc
->selected
[5] == k
) )
648 glMaterialfv(GL_FRONT
, GL_DIFFUSE
, diffuse
[8]);
651 glDepthMask (GL_FALSE
);
652 glBlendFunc (GL_SRC_ALPHA
,GL_ONE_MINUS_SRC_COLOR
);
667 glDepthMask (GL_TRUE
);
668 glDisable (GL_BLEND
);
676 void drawMine(int x
,int y
,int z
)
680 //glEnable(GL_TEXTURE_2D);
681 //glDisable( GL_LIGHTING );
683 const Field
& f
= thc
->b
->getField(x
,y
,z
);
686 int total_offsetX
= 0;
687 int total_offsetY
= 3;
694 if ( !f
.isCovered() )
703 val
= f
.getRemainingNeighboursCnt() - 1;
704 if (val
== -1 ) return;
705 if (val
< -1 ) val
= 28;
709 val
= f
.getNeighboursCnt() - 1;
710 if (val
== -1 ) return;
716 total_offsetX
= val
% 8;
717 total_offsetY
-= (val
/ 8) % 4;
724 glNormal3f(0.0f
, 0.0f
, 1.0f
);
726 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
727 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
729 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
730 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
732 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
733 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
735 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
736 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
739 glNormal3f(0.0f
, 0.0f
, -1.0f
);
741 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
742 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
744 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
745 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
747 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
748 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
750 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
751 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
754 glNormal3f(-1.0f
, 0.0f
, 0.0f
);
756 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
757 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
759 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
760 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
762 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
763 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
765 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
766 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
769 glNormal3f(1.0f
, 0.0f
, 0.0f
);
771 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
772 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
774 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
775 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
777 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
778 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
780 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
781 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
784 glNormal3f(0.0f
, -1.0f
, 0.0f
);
786 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
787 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
789 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
790 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
792 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
793 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
795 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
796 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
799 glNormal3f(0.0f
, 1.0f
, 0.0f
);
801 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
802 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
804 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
805 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
807 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
808 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
810 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
811 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
818 //glDisable(GL_TEXTURE_2D);
819 //glEnable( GL_LIGHTING );
824 void motion_pas(int x
,int y
)
827 if (y
< 54 && y
> 37)
858 if (y
< 37 && y
> 19)
860 if (x
< 336 && x
> 200)
897 if (x
< 320 && x
> 200)