Fix a problem that caused the new interface code to not actually be
[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 ggi_mesa_context_t __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_vis = ggiOpen(NULL);
242 if (__glut_vis == NULL)
243 {
244 ggiPanic("ggiOpen() failed!\n");
245 /* return GL_FALSE; */
246 }
247
248 ggiSetFlags(__glut_vis, GGIFLAG_ASYNC);
249
250 ggiCheckMode(__glut_vis, &mode);
251
252 err = ggiSetMode(__glut_vis, &mode);
253 if (err < 0)
254 {
255 ggiPanic("Can't set graphic mode!\n");
256 /* return GL_FALSE; */
257 }
258
259 if (ggiMesaExtendVisual(__glut_vis, GL_FALSE, GL_FALSE,
260 16, 0, 0, 0, 0, 0, 1) < 0)
261 {
262 ggiPanic("GGIMesaSetVisual failed!\n");
263 }
264
265 __glut_ctx = ggiMesaCreateContext(__glut_vis);
266
267 if (__glut_ctx == NULL)
268 ggiPanic("Can't create mesa-context\n");
269
270 ggiGetMode(__glut_vis, &mode);
271
272
273 __glut_width = mode.visible.x;
274 __glut_height = mode.visible.y;
275
276 mousex = mode.visible.x / 2;
277 mousey = mode.visible.y / 2;
278
279 ggiMesaMakeCurrent(__glut_ctx, __glut_vis);
280
281 if (__glut_reshape)
282 __glut_reshape(__glut_width, __glut_height);
283
284 return GL_TRUE;
285 }
286
287 void glutReshapeFunc(void (*func)(int, int))
288 {
289 GGIGLUTDPRINT_CORE("glutReshapeFunc() called\n");
290
291 __glut_reshape = func;
292 if (__glut_vis && __glut_reshape)
293 __glut_reshape(__glut_width, __glut_height);
294 }
295
296 void glutKeyboardFunc(void (*keyboard)(unsigned char key, int x, int y))
297 {
298 GGIGLUTDPRINT_CORE("glutKeyBoardFunc() called\n");
299
300 __glut_keyboard = keyboard;
301 }
302
303 int glutGetModifiers(void)
304 {
305 GGIGLUTDPRINT_CORE("glutGetModifiers() called\n");
306
307 return __glut_mod_keys;
308 }
309
310 void glutEntryFunc(void (*func)(int state))
311 {
312 GGIGLUTDPRINT_CORE("glutEntryFunc() called\n");
313 }
314
315 void glutVisibilitFunc(void (*func)(int state))
316 {
317 GGIGLUTDPRINT_CORE("glutVisibilityFunc() called\n");
318 }
319
320 void glutTimerFunc(unsigned int millis, void (*func)(int value), int value)
321 {
322 GGIGLUTDPRINT_CORE("glutTimerFunc() called\n");
323 }
324
325 void glutMenuStateFunc(void (*func)(int state))
326 {
327 GGIGLUTDPRINT_CORE("glutMenuStateFunc() called\n");
328 }
329
330 int glutGet(GLenum type)
331 {
332 GGIGLUTDPRINT_CORE("glutGet() called\n");
333
334 switch(type)
335 {
336 case GLUT_WINDOW_X:
337 return 0;
338 case GLUT_WINDOW_Y:
339 return 0;
340 case GLUT_WINDOW_WIDTH:
341 return __glut_width;
342 case GLUT_WINDOW_HEIGHT:
343 return __glut_height;
344 case GLUT_MENU_NUM_ITEMS:
345 if (curmenu)
346 return curmenu->num_entries;
347 else
348 return 0;
349 default:
350 GGIGLUTDPRINT("glutGet: unknown type %i\n", type);
351 }
352 return 0;
353 }
354
355 void glutSpecialFunc(void (*special)(int key, int x, int y))
356 {
357 GGIGLUTDPRINT_CORE("glutSpecialFunc() called\n");
358
359 __glut_special=special;
360 }
361
362 void glutDisplayFunc(void (*disp)(void))
363 {
364 GGIGLUTDPRINT_CORE("glutDisplayFunc() called\n");
365 __glut_display=disp;
366 }
367
368 void glutSetColor(int index, GLfloat red, GLfloat green, GLfloat blue)
369 {
370 ggi_color c;
371 GLfloat max;
372
373 GGIGLUTDPRINT_CORE("glutSetColor() called\n");
374
375 if (red > 1.0) red = 1.0;
376 if (red < 0.0) red = 0.0;
377 if (green > 1.0) green = 1.0;
378 if (green < 0.0) green = 0.0;
379 if (blue > 1.0) blue = 1.0;
380 if (blue < 0.0) blue = 0.0;
381
382 max = (float)((1 << GGI_COLOR_PRECISION) - 1);
383
384 c.r = (int)(max * red);
385 c.g = (int)(max * green);
386 c.b = (int)(max * blue);
387 ggiSetPalette(__glut_vis, index, 1, &c);
388 }
389
390 void glutPostRedisplay(void)
391 {
392 GGIGLUTDPRINT_CORE("glutPostRedisplay() called\n");
393
394 __glut_redisplay = GL_TRUE;
395 }
396
397 void glutPostWindowRedisplay(int win)
398 {
399 GGIGLUTDPRINT_CORE("glutPostWindowRedisplay() called\n");
400
401 __glut_redisplay = GL_TRUE;
402 }
403
404 void glutSwapBuffers(void)
405 {
406 GGIGLUTDPRINT_CORE("glutSwapBuffers() called\n");
407
408 GGIMesaSwapBuffers();
409 }
410
411 void glutIdleFunc(void (*idle)(void))
412 {
413 GGIGLUTDPRINT_CORE("glutIdleFunc() called\n");
414
415 __glut_idle = idle;
416 }
417
418 static void keyboard(ggi_event *ev)
419 {
420 int sym;
421 int modifer = 0, key = 0;
422
423 GGIGLUTDPRINT_CORE("keyboard() called\n");
424
425 sym = ev->key.sym;
426
427 modifer = ev->key.modifiers;
428 if (modifer == GII_KM_SHIFT)
429 __glut_mod_keys |= GLUT_ACTIVE_SHIFT;
430 if (modifer == GII_KM_CTRL)
431 __glut_mod_keys |= GLUT_ACTIVE_CTRL;
432 if (modifer == GII_KM_ALT)
433 __glut_mod_keys |= GLUT_ACTIVE_ALT;
434
435 /* if (__glut_special && key) __glut_special(GII_KTYP(key),0,0); */
436
437 if (__glut_keyboard)
438 // __glut_keyboard(GII_UNICODE(sym), 0, 0);
439 __glut_keyboard(sym, 0, 0);
440 }
441
442 static void mouseabs(ggi_event *ev)
443 {
444 int oldx = mousex;
445 int oldy = mousey;
446
447 mousex = ev->pmove.x;
448 mousey = ev->pmove.y;
449
450 if (mousex < 0) mousex = 0;
451 if (mousey < 0) mousey = 0;
452 if (mousex >= __glut_width) mousex = __glut_width - 1;
453 if (mousey >= __glut_height) mousey = __glut_height - 1;
454
455 if (mousex != oldx || mousey != oldy) mouse_moved = GL_TRUE;
456 }
457
458 static void mouse(ggi_event *ev)
459 {
460 int oldx = mousex;
461 int oldy = mousey;
462
463 GGIGLUTDPRINT_CORE("mouse() called\n");
464
465 mousex += ev->pmove.x >> 1;
466 mousey += ev->pmove.y >> 1;
467
468 if (mousex < 0) mousex = 0;
469 if (mousey < 0) mousey = 0;
470 if (mousex >= __glut_width) mousex = __glut_width - 1;
471 if (mousey >= __glut_height) mousey = __glut_height - 1;
472
473 if (mousex != oldx || mousey != oldy) mouse_moved = GL_TRUE;
474
475 }
476
477 static void showmenu(void);
478 static int clickmenu(void);
479 static void updatemouse(void);
480 static void drawmouse(void);
481
482 static void mousemove(void)
483 {
484 GGIGLUTDPRINT_CORE("mousemove() called\n");
485
486 if (mouse_moved) {
487 if (__glut_motion && mouse_down) {
488 __glut_motion(mousex,mousey);
489 }
490
491 if (__glut_passive_motion && (!mouse_down)) {
492 __glut_passive_motion(mousex,mousey);
493 }
494
495 if (__glut_menuactive) updatemouse();
496 mouse_moved=GL_FALSE;
497 }
498 }
499
500 static void button(ggi_event *ev)
501 {
502 int i;
503 int btn[4] = {
504 0,
505 GLUT_LEFT_BUTTON,
506 GLUT_RIGHT_BUTTON,
507 GLUT_MIDDLE_BUTTON
508 };
509
510 GGIGLUTDPRINT_CORE("button() called\n");
511
512 mousemove();
513
514 if (ev->pbutton.button <= 3) { /* GGI can have >3 buttons ! */
515 char state = ev->any.type == evPtrButtonPress ? GLUT_DOWN : GLUT_UP;
516 if (__glut_menuactive) {
517 if (state == GLUT_UP && clickmenu()) {
518 glutPostRedisplay();
519 __glut_menuactive = GL_FALSE;
520 }
521 } else
522 if (btn[ev->pbutton.button] == __glut_menubutton) {
523 __glut_menuactive = GL_TRUE;
524 activemenu = mainmenu;
525 showmenu();
526 } else
527 if (__glut_mouse) {
528 __glut_mouse(btn[ev->pbutton.button], state, mousex, mousey);
529 }
530 if (state == GLUT_DOWN) {
531 mouse_down |= (1 << (ev->pbutton.button - 1));
532 }
533 else mouse_down &= ~( 1 << (ev->pbutton.button - 1));
534 }
535 }
536
537 void glutMainLoop(void)
538 {
539 ggi_event ev;
540 ggi_event_mask evmask = (emKeyPress | emKeyRepeat | emPtrMove | emPtrButton);
541
542 GGIGLUTDPRINT_CORE("glutMainLoop() called\n");
543
544 ggiSetEventMask(__glut_vis, evmask);
545
546 glutPostRedisplay();
547
548 if (__glut_visibility)
549 __glut_visibility(GLUT_VISIBLE);
550
551 while (1)
552 {
553 if (!__glut_menuactive)
554 {
555 if (__glut_idle)
556 __glut_idle();
557 if (__glut_redisplay && __glut_display)
558 {
559 __glut_redisplay = GL_FALSE;
560 __glut_display();
561 }
562 }
563
564 while (1)
565 {
566 struct timeval t = {0, 0};
567
568 if (ggiEventPoll(__glut_vis, evmask, &t) == 0)
569 break;
570
571 ggiEventRead(__glut_vis, &ev, evmask);
572
573 switch (ev.any.type)
574 {
575 case evKeyPress:
576 case evKeyRepeat:
577 keyboard(&ev);
578 break;
579 case evPtrAbsolute:
580 mouseabs(&ev);
581 break;
582 case evPtrRelative:
583 mouse(&ev);
584 break;
585 case evPtrButtonPress:
586 case evPtrButtonRelease:
587 button(&ev);
588 break;
589 }
590 }
591 mousemove();
592 }
593 }
594
595 static void showmenu()
596 {
597 int y,i;
598 ggi_color col = { 0xffff, 0xffff, 0xffff };
599
600 GGIGLUTDPRINT_CORE("showmenu() called\n");
601
602 ggiSetGCForeground(__glut_vis,ggiMapColor(__glut_vis,&col));
603 ggiSetOrigin(__glut_vis,0,0);
604
605 for (y = i = 0; i < activemenu->num_entries; i++, y += 8) {
606 ggiPuts(__glut_vis, 0, y, activemenu->label[i]);
607 }
608 drawmouse();
609 }
610
611 static int clickmenu(void)
612 {
613 int i;
614 int w, h;
615
616 GGIGLUTDPRINT_CORE("clickmenu() called\n");
617
618 i = mousey / 8;
619
620 if (i >= activemenu->num_entries) return GL_TRUE;
621 if (mousex >= 8 * strlen(activemenu->label[i])) return GL_TRUE;
622
623 if (activemenu->submenu[i]) {
624 ggi_color col={0,0,0};
625 ggiSetGCForeground(__glut_vis,ggiMapColor(__glut_vis,&col));
626 h=activemenu->num_entries*8;
627 w=activemenu->max_strlen*8;
628 ggiDrawBox(__glut_vis,0,0,w,h);
629 activemenu=activemenu->submenu[i];
630 showmenu();
631 return GL_FALSE;
632 }
633 curmenu=activemenu;
634 activemenu->func(activemenu->value[i]);
635 return GL_TRUE;
636 }
637
638 static int oldx=-1;
639 static int oldy=-1;
640 static char buffer[16*16*4];
641
642 static void updatemouse()
643 {
644 GGIGLUTDPRINT_CORE("updatemouse() called\n");
645
646 ggiPutBox(__glut_vis,oldx,oldy,16,16,buffer);
647 drawmouse();
648 }
649
650 static void drawmouse()
651 {
652 int x,y;
653
654 GGIGLUTDPRINT_CORE("drawmouse() called\n");
655
656 x=mousex-8;
657 if (x<0) x=0;
658 y=mousey-8;
659 if (y<0) y=0;
660 ggiGetBox(__glut_vis,x,y,16,16,buffer);
661 ggiDrawLine(__glut_vis,mousex-2,mousey,mousex+2,mousey);
662 ggiDrawLine(__glut_vis,mousex,mousey-2,mousex,mousey+2);
663 oldx=x;
664 oldy=y;
665 }
666
667 int glutCreateMenu(void(*func)(int))
668 {
669 menu_t *m;
670
671 GGIGLUTDPRINT_CORE("glutCreateMenu() called\n");
672
673 m=malloc(sizeof(menu_t));
674 memset(m,0,sizeof(menu_t));
675 curmenu=m;
676 curmenu->func=func;
677 return (int)curmenu;
678 }
679
680 static void addEntry(const char *label,int value,menu_t *submenu)
681 {
682 int i=curmenu->num_entries;
683
684 GGIGLUTDPRINT_CORE("addEntry() called\n");
685
686 /* printf("%i %i %s %p\n",i,value,label,submenu); */
687 if (i<MAX_ENTRIES) {
688 curmenu->label[i]=strdup(label);
689 curmenu->value[i]=value;
690 curmenu->submenu[i]=submenu;
691
692 if (strlen(label)>curmenu->max_strlen)
693 curmenu->max_strlen=strlen(label);
694 curmenu->num_entries++;
695 }
696 }
697
698 void glutAddMenuEntry(const char *label,int value)
699 {
700 GGIGLUTDPRINT_CORE("glutAddMenuEntry() called\n");
701
702 addEntry(label,value,NULL);
703 }
704
705 void glutAddSubMenu(const char *label,int submenu)
706 {
707 char text[100];
708
709 GGIGLUTDPRINT_CORE("glutAddSubMenu() called\n");
710
711 if (!curmenu) return;
712 strncpy(text,label,98);
713 text[98]=0;
714 text[strlen(text)+1]=0;
715 text[strlen(text)]='>';
716
717 addEntry(text,0,(menu_t *) submenu);
718 }
719
720 void glutAttachMenu(int button)
721 {
722 GGIGLUTDPRINT_CORE("glutAttachMenu() called\n");
723
724 mainmenu=curmenu;
725 __glut_menubutton=button;
726 }
727
728 void glutDetachMenu(int button)
729 {
730 GGIGLUTDPRINT_CORE("glutDetachMenu() called\n");
731 }
732
733 void glutVisibilityFunc(void (*func)(int state))
734 {
735 GGIGLUTDPRINT_CORE("glutVisibilityFunc() called\n");
736
737 __glut_visibility=func;
738 }
739
740 void glutMouseFunc(void (*mouse)(int, int, int, int))
741 {
742 GGIGLUTDPRINT_CORE("glutMouseFunc() called\n");
743
744 __glut_mouse=mouse;
745 }
746
747 void glutMotionFunc(void (*motion)(int,int))
748 {
749 GGIGLUTDPRINT_CORE("glutMotionFunc() called\n");
750
751 __glut_motion=motion;
752 }
753
754 void glutPassiveMotionFunc(void (*motion)(int,int))
755 {
756 GGIGLUTDPRINT_CORE("glutPassiveMotionFunc() called\n");
757
758 __glut_passive_motion=motion;
759 }
760
761 void glutSetWindowTitle(const char *title)
762 {
763 GGIGLUTDPRINT_CORE("glutSetWindowTitle() called\n");
764 }
765
766 void glutSetIconTitle(const char *title)
767 {
768 GGIGLUTDPRINT_CORE("glutSetIconTitle() called\n");
769 }
770
771 void glutChangeToMenuEntry(int item,const char *label,int value)
772 {
773 GGIGLUTDPRINT_CORE("glutChangeToMenuEntry() called\n");
774
775 if (item>0 && item<=curmenu->num_entries) {
776 item--;
777 free(curmenu->label[item]);
778 curmenu->label[item]=strdup(label);
779 curmenu->value[item]=value;
780 curmenu->submenu[item]=NULL;
781 }
782 }
783 void glutChangeToSubMenu(int item,const char *label,int submenu)
784 {
785 GGIGLUTDPRINT_CORE("glutChengeToSubMenu() called\n");
786
787 if (item>0 && item<=curmenu->num_entries) {
788 item--;
789 free(curmenu->label[item]);
790 curmenu->label[item]=strdup(label);
791 curmenu->value[item]=0;
792 curmenu->submenu[item]=(menu_t *)submenu;
793 }
794 }
795
796 void glutDestroyMenu(int menu)
797 {
798 menu_t *m=(menu_t *)menu;
799 int i;
800
801 GGIGLUTDPRINT_CORE("glutDestroyMenu() called\n");
802
803 for (i=0;i<m->num_entries;i++) {
804 free(m->label[i]);
805 }
806 free(m);
807 }
808
809 int glutCreateSubWindow(int win,int x,int y,int w,int h)
810 {
811 GGIGLUTDPRINT_CORE("glutCreateSubWindow() called\n");
812
813 return 0;
814 }
815
816 void glutDestroyWindow(int win)
817 {
818 GGIGLUTDPRINT_CORE("glutDestroyWindow() called\n");
819 }
820
821 int glutGetWindow(void)
822 {
823 GGIGLUTDPRINT_CORE("glutGetWindow() called\n");
824
825 return 0;
826 }
827
828 void glutSetWindow(int win)
829 {
830 GGIGLUTDPRINT_CORE("glutSetWindow() called\n");
831 }
832
833 void glutPositionWindow(int x,int y)
834 {
835 GGIGLUTDPRINT_CORE("glutPositionWindow() called\n");
836 }
837
838 void glutReshapeWindow(int x,int y)
839 {
840 GGIGLUTDPRINT_CORE("glutReshapeWindow() called\n");
841 }
842
843 void glutPushWindow(void)
844 {
845 GGIGLUTDPRINT_CORE("glutPushWindow() called\n");
846 }
847
848 void glutPopWindow(void)
849 {
850 GGIGLUTDPRINT_CORE("glutPopWindow() called\n");
851 }
852
853 void glutIconifyWindow(void)
854 {
855 GGIGLUTDPRINT_CORE("glutIconifyWindow() called\n");
856 }
857
858 void glutShowWindow()
859 {
860 GGIGLUTDPRINT_CORE("glutShowWindow() called\n");
861 }
862
863 void glutHideWindow()
864 {
865 GGIGLUTDPRINT_CORE("glutHideWindow() called\n");
866 }
867
868 void glutSetCursor(int cursor)
869 {
870 GGIGLUTDPRINT_CORE("glutSetCursor() called\n");
871 }
872
873 void glutWarpPointer(int x,int y)
874 {
875 GGIGLUTDPRINT_CORE("glutWarpPointer() called\n");
876 }
877
878 void glutEstablishOverlay(void)
879 {
880 GGIGLUTDPRINT_CORE("glutEstablishOverlay() called\n");
881 }
882
883 void glutRemoveOverlay(void)
884 {
885 GGIGLUTDPRINT_CORE("glutRemoveOverlay() called\n");
886 }
887
888 void glutUseLayer(GLenum layer)
889 {
890 GGIGLUTDPRINT_CORE("glutUseLayer() called\n");
891 }
892
893 int glutLayerGet(GLenum type)
894 {
895 GGIGLUTDPRINT_CORE("glutLayerGet() called\n");
896 return 0;
897 }
898
899 void glutPostOverlayRedisplay(void)
900 {
901 GGIGLUTDPRINT_CORE("glutPostOverlayRedisplay() called\n");
902 }
903
904 void glutPostWindowOverlayRedisplay(int w)
905 {
906 GGIGLUTDPRINT_CORE("glutPostWindowOverlayRedisplay() called\n");
907 }
908
909 void glutShowOverlay(void)
910 {
911 GGIGLUTDPRINT_CORE("glutShowOverlay() called\n");
912 }
913
914 void glutHideOverlay(void)
915 {
916 GGIGLUTDPRINT_CORE("glutHideOverlay() called\n");
917 }
918
919 int glutGetMenu(void)
920 {
921 GGIGLUTDPRINT_CORE("glutGetMenu() called\n");
922 return 0;
923 }
924
925 void glutSetMenu(int menu)
926 {
927 GGIGLUTDPRINT_CORE("glutSetMenu() called\n");
928 }
929
930 void glutRemoveMenuItem(int item)
931 {
932 GGIGLUTDPRINT_CORE("glutRemoveMenuItem() called\n");
933 }
934
935 void glutSpaceBallMotionFunc(void (*func)(int key,int x,int y))
936 {
937 GGIGLUTDPRINT_CORE("glutSpaceBallMotionFunc() called\n");
938 }
939
940 void glutSpaceBallRotateFunc(void (*func)(int x,int y,int z))
941 {
942 GGIGLUTDPRINT_CORE("glutSpaceBallRotateFunc() called\n");
943 }
944
945 void glutSpaceBallButtonFunc(void (*func)(int button,int state))
946 {
947 GGIGLUTDPRINT_CORE("glutSpaceBallButtonFunc() called\n");
948 }
949
950 void glutCopyColormap(int win)
951 {
952 GGIGLUTDPRINT_CORE("glutCopyColormap() called\n");
953 }
954
955 int glutDeviceGet(GLenum param)
956 {
957 GGIGLUTDPRINT_CORE("glutDeviceGet() called\n");
958
959 return 0;
960 }