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