Clean up install, restore for exec vtxfmts.
[mesa.git] / src / glut / ggi / ggiglut.c
1 /* **************************************************************************
2 * ggiglut.c
3 * **************************************************************************
4 *
5 * Copyright (C) 1998 Uwe Maurer - uwe_maurer@t-online.de
6 * Copyright (C) 1999 James Simmons
7 * Copyright (C) 1999 Jon Taylor
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
18 *
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 * **************************************************************************
24 * To-do:
25 * - Make everything use the portable ggi_* types
26 *
27 */
28
29 #define BUILDING_GGIGLUT
30
31 #define WIDTH 640
32 #define HEIGHT 480
33 #define GRAPHTYPE_RGB GT_16BIT
34 #define GRAPHTYPE_INDEX GT_8BIT
35
36 /*************************************************************************/
37
38 #include <GL/gl.h>
39 #include <GL/glu.h>
40 #include <GL/glut.h>
41 #include <malloc.h>
42 #include <stdio.h>
43 #include <stdarg.h>
44 #include <string.h>
45 #include "GL/ggimesa.h"
46 #include "debug.h"
47
48 #include <ggi/ggi.h>
49 #include <ggi/gii.h>
50
51 int _ggiglutDebugSync = 0;
52 uint32 _ggiglutDebugState = 0;
53
54 char *__glutProgramName = "GGI";
55
56 static ggi_visual_t __glut_vis;
57
58 static GGIMesaContext __glut_ctx;
59
60 //static int __glut_width = WIDTH;
61 //static int __glut_height = HEIGHT;
62 //static ggi_graphtype __glut_gt_rgb = GRAPHTYPE_RGB;
63 //static ggi_graphtype __glut_gt_index = GRAPHTYPE_INDEX;
64 static int __glut_width = GGI_AUTO;
65 static int __glut_height = GGI_AUTO;
66 static ggi_graphtype __glut_gt_rgb = GT_AUTO;
67 static ggi_graphtype __glut_gt_index = GT_8BIT;
68 static int __glut_init = GL_FALSE;
69
70 static int mousex = WIDTH / 2;
71 static int mousey = HEIGHT / 2;
72 static int mouse_moved = GL_FALSE;
73 static int mouse_down = GL_FALSE;
74 static int mouse_showcursor = GL_FALSE;
75
76 static void (*__glut_reshape)(int, int);
77 static void (*__glut_display)(void);
78 static void (*__glut_idle)(void);
79 static void (*__glut_keyboard)(unsigned char, int, int);
80 static void (*__glut_special)(int, int, int);
81 static void (*__glut_mouse)(int, int, int, int);
82 static void (*__glut_motion)(int, int);
83 static void (*__glut_passive_motion)(int, int);
84 static void (*__glut_visibility)(int);
85
86 static unsigned int __glut_mode = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH;
87
88 static int __glut_mod_keys = 0;
89
90 static int __glut_redisplay = GL_FALSE;
91
92 /* Menu */
93 static int __glut_menubutton = -1;
94 static int __glut_menuactive = GL_FALSE;
95
96 #define MAX_ENTRIES 64
97
98 typedef struct menu_s
99 {
100 char *label[MAX_ENTRIES];
101 int value[MAX_ENTRIES];
102 struct menu_s * submenu[MAX_ENTRIES];
103 void (*func)(int);
104 int max_strlen;
105 int num_entries;
106 } menu_t;
107
108 static menu_t *mainmenu;
109 static menu_t *curmenu;
110 static menu_t *activemenu;
111
112 void glutInit(int *argc, char **argv)
113 {
114 ggi_graphtype gt;
115 int i, k;
116 char *str;
117
118 GGIGLUTDPRINT_CORE("glutInit() called\n");
119
120 #define REMOVE {for (k=i;k<*argc-1;k++) argv[k]=argv[k+1]; \
121 (*argc)--; i--; }
122
123 if (__glut_init) return;
124
125 str = getenv("GGIGLUT_DEBUG");
126 if (str != NULL) {
127 _ggiglutDebugState = atoi(str);
128 fprintf(stderr, "Debugging=%d\n", _ggiglutDebugState);
129 GGIGLUTDPRINT_CORE("Debugging=%d\n", _ggiglutDebugState);
130 }
131
132 str = getenv("GGIGLUT_DEBUGSYNC");
133 if (str != NULL) {
134 _ggiglutDebugSync = 1;
135 }
136
137 if (argc && argv)
138 {
139
140 for (i = 1; i < *argc; i++)
141 {
142 if (strcmp(argv[i], "-mouse") == 0)
143 {
144 mouse_showcursor = GL_TRUE;
145 REMOVE;
146 }
147 else
148 if (strcmp(argv[i], "-bpp") == 0 && (i + 1) < (*argc))
149 {
150 switch(atoi(argv[i + 1]))
151 {
152 case 4: gt = GT_4BIT; break;
153 case 8: gt = GT_8BIT; break;
154 case 15: gt = GT_15BIT; break;
155 case 16: gt = GT_16BIT; break;
156 case 24: gt = GT_24BIT; break;
157 case 32: gt = GT_32BIT; break;
158 default:
159 ggiPanic("\"%s\" bits per pixel?\n", argv[i+1]);
160 }
161 __glut_gt_rgb = __glut_gt_index = gt;
162 REMOVE;
163 REMOVE;
164 }
165 else
166 if (strcmp(argv[i], "-size") == 0 && (i + 2) < (*argc))
167 {
168 __glut_width = atoi(argv[i + 1]);
169 __glut_height = atoi(argv[i + 2]);
170 REMOVE;
171 REMOVE;
172 REMOVE;
173 }
174 }
175 }
176
177 if (ggiInit() < 0)
178 {
179 ggiPanic("ggiInit() failed!\n");
180 }
181 __glut_init = GL_TRUE;
182
183 #undef REMOVE
184 }
185
186 void glutInitWindowPosition(int x, int y)
187 {
188 GGIGLUTDPRINT_CORE("glutInitWindowPosition() called\n");
189 }
190
191 void glutInitWindowSize(int x, int y)
192 {
193 GGIGLUTDPRINT_CORE("glutInitWindowsSize() called\n");
194 }
195
196 void glutFullScreen(void)
197 {
198 GGIGLUTDPRINT_CORE("glutFullScreen() called\n");
199 }
200
201 void glutInitDisplayMode(unsigned int mode)
202 {
203 GGIGLUTDPRINT_CORE("glutInitDisplayMode() called\n");
204
205 __glut_mode = mode;
206 }
207
208 void glutInitDisplayString(const char *string)
209 {
210 GGIGLUTDPRINT_CORE("glutInitDisplayString(%s) called\n", string);
211 }
212
213 int glutCreateWindow(const char *title)
214 {
215 ggi_graphtype gt;
216 ggi_mode mode =
217 {
218 1,
219 { GGI_AUTO, GGI_AUTO },
220 { GGI_AUTO, GGI_AUTO },
221 { 0, 0 },
222 GT_AUTO,
223 { GGI_AUTO, GGI_AUTO }
224 };
225 int frames;
226 int rgb;
227 int err;
228
229 GGIGLUTDPRINT_CORE("glutCreateWindow() called\n");
230
231 if (!__glut_init)
232 glutInit(NULL, NULL);
233
234 GGIGLUTDPRINT("GGIGLUT: %s\n", title);
235
236 rgb = !(__glut_mode & GLUT_INDEX);
237 frames = (__glut_mode & GLUT_DOUBLE) ? 2 : 1;
238
239 gt = (rgb) ? __glut_gt_rgb : __glut_gt_index;
240
241 __glut_ctx = GGIMesaCreateContext();
242
243 if (__glut_ctx == NULL)
244 ggiPanic("Can't create mesa-context\n");
245
246 __glut_vis = ggiOpen(NULL);
247 if (__glut_vis == NULL)
248 {
249 ggiPanic("ggiOpen() failed!\n");
250 /* return GL_FALSE; */
251 }
252
253 ggiSetFlags(__glut_vis, GGIFLAG_ASYNC);
254
255 ggiCheckMode(__glut_vis, &mode);
256
257 err = ggiSetMode(__glut_vis, &mode);
258 if (err < 0)
259 {
260 ggiPanic("Can't set graphic mode!\n");
261 /* return GL_FALSE; */
262 }
263
264 ggiGetMode(__glut_vis, &mode);
265
266 if (GGIMesaSetVisual(__glut_ctx, __glut_vis, rgb, frames > 1) < 0)
267 {
268 ggiPanic("GGIMesaSetVisual failed!\n");
269 }
270
271 __glut_width = mode.visible.x;
272 __glut_height = mode.visible.y;
273
274 mousex = mode.visible.x / 2;
275 mousey = mode.visible.y / 2;
276
277 GGIMesaMakeCurrent(__glut_ctx);
278
279 if (__glut_reshape)
280 __glut_reshape(__glut_width, __glut_height);
281
282 return GL_TRUE;
283 }
284
285 void glutReshapeFunc(void (*func)(int, int))
286 {
287 GGIGLUTDPRINT_CORE("glutReshapeFunc() called\n");
288
289 __glut_reshape = func;
290 if (__glut_vis && __glut_reshape)
291 __glut_reshape(__glut_width, __glut_height);
292 }
293
294 void glutKeyboardFunc(void (*keyboard)(unsigned char key, int x, int y))
295 {
296 GGIGLUTDPRINT_CORE("glutKeyBoardFunc() called\n");
297
298 __glut_keyboard = keyboard;
299 }
300
301 int glutGetModifiers(void)
302 {
303 GGIGLUTDPRINT_CORE("glutGetModifiers() called\n");
304
305 return __glut_mod_keys;
306 }
307
308 void glutEntryFunc(void (*func)(int state))
309 {
310 GGIGLUTDPRINT_CORE("glutEntryFunc() called\n");
311 }
312
313 void glutVisibilitFunc(void (*func)(int state))
314 {
315 GGIGLUTDPRINT_CORE("glutVisibilityFunc() called\n");
316 }
317
318 void glutTimerFunc(unsigned int millis, void (*func)(int value), int value)
319 {
320 GGIGLUTDPRINT_CORE("glutTimerFunc() called\n");
321 }
322
323 void glutMenuStateFunc(void (*func)(int state))
324 {
325 GGIGLUTDPRINT_CORE("glutMenuStateFunc() called\n");
326 }
327
328 int glutGet(GLenum type)
329 {
330 GGIGLUTDPRINT_CORE("glutGet() called\n");
331
332 switch(type)
333 {
334 case GLUT_WINDOW_X:
335 return 0;
336 case GLUT_WINDOW_Y:
337 return 0;
338 case GLUT_WINDOW_WIDTH:
339 return __glut_width;
340 case GLUT_WINDOW_HEIGHT:
341 return __glut_height;
342 case GLUT_MENU_NUM_ITEMS:
343 if (curmenu)
344 return curmenu->num_entries;
345 else
346 return 0;
347 default:
348 GGIGLUTDPRINT("glutGet: unknown type %i\n", type);
349 }
350 return 0;
351 }
352
353 void glutSpecialFunc(void (*special)(int key, int x, int y))
354 {
355 GGIGLUTDPRINT_CORE("glutSpecialFunc() called\n");
356
357 __glut_special=special;
358 }
359
360 void glutDisplayFunc(void (*disp)(void))
361 {
362 GGIGLUTDPRINT_CORE("glutDisplayFunc() called\n");
363 __glut_display=disp;
364 }
365
366 void glutSetColor(int index, GLfloat red, GLfloat green, GLfloat blue)
367 {
368 ggi_color c;
369 GLfloat max;
370
371 GGIGLUTDPRINT_CORE("glutSetColor() called\n");
372
373 if (red > 1.0) red = 1.0;
374 if (red < 0.0) red = 0.0;
375 if (green > 1.0) green = 1.0;
376 if (green < 0.0) green = 0.0;
377 if (blue > 1.0) blue = 1.0;
378 if (blue < 0.0) blue = 0.0;
379
380 max = (float)((1 << GGI_COLOR_PRECISION) - 1);
381
382 c.r = (int)(max * red);
383 c.g = (int)(max * green);
384 c.b = (int)(max * blue);
385 ggiSetPalette(__glut_vis, index, 1, &c);
386 }
387
388 void glutPostRedisplay(void)
389 {
390 GGIGLUTDPRINT_CORE("glutPostRedisplay() called\n");
391
392 __glut_redisplay = GL_TRUE;
393 }
394
395 void glutPostWindowRedisplay(int win)
396 {
397 GGIGLUTDPRINT_CORE("glutPostWindowRedisplay() called\n");
398
399 __glut_redisplay = GL_TRUE;
400 }
401
402 void glutSwapBuffers(void)
403 {
404 GGIGLUTDPRINT_CORE("glutSwapBuffers() called\n");
405
406 GGIMesaSwapBuffers();
407 }
408
409 void glutIdleFunc(void (*idle)(void))
410 {
411 GGIGLUTDPRINT_CORE("glutIdleFunc() called\n");
412
413 __glut_idle = idle;
414 }
415
416 static void keyboard(ggi_event *ev)
417 {
418 int sym;
419 int modifer = 0, key = 0;
420
421 GGIGLUTDPRINT_CORE("keyboard() called\n");
422
423 sym = ev->key.sym;
424
425 modifer = ev->key.modifiers;
426 if (modifer == GII_KM_SHIFT)
427 __glut_mod_keys |= GLUT_ACTIVE_SHIFT;
428 if (modifer == GII_KM_CTRL)
429 __glut_mod_keys |= GLUT_ACTIVE_CTRL;
430 if (modifer == GII_KM_ALT)
431 __glut_mod_keys |= GLUT_ACTIVE_ALT;
432
433 /* if (__glut_special && key) __glut_special(GII_KTYP(key),0,0); */
434
435 if (__glut_keyboard)
436 // __glut_keyboard(GII_UNICODE(sym), 0, 0);
437 __glut_keyboard(sym, 0, 0);
438 }
439
440 static void mouseabs(ggi_event *ev)
441 {
442 int oldx = mousex;
443 int oldy = mousey;
444
445 mousex = ev->pmove.x;
446 mousey = ev->pmove.y;
447
448 if (mousex < 0) mousex = 0;
449 if (mousey < 0) mousey = 0;
450 if (mousex >= __glut_width) mousex = __glut_width - 1;
451 if (mousey >= __glut_height) mousey = __glut_height - 1;
452
453 if (mousex != oldx || mousey != oldy) mouse_moved = GL_TRUE;
454 }
455
456 static void mouse(ggi_event *ev)
457 {
458 int oldx = mousex;
459 int oldy = mousey;
460
461 GGIGLUTDPRINT_CORE("mouse() called\n");
462
463 mousex += ev->pmove.x >> 1;
464 mousey += ev->pmove.y >> 1;
465
466 if (mousex < 0) mousex = 0;
467 if (mousey < 0) mousey = 0;
468 if (mousex >= __glut_width) mousex = __glut_width - 1;
469 if (mousey >= __glut_height) mousey = __glut_height - 1;
470
471 if (mousex != oldx || mousey != oldy) mouse_moved = GL_TRUE;
472
473 }
474
475 static void showmenu(void);
476 static int clickmenu(void);
477 static void updatemouse(void);
478 static void drawmouse(void);
479
480 static void mousemove(void)
481 {
482 GGIGLUTDPRINT_CORE("mousemove() called\n");
483
484 if (mouse_moved) {
485 if (__glut_motion && mouse_down) {
486 __glut_motion(mousex,mousey);
487 }
488
489 if (__glut_passive_motion && (!mouse_down)) {
490 __glut_passive_motion(mousex,mousey);
491 }
492
493 if (__glut_menuactive) updatemouse();
494 mouse_moved=GL_FALSE;
495 }
496 }
497
498 static void button(ggi_event *ev)
499 {
500 int i;
501 int btn[4] = {
502 0,
503 GLUT_LEFT_BUTTON,
504 GLUT_RIGHT_BUTTON,
505 GLUT_MIDDLE_BUTTON
506 };
507
508 GGIGLUTDPRINT_CORE("button() called\n");
509
510 mousemove();
511
512 if (ev->pbutton.button <= 3) { /* GGI can have >3 buttons ! */
513 char state = ev->any.type == evPtrButtonPress ? GLUT_DOWN : GLUT_UP;
514 if (__glut_menuactive) {
515 if (state == GLUT_UP && clickmenu()) {
516 glutPostRedisplay();
517 __glut_menuactive = GL_FALSE;
518 }
519 } else
520 if (btn[ev->pbutton.button] == __glut_menubutton) {
521 __glut_menuactive = GL_TRUE;
522 activemenu = mainmenu;
523 showmenu();
524 } else
525 if (__glut_mouse) {
526 __glut_mouse(btn[ev->pbutton.button], state, mousex, mousey);
527 }
528 if (state == GLUT_DOWN) {
529 mouse_down |= (1 << (ev->pbutton.button - 1));
530 }
531 else mouse_down &= ~( 1 << (ev->pbutton.button - 1));
532 }
533 }
534
535 void glutMainLoop(void)
536 {
537 ggi_event ev;
538 ggi_event_mask evmask = (emKeyPress | emKeyRepeat | emPtrMove | emPtrButton);
539
540 GGIGLUTDPRINT_CORE("glutMainLoop() called\n");
541
542 ggiSetEventMask(__glut_vis, evmask);
543
544 glutPostRedisplay();
545
546 if (__glut_visibility)
547 __glut_visibility(GLUT_VISIBLE);
548
549 while (1)
550 {
551 if (!__glut_menuactive)
552 {
553 if (__glut_idle)
554 __glut_idle();
555 if (__glut_redisplay && __glut_display)
556 {
557 __glut_redisplay = GL_FALSE;
558 __glut_display();
559 }
560 }
561
562 while (1)
563 {
564 struct timeval t = {0, 0};
565
566 if (ggiEventPoll(__glut_vis, evmask, &t) == 0)
567 break;
568
569 ggiEventRead(__glut_vis, &ev, evmask);
570
571 switch (ev.any.type)
572 {
573 case evKeyPress:
574 case evKeyRepeat:
575 keyboard(&ev);
576 break;
577 case evPtrAbsolute:
578 mouseabs(&ev);
579 break;
580 case evPtrRelative:
581 mouse(&ev);
582 break;
583 case evPtrButtonPress:
584 case evPtrButtonRelease:
585 button(&ev);
586 break;
587 }
588 }
589 mousemove();
590 }
591 }
592
593 static void showmenu()
594 {
595 int y,i;
596 ggi_color col = { 0xffff, 0xffff, 0xffff };
597
598 GGIGLUTDPRINT_CORE("showmenu() called\n");
599
600 ggiSetGCForeground(__glut_vis,ggiMapColor(__glut_vis,&col));
601 ggiSetOrigin(__glut_vis,0,0);
602
603 for (y = i = 0; i < activemenu->num_entries; i++, y += 8) {
604 ggiPuts(__glut_vis, 0, y, activemenu->label[i]);
605 }
606 drawmouse();
607 }
608
609 static int clickmenu(void)
610 {
611 int i;
612 int w, h;
613
614 GGIGLUTDPRINT_CORE("clickmenu() called\n");
615
616 i = mousey / 8;
617
618 if (i >= activemenu->num_entries) return GL_TRUE;
619 if (mousex >= 8 * strlen(activemenu->label[i])) return GL_TRUE;
620
621 if (activemenu->submenu[i]) {
622 ggi_color col={0,0,0};
623 ggiSetGCForeground(__glut_vis,ggiMapColor(__glut_vis,&col));
624 h=activemenu->num_entries*8;
625 w=activemenu->max_strlen*8;
626 ggiDrawBox(__glut_vis,0,0,w,h);
627 activemenu=activemenu->submenu[i];
628 showmenu();
629 return GL_FALSE;
630 }
631 curmenu=activemenu;
632 activemenu->func(activemenu->value[i]);
633 return GL_TRUE;
634 }
635
636 static int oldx=-1;
637 static int oldy=-1;
638 static char buffer[16*16*4];
639
640 static void updatemouse()
641 {
642 GGIGLUTDPRINT_CORE("updatemouse() called\n");
643
644 ggiPutBox(__glut_vis,oldx,oldy,16,16,buffer);
645 drawmouse();
646 }
647
648 static void drawmouse()
649 {
650 int x,y;
651
652 GGIGLUTDPRINT_CORE("drawmouse() called\n");
653
654 x=mousex-8;
655 if (x<0) x=0;
656 y=mousey-8;
657 if (y<0) y=0;
658 ggiGetBox(__glut_vis,x,y,16,16,buffer);
659 ggiDrawLine(__glut_vis,mousex-2,mousey,mousex+2,mousey);
660 ggiDrawLine(__glut_vis,mousex,mousey-2,mousex,mousey+2);
661 oldx=x;
662 oldy=y;
663 }
664
665 int glutCreateMenu(void(*func)(int))
666 {
667 menu_t *m;
668
669 GGIGLUTDPRINT_CORE("glutCreateMenu() called\n");
670
671 m=malloc(sizeof(menu_t));
672 memset(m,0,sizeof(menu_t));
673 curmenu=m;
674 curmenu->func=func;
675 return (int)curmenu;
676 }
677
678 static void addEntry(const char *label,int value,menu_t *submenu)
679 {
680 int i=curmenu->num_entries;
681
682 GGIGLUTDPRINT_CORE("addEntry() called\n");
683
684 /* printf("%i %i %s %p\n",i,value,label,submenu); */
685 if (i<MAX_ENTRIES) {
686 curmenu->label[i]=strdup(label);
687 curmenu->value[i]=value;
688 curmenu->submenu[i]=submenu;
689
690 if (strlen(label)>curmenu->max_strlen)
691 curmenu->max_strlen=strlen(label);
692 curmenu->num_entries++;
693 }
694 }
695
696 void glutAddMenuEntry(const char *label,int value)
697 {
698 GGIGLUTDPRINT_CORE("glutAddMenuEntry() called\n");
699
700 addEntry(label,value,NULL);
701 }
702
703 void glutAddSubMenu(const char *label,int submenu)
704 {
705 char text[100];
706
707 GGIGLUTDPRINT_CORE("glutAddSubMenu() called\n");
708
709 if (!curmenu) return;
710 strncpy(text,label,98);
711 text[98]=0;
712 text[strlen(text)+1]=0;
713 text[strlen(text)]='>';
714
715 addEntry(text,0,(menu_t *) submenu);
716 }
717
718 void glutAttachMenu(int button)
719 {
720 GGIGLUTDPRINT_CORE("glutAttachMenu() called\n");
721
722 mainmenu=curmenu;
723 __glut_menubutton=button;
724 }
725
726 void glutDetachMenu(int button)
727 {
728 GGIGLUTDPRINT_CORE("glutDetachMenu() called\n");
729 }
730
731 void glutVisibilityFunc(void (*func)(int state))
732 {
733 GGIGLUTDPRINT_CORE("glutVisibilityFunc() called\n");
734
735 __glut_visibility=func;
736 }
737
738 void glutMouseFunc(void (*mouse)(int, int, int, int))
739 {
740 GGIGLUTDPRINT_CORE("glutMouseFunc() called\n");
741
742 __glut_mouse=mouse;
743 }
744
745 void glutMotionFunc(void (*motion)(int,int))
746 {
747 GGIGLUTDPRINT_CORE("glutMotionFunc() called\n");
748
749 __glut_motion=motion;
750 }
751
752 void glutPassiveMotionFunc(void (*motion)(int,int))
753 {
754 GGIGLUTDPRINT_CORE("glutPassiveMotionFunc() called\n");
755
756 __glut_passive_motion=motion;
757 }
758
759 void glutSetWindowTitle(const char *title)
760 {
761 GGIGLUTDPRINT_CORE("glutSetWindowTitle() called\n");
762 }
763
764 void glutSetIconTitle(const char *title)
765 {
766 GGIGLUTDPRINT_CORE("glutSetIconTitle() called\n");
767 }
768
769 void glutChangeToMenuEntry(int item,const char *label,int value)
770 {
771 GGIGLUTDPRINT_CORE("glutChangeToMenuEntry() called\n");
772
773 if (item>0 && item<=curmenu->num_entries) {
774 item--;
775 free(curmenu->label[item]);
776 curmenu->label[item]=strdup(label);
777 curmenu->value[item]=value;
778 curmenu->submenu[item]=NULL;
779 }
780 }
781 void glutChangeToSubMenu(int item,const char *label,int submenu)
782 {
783 GGIGLUTDPRINT_CORE("glutChengeToSubMenu() called\n");
784
785 if (item>0 && item<=curmenu->num_entries) {
786 item--;
787 free(curmenu->label[item]);
788 curmenu->label[item]=strdup(label);
789 curmenu->value[item]=0;
790 curmenu->submenu[item]=(menu_t *)submenu;
791 }
792 }
793
794 void glutDestroyMenu(int menu)
795 {
796 menu_t *m=(menu_t *)menu;
797 int i;
798
799 GGIGLUTDPRINT_CORE("glutDestroyMenu() called\n");
800
801 for (i=0;i<m->num_entries;i++) {
802 free(m->label[i]);
803 }
804 free(m);
805 }
806
807 int glutCreateSubWindow(int win,int x,int y,int w,int h)
808 {
809 GGIGLUTDPRINT_CORE("glutCreateSubWindow() called\n");
810
811 return 0;
812 }
813
814 void glutDestroyWindow(int win)
815 {
816 GGIGLUTDPRINT_CORE("glutDestroyWindow() called\n");
817 }
818
819 int glutGetWindow(void)
820 {
821 GGIGLUTDPRINT_CORE("glutGetWindow() called\n");
822
823 return 0;
824 }
825
826 void glutSetWindow(int win)
827 {
828 GGIGLUTDPRINT_CORE("glutSetWindow() called\n");
829 }
830
831 void glutPositionWindow(int x,int y)
832 {
833 GGIGLUTDPRINT_CORE("glutPositionWindow() called\n");
834 }
835
836 void glutReshapeWindow(int x,int y)
837 {
838 GGIGLUTDPRINT_CORE("glutReshapeWindow() called\n");
839 }
840
841 void glutPushWindow(void)
842 {
843 GGIGLUTDPRINT_CORE("glutPushWindow() called\n");
844 }
845
846 void glutPopWindow(void)
847 {
848 GGIGLUTDPRINT_CORE("glutPopWindow() called\n");
849 }
850
851 void glutIconifyWindow(void)
852 {
853 GGIGLUTDPRINT_CORE("glutIconifyWindow() called\n");
854 }
855
856 void glutShowWindow()
857 {
858 GGIGLUTDPRINT_CORE("glutShowWindow() called\n");
859 }
860
861 void glutHideWindow()
862 {
863 GGIGLUTDPRINT_CORE("glutHideWindow() called\n");
864 }
865
866 void glutSetCursor(int cursor)
867 {
868 GGIGLUTDPRINT_CORE("glutSetCursor() called\n");
869 }
870
871 void glutWarpPointer(int x,int y)
872 {
873 GGIGLUTDPRINT_CORE("glutWarpPointer() called\n");
874 }
875
876 void glutEstablishOverlay(void)
877 {
878 GGIGLUTDPRINT_CORE("glutEstablishOverlay() called\n");
879 }
880
881 void glutRemoveOverlay(void)
882 {
883 GGIGLUTDPRINT_CORE("glutRemoveOverlay() called\n");
884 }
885
886 void glutUseLayer(GLenum layer)
887 {
888 GGIGLUTDPRINT_CORE("glutUseLayer() called\n");
889 }
890
891 int glutLayerGet(GLenum type)
892 {
893 GGIGLUTDPRINT_CORE("glutLayerGet() called\n");
894 return 0;
895 }
896
897 void glutPostOverlayRedisplay(void)
898 {
899 GGIGLUTDPRINT_CORE("glutPostOverlayRedisplay() called\n");
900 }
901
902 void glutPostWindowOverlayRedisplay(int w)
903 {
904 GGIGLUTDPRINT_CORE("glutPostWindowOverlayRedisplay() called\n");
905 }
906
907 void glutShowOverlay(void)
908 {
909 GGIGLUTDPRINT_CORE("glutShowOverlay() called\n");
910 }
911
912 void glutHideOverlay(void)
913 {
914 GGIGLUTDPRINT_CORE("glutHideOverlay() called\n");
915 }
916
917 int glutGetMenu(void)
918 {
919 GGIGLUTDPRINT_CORE("glutGetMenu() called\n");
920 return 0;
921 }
922
923 void glutSetMenu(int menu)
924 {
925 GGIGLUTDPRINT_CORE("glutSetMenu() called\n");
926 }
927
928 void glutRemoveMenuItem(int item)
929 {
930 GGIGLUTDPRINT_CORE("glutRemoveMenuItem() called\n");
931 }
932
933 void glutSpaceBallMotionFunc(void (*func)(int key,int x,int y))
934 {
935 GGIGLUTDPRINT_CORE("glutSpaceBallMotionFunc() called\n");
936 }
937
938 void glutSpaceBallRotateFunc(void (*func)(int x,int y,int z))
939 {
940 GGIGLUTDPRINT_CORE("glutSpaceBallRotateFunc() called\n");
941 }
942
943 void glutSpaceBallButtonFunc(void (*func)(int button,int state))
944 {
945 GGIGLUTDPRINT_CORE("glutSpaceBallButtonFunc() called\n");
946 }
947
948 void glutCopyColormap(int win)
949 {
950 GGIGLUTDPRINT_CORE("glutCopyColormap() called\n");
951 }
952
953 int glutDeviceGet(GLenum param)
954 {
955 GGIGLUTDPRINT_CORE("glutDeviceGet() called\n");
956
957 return 0;
958 }