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);
39 void init(int x
,int y
,int z
);
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);
66 int cropX_min
= 0,cropX_max
;
67 int cropY_min
= 0,cropY_max
;
68 int cropZ_min
= 0,cropZ_max
;
69 int last_x
,last_y
,last_z
;
71 float mouse_old_x
= 0, mouse_old_y
= 0;
74 Thread_controller
* thc
;
76 float curQuat
[4], incQuat
[4];
78 const char * strX
= "X: min max";
79 const char * strY
= "Y: min max";
80 const char * strZ
= "Z: min max";
84 GLfloat ambient
[] = { 1.0f
, 1.0f
, 1.0f
, 1.0f
};
86 GLfloat diffuse
[][4] =
88 { 0.9f
, 0.9f
, 0.9f
, 1.0f
}, // 0 light grey
89 { 0.0f
, 0.0f
, 1.0f
, 1.0f
}, // 1 blue
90 { 0.0f
, 1.0f
, 0.0f
, 1.0f
}, // 2 green
91 { 1.0f
, 0.0f
, 0.0f
, 1.0f
}, // 3 red
92 { 0.0f
, 0.0f
, 0.5f
, 1.0f
}, // 4 dark blue
93 { 0.7f
, 0.0f
, 0.7f
, 1.0f
}, // 5 purple
94 { 0.0f
, 0.5f
, 0.0f
, 1.0f
}, // 6 dark green
95 { 0.5f
, 0.0f
, 0.0f
, 1.0f
}, // 7 dark red
96 { 0.32f
, 0.32f
, 0.32f
, 1.0f
}, // 8 grey
97 { 0.0f
, 0.0f
, 0.0f
, 0.0f
} // 9 black
100 GLfloat sunDirection
[] = { 0.0f
, -1.0f
, 0.0f
};
101 GLfloat sunPosition
[3];
103 //void runGlutMainLoop(int x,int y,int z )
105 void forceRedraw(void)
110 void * runGlutMainLoop( void * args
)
112 char *argval
= new char [1];
113 char **argv
= new char* [1];
118 thc
= (Thread_controller
*)args
;
120 glutInit(&argc
,argv
);
121 glutInitDisplayMode(GLUT_DOUBLE
|GLUT_RGBA
| GLUT_DEPTH
);
122 glutInitWindowSize(glut_WINDOW_SIZE
,glut_WINDOW_SIZE
);
123 glutInitWindowPosition(glut_WINDOW_POS_X
,glut_WINDOW_POS_Y
);
124 win
= glutCreateWindow(glut_WINDOW_TITLE
);
125 w_height
= w_width
= glut_WINDOW_SIZE
;
127 drawMines
= drawMines1
;
129 init(thc
->dim
[0],thc
->dim
[1],thc
->dim
[2]);
131 glutDisplayFunc(display
);
132 glutReshapeFunc(reshape
);
134 glutMotionFunc(motion
);
135 glutSpecialFunc(keyboard_input
);
137 trackball(curQuat
,0.0,0.0,0.0,0.0);
139 subWin
= glutCreateSubWindow(win
, 0, 0, 340, 60);
140 glutDisplayFunc(displaySub
);
141 glutMouseFunc(mouse_input
);
142 glutPassiveMotionFunc(motion_pas
);
144 thc
->ptf
= &forceRedraw
;
150 void init(int x
,int y
,int z
)
154 glPolygonMode( GL_FRONT
, GL_FILL
);
155 glPolygonMode( GL_BACK
, GL_LINE
);
156 glCullFace( GL_BACK
);
158 minesX
= &thc
->dim
[0];
159 minesY
= &thc
->dim
[1];
160 minesZ
= &thc
->dim
[2];
162 sunPosition
[0] = 0.0f
;
163 sunPosition
[1] = 0.0f
;
164 sunPosition
[2] = (*minesY
) * 8 * glut_CUBE_SIZE
;
166 cropX_max
= last_x
= *minesX
;
167 cropY_max
= last_y
= *minesY
;
168 cropZ_max
= last_z
= *minesZ
;
170 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
171 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
173 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_MODULATE
);
174 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_FASTEST
);
176 if(!LoadRGBMipmapsUserAlpha(TEXTURE_FILE
, GL_RGBA
,ALPHA_CONST
)) {
177 printf("Error: couldn't load texture image\n");
180 glEnable(GL_TEXTURE_2D
);
181 glEnable(GL_LIGHTING
);
182 glEnable(GL_DEPTH_TEST
);
185 void initLights(void)
188 glLightf(GL_LIGHT0
,GL_SPOT_CUTOFF
,180);
190 glLightfv(GL_LIGHT0
,GL_POSITION
, sunPosition
);
191 glLightfv(GL_LIGHT0
,GL_SPOT_DIRECTION
,sunDirection
);
195 void displaySub(void)
197 glClearColor(0.2, 0.2, 0.2, 1.0);
198 glClear(GL_COLOR_BUFFER_BIT
);
200 glRasterPos2f(-0.95,0.5);
202 char * pom
= (char*)malloc(25*sizeof(char));
203 if (cropX_min
<= 9) sprintf(pom
," %i",cropX_min
);
204 else sprintf(pom
,"%i",cropX_min
);
207 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strX
[i
]);
209 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
211 if (cropX_max
<= 9) sprintf(pom
," %i",cropX_max
);
212 else sprintf(pom
,"%i",cropX_max
);
216 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strX
[i
]);
218 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
220 glRasterPos2f(-0.95,-0.1);
221 if (cropY_min
<= 9) sprintf(pom
," %i",cropY_min
);
222 else sprintf(pom
,"%i",cropY_min
);
225 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strY
[i
]);
227 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
229 if (cropY_max
<= 9) sprintf(pom
," %i",cropY_max
);
230 else sprintf(pom
,"%i",cropY_max
);
233 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strY
[i
]);
235 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
237 glRasterPos2f(-0.95,-0.7);
238 if (cropZ_min
<= 9) sprintf(pom
," %i",cropZ_min
);
239 else sprintf(pom
,"%i",cropZ_min
);
242 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strZ
[i
]);
244 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
246 if (cropZ_max
<= 9) sprintf(pom
," %i",cropZ_max
);
247 else sprintf(pom
,"%i",cropZ_max
);
250 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
, strZ
[i
]);
252 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
257 if (selectXYZ
== 8) glColor3f(1, 0, 0);
258 else glColor3f(1, 1, 0);
259 glRasterPos2f(-0.45,0.5);
260 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
262 if (selectXYZ
== 9) glColor3f(1, 0, 0);
263 else glColor3f(1, 1, 0);
264 glRasterPos2f(-0.38,0.5);
265 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
267 if (selectXYZ
== 10) glColor3f(1, 0, 0);
268 else glColor3f(1, 1, 0);
269 glRasterPos2f(0.03,0.5);
270 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
272 if (selectXYZ
== 11) glColor3f(1, 0, 0);
273 else glColor3f(1, 1, 0);
274 glRasterPos2f(0.10,0.5);
275 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
278 if (selectXYZ
== 4) glColor3f(1, 0, 0);
279 else glColor3f(1, 1, 0);
280 glRasterPos2f(-0.45,-0.1);
281 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
283 if (selectXYZ
== 5) glColor3f(1, 0, 0);
284 else glColor3f(1, 1, 0);
285 glRasterPos2f(-0.38,-0.1);
286 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
288 if (selectXYZ
== 6) glColor3f(1, 0, 0);
289 else glColor3f(1, 1, 0);
290 glRasterPos2f(0.03,-0.1);
291 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
293 if (selectXYZ
== 7) glColor3f(1, 0, 0);
294 else glColor3f(1, 1, 0);
295 glRasterPos2f(0.10,-0.1);
296 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
299 if (selectXYZ
== 0) glColor3f(1, 0, 0);
300 else glColor3f(1, 1, 0);
301 glRasterPos2f(-0.45,-0.7);
302 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
304 if (selectXYZ
== 1) glColor3f(1, 0, 0);
305 else glColor3f(1, 1, 0);
306 glRasterPos2f(-0.38,-0.7);
307 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
309 if (selectXYZ
== 2) glColor3f(1, 0, 0);
310 else glColor3f(1, 1, 0);
311 glRasterPos2f(0.03,-0.7);
312 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'+');
314 if (selectXYZ
== 3) glColor3f(1, 0, 0);
315 else glColor3f(1, 1, 0);
316 glRasterPos2f(0.10,-0.7);
317 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,'-');
319 if (selectXYZ
== 12) glColor3f(1, 0, 0);
320 else glColor3f(1, 1, 0);
321 glRasterPos2f(0.25,0.5);
322 sprintf(pom
,"SWITCH MODE %i",mode
);
325 glutBitmapCharacter(GLUT_BITMAP_9_BY_15
,pom
[i
]);
337 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
341 if ( last_x
!= *minesX
|| last_y
!= *minesY
|| last_z
!= *minesZ
)
343 cropX_max
= last_x
= *minesX
;
344 cropY_max
= last_y
= *minesY
;
345 cropZ_max
= last_z
= *minesZ
;
346 glutPostWindowRedisplay(win
);
349 glMatrixMode(GL_MODELVIEW
);
352 if (*minesY
> m
) m
= *minesY
;
353 if (*minesZ
> m
) m
= *minesZ
;
357 gluLookAt( 0.0, 0.0 , glut_CUBE_SIZE
* 6 * m
* zoom
,
364 if (thc
->b
!= 0) drawMines();
368 glMaterialfv(GL_FRONT
,GL_AMBIENT
,ambient
);
369 glMaterialfv(GL_FRONT
,GL_DIFFUSE
,diffuse
[0]);
380 void reshape(int width
,int height
)
386 glViewport(0,0,width
,height
);
388 glMatrixMode(GL_PROJECTION
);
390 gluPerspective(60.0,(GLdouble
)width
/height
,0.1,200.0);
394 glMatrixMode(GL_MODELVIEW
);
397 if (*minesY
> m
) m
= *minesY
;
398 if (*minesZ
> m
) m
= *minesZ
;
402 gluLookAt( 0.0, 0.0 , glut_CUBE_SIZE
* 6 * m
* zoom
,
414 void keyboard_input(int key
,int x
,int y
)
416 if (key
== GLUT_KEY_LEFT
) zoom
+= 0.025f
;
417 if (key
== GLUT_KEY_RIGHT
) zoom
-= 0.025f
;
421 void mouse_input(int button
,int state
,int x
,int y
)
424 if( button
== GLUT_LEFT_BUTTON
)
426 if (state
== GLUT_DOWN
)
434 if (cropX_min
< *minesX
-1) cropX_min
+= 1;
437 if (cropX_min
> 0) cropX_min
-= 1;
440 if (cropX_max
< *minesX
) cropX_max
+= 1;
443 if (cropX_max
> 0) cropX_max
-= 1;
446 if (cropY_min
< *minesY
-1) cropY_min
+= 1;
449 if (cropY_min
> 0) cropY_min
-= 1;
452 if (cropY_max
< *minesY
) cropY_max
+= 1;
455 if (cropY_max
> 0) cropY_max
-= 1;
458 if (cropZ_min
< *minesZ
-1) cropZ_min
+= 1;
461 if (cropZ_min
> 0) cropZ_min
-= 1;
464 if (cropZ_max
< *minesZ
) cropZ_max
+= 1;
467 if (cropZ_max
> 0) cropZ_max
-= 1;
474 glutPostWindowRedisplay(win
);
478 void motion(int x
, int y
)
483 if (mouse_old_x
- x
> w_width
/ 100 ) x
= (int)mouse_old_x
- w_width
/ 100;
484 if (mouse_old_x
- x
< -w_width
/ 100) x
= (int)mouse_old_x
+ w_width
/ 100;
486 if (mouse_old_y
- y
> w_height
/ 100) y
= (int)mouse_old_y
- w_height
/ 100;
487 if (mouse_old_y
- y
< -w_height
/ 100) y
= (int)mouse_old_y
+ w_height
/ 100;
489 trackball(incQuat
, (2.0 * mouse_old_x
- w_width
) / w_width
,
490 (w_height
- 2.0 * mouse_old_y
) / w_height
,
491 (2.0 * x
- w_width
) / w_width
,
492 (w_height
- 2.0 * y
) / w_height
);
495 add_quats(incQuat
,curQuat
,curQuat
);
500 //glutPostRedisplay();
505 void drawMines1(void)
514 build_rotmatrix(m
,curQuat
);
515 glMultMatrixf(&m
[0][0]);
517 glDisable(GL_LIGHTING
);
518 glDisable(GL_TEXTURE_2D
);
521 glColor3f(1.0, 0.0, 0.0);
522 glVertex3f(0.0,0.0,0.0);
523 glVertex3f(glut_CUBE_SIZE
* 4 * *minesX
,0.0,0.0);
525 glVertex3f(glut_CUBE_SIZE
* 4 * *minesX
,0.0,0.0);
526 glVertex3f(glut_CUBE_SIZE
* 4 * *minesX
- 2,2.0,0.0);
527 glVertex3f(glut_CUBE_SIZE
* 4 * *minesX
,0.0,0.0);
528 glVertex3f(glut_CUBE_SIZE
* 4 * *minesX
- 2,-2.0,0.0);
530 glColor3f(0.0, 1.0, 0.0);
531 glVertex3f(0.0,0.0,0.0);
532 glVertex3f(0.0,glut_CUBE_SIZE
* 4 * *minesY
,0.0);
534 glVertex3f(0.0,glut_CUBE_SIZE
* 4 * *minesY
,0.0);
535 glVertex3f(2.0,glut_CUBE_SIZE
* 4 * *minesY
-2,0.0);
536 glVertex3f(0.0,glut_CUBE_SIZE
* 4 * *minesY
,0.0);
537 glVertex3f(-2.0,glut_CUBE_SIZE
* 4 * *minesY
-2,0.0);
539 glColor3f(0.0, 0.0, 1.0);
540 glVertex3f(0.0,0.0,0.0);
541 glVertex3f(0.0,0.0,glut_CUBE_SIZE
* 4 * *minesZ
);
543 glVertex3f(0.0,0.0,glut_CUBE_SIZE
* 4 * *minesZ
);
544 glVertex3f(2.0,0.0,glut_CUBE_SIZE
* 4 * *minesZ
-2);
545 glVertex3f(0.0,0.0,glut_CUBE_SIZE
* 4 * *minesZ
);
546 glVertex3f(-2.0,0.0,glut_CUBE_SIZE
* 4 * *minesZ
-2);
551 glEnable(GL_LIGHTING
);
552 glEnable(GL_TEXTURE_2D
);
555 glDepthMask (GL_FALSE
);
556 glBlendFunc (GL_SRC_ALPHA
,GL_ONE_MINUS_SRC_COLOR
);
558 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] );
559 else glTranslated( -2 * (*minesX
-1) * glut_CUBE_SIZE
,-2 * (*minesY
-1) * glut_CUBE_SIZE
,-2 * (*minesZ
-1) * glut_CUBE_SIZE
);
561 glPushAttrib(GL_ALL_ATTRIB_BITS
);
563 for (i
= 0;i
< *minesX
;i
++ )
565 if ((i
< thc
->selected
[1]-2 || i
> thc
->selected
[1]+2) && mode
> 2 ) continue;
567 if (i
< cropX_min
|| i
> cropX_max
) continue;
569 for ( j
= 0;j
< *minesZ
; j
++ )
571 if ((j
< thc
->selected
[0]-2 || j
> thc
->selected
[0]+2) && mode
> 2 ) continue;
572 if (j
< cropZ_min
|| j
> cropZ_max
) continue;
573 for ( k
= 0;k
< *minesY
; k
++ )
575 if ((k
< thc
->selected
[2]-2 || k
> thc
->selected
[2]+2) && mode
> 2 ) continue;
576 if (k
< cropY_min
|| k
> cropY_max
) continue;
579 glTranslated( 4 * i
* glut_CUBE_SIZE
, 4 * k
* glut_CUBE_SIZE
, 4 * j
* glut_CUBE_SIZE
);
580 glMaterialfv(GL_FRONT
, GL_AMBIENT
, ambient
);
581 glMaterialfv(GL_FRONT
, GL_DIFFUSE
, diffuse
[0]);
583 if ((thc
->selected
[0] == j
&& thc
->selected
[1] == i
&& thc
->selected
[2] == k
) || thc
->selected
[0] == -1 || mode
% 2 == 1)
585 glDepthMask (GL_TRUE
);
586 glDisable (GL_BLEND
);
588 if ((thc
->selected
[3] == j
&& thc
->selected
[4] == i
&& thc
->selected
[5] == k
) )
589 glMaterialfv(GL_FRONT
, GL_DIFFUSE
, diffuse
[8]);
592 glDepthMask (GL_FALSE
);
593 glBlendFunc (GL_SRC_ALPHA
,GL_ONE_MINUS_SRC_COLOR
);
608 glDepthMask (GL_TRUE
);
609 glDisable (GL_BLEND
);
617 void drawMine(int x
,int y
,int z
)
621 //glEnable(GL_TEXTURE_2D);
622 //glDisable( GL_LIGHTING );
624 Field f
= thc
->b
->getField(x
,y
,z
);
627 int total_offsetX
= 0;
628 int total_offsetY
= 3;
635 if ( !f
.isCovered() )
642 val
= f
.getNeighboursCnt() - 1;
643 if (val
== -1 ) return;
648 total_offsetX
= val
% 8;
649 total_offsetY
-= (val
/ 8) % 4;
656 glNormal3f(0.0f
, 0.0f
, 1.0f
);
658 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
659 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
661 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
662 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
664 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
665 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
667 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
668 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
671 glNormal3f(0.0f
, 0.0f
, -1.0f
);
673 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
674 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
676 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
677 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
679 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
680 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
682 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
683 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
686 glNormal3f(-1.0f
, 0.0f
, 0.0f
);
688 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
689 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
691 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
692 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
694 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
695 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
697 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
698 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
701 glNormal3f(1.0f
, 0.0f
, 0.0f
);
703 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
704 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
706 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
707 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
709 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
710 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
712 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
713 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
716 glNormal3f(0.0f
, -1.0f
, 0.0f
);
718 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
719 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
721 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
722 glVertex3f( -glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
724 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
725 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
727 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
728 glVertex3f( glut_CUBE_SIZE
,-glut_CUBE_SIZE
, glut_CUBE_SIZE
);
731 glNormal3f(0.0f
, 1.0f
, 0.0f
);
733 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
734 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
736 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
);
737 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, glut_CUBE_SIZE
);
739 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
+ TEXTURE_OFFSET_UNIT_X
, TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
740 glVertex3f( glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
742 glTexCoord2f(total_offsetX
* TEXTURE_OFFSET_UNIT_X
,TEXTURE_OFFSET_UNIT_Y
* total_offsetY
+ TEXTURE_OFFSET_UNIT_Y
);
743 glVertex3f( -glut_CUBE_SIZE
,glut_CUBE_SIZE
, -glut_CUBE_SIZE
);
750 //glDisable(GL_TEXTURE_2D);
751 //glEnable( GL_LIGHTING );
756 void motion_pas(int x
,int y
)
759 if (y
< 54 && y
> 37)
790 if (y
< 37 && y
> 19)
823 if (x
< 320 && x
> 210)