2b683e1327243cf488b99008e896af5ab3568ec6
[freeglut] / src / freeglut_state.c
1 /*
2  * freeglut_state.c
3  *
4  * Freeglut state query methods.
5  *
6  * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7  * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8  * Creation date: Thu Dec 16 1999
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23  * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  */
27
28 #include <GL/freeglut.h>
29 #include "freeglut_internal.h"
30
31 /*
32  * TODO BEFORE THE STABLE RELEASE:
33  *
34  *  glutGet()               -- X11 tests passed, but check if all enums
35  *                             handled (what about Win32?)
36  *  glutDeviceGet()         -- X11 tests passed, but check if all enums
37  *                             handled (what about Win32?)
38  *  glutGetModifiers()      -- OK, but could also remove the limitation
39  *  glutLayerGet()          -- what about GLUT_NORMAL_DAMAGED?
40  *
41  * The fail-on-call policy will help adding the most needed things imho.
42  */
43
44 /* -- LOCAL DEFINITIONS ---------------------------------------------------- */
45
46 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
47
48 #if TARGET_HOST_POSIX_X11
49 /*
50  * Queries the GL context about some attributes
51  */
52 static int fghGetConfig( int attribute )
53 {
54   int returnValue = 0;
55
56   if( fgStructure.CurrentWindow )
57       glXGetConfig( fgDisplay.Display, fgStructure.CurrentWindow->Window.VisualInfo,
58                     attribute, &returnValue );
59
60   return returnValue;
61 }
62 #endif
63
64 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
65
66 /*
67  * General settings assignment method
68  */
69 void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
70 {
71     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetOption" );
72
73     /*
74      * XXX In chronological code add order.  (WHY in that order?)
75      */
76     switch( eWhat )
77     {
78     case GLUT_INIT_WINDOW_X:
79         fgState.Position.X = (GLint)value;
80         break;
81
82     case GLUT_INIT_WINDOW_Y:
83         fgState.Position.Y = (GLint)value;
84         break;
85
86     case GLUT_INIT_WINDOW_WIDTH:
87         fgState.Size.X = (GLint)value;
88         break;
89
90     case GLUT_INIT_WINDOW_HEIGHT:
91         fgState.Size.Y = (GLint)value;
92         break;
93
94     case GLUT_INIT_DISPLAY_MODE:
95         fgState.DisplayMode = (unsigned int)value;
96         break;
97
98     case GLUT_ACTION_ON_WINDOW_CLOSE:
99         fgState.ActionOnWindowClose = value;
100         break;
101
102     case GLUT_RENDERING_CONTEXT:
103         fgState.UseCurrentContext =
104             ( value == GLUT_USE_CURRENT_CONTEXT ) ? GL_TRUE : GL_FALSE;
105         break;
106
107     case GLUT_DIRECT_RENDERING:
108         fgState.DirectContext = value;
109         break;
110
111     case GLUT_WINDOW_CURSOR:
112         if( fgStructure.CurrentWindow != NULL )
113             fgStructure.CurrentWindow->State.Cursor = value;
114         break;
115
116     default:
117         fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
118         break;
119     }
120 }
121
122 #if TARGET_HOST_MS_WINDOWS
123 /* The following include file is available from SGI but is not standard:
124  *   #include <GL/wglext.h>
125  * So we copy the necessary parts out of it to support the multisampling query
126  */
127 #define WGL_SAMPLES_ARB                0x2042
128 #endif
129
130
131 /*
132  * General settings query method
133  */
134 int FGAPIENTRY glutGet( GLenum eWhat )
135 {
136 #if TARGET_HOST_MS_WINDOWS
137     int returnValue ;
138     GLboolean boolValue ;
139 #endif
140
141     int nsamples = 0;
142
143     switch (eWhat)
144     {
145     case GLUT_INIT_STATE:
146         return fgState.Initialised;
147
148     case GLUT_ELAPSED_TIME:
149         return fgElapsedTime();
150     }
151
152     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGet" );
153
154     /* XXX In chronological code add order.  (WHY in that order?) */
155     switch( eWhat )
156     {
157     /* Following values are stored in fgState and fgDisplay global structures */
158     case GLUT_SCREEN_WIDTH:         return fgDisplay.ScreenWidth   ;
159     case GLUT_SCREEN_HEIGHT:        return fgDisplay.ScreenHeight  ;
160     case GLUT_SCREEN_WIDTH_MM:      return fgDisplay.ScreenWidthMM ;
161     case GLUT_SCREEN_HEIGHT_MM:     return fgDisplay.ScreenHeightMM;
162     case GLUT_INIT_WINDOW_X:        return fgState.Position.Use ?
163                                            fgState.Position.X : -1 ;
164     case GLUT_INIT_WINDOW_Y:        return fgState.Position.Use ?
165                                            fgState.Position.Y : -1 ;
166     case GLUT_INIT_WINDOW_WIDTH:    return fgState.Size.Use ?
167                                            fgState.Size.X : -1     ;
168     case GLUT_INIT_WINDOW_HEIGHT:   return fgState.Size.Use ?
169                                            fgState.Size.Y : -1     ;
170     case GLUT_INIT_DISPLAY_MODE:    return fgState.DisplayMode     ;
171
172 #if TARGET_HOST_POSIX_X11
173     /*
174      * The window/context specific queries are handled mostly by
175      * fghGetConfig().
176      */
177     case GLUT_WINDOW_NUM_SAMPLES:
178 #ifdef GLX_VERSION_1_3
179         glGetIntegerv(GL_SAMPLES, &nsamples);
180 #endif
181         return nsamples;
182
183     /*
184      * The rest of GLX queries under X are general enough to use a macro to
185      * check them
186      */
187 #   define GLX_QUERY(a,b) case a: return fghGetConfig( b );
188
189     GLX_QUERY( GLUT_WINDOW_RGBA,                GLX_RGBA                );
190     GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER,        GLX_DOUBLEBUFFER        );
191     GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE,         GLX_BUFFER_SIZE         );
192     GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE,        GLX_STENCIL_SIZE        );
193     GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE,          GLX_DEPTH_SIZE          );
194     GLX_QUERY( GLUT_WINDOW_RED_SIZE,            GLX_RED_SIZE            );
195     GLX_QUERY( GLUT_WINDOW_GREEN_SIZE,          GLX_GREEN_SIZE          );
196     GLX_QUERY( GLUT_WINDOW_BLUE_SIZE,           GLX_BLUE_SIZE           );
197     GLX_QUERY( GLUT_WINDOW_ALPHA_SIZE,          GLX_ALPHA_SIZE          );
198     GLX_QUERY( GLUT_WINDOW_ACCUM_RED_SIZE,      GLX_ACCUM_RED_SIZE      );
199     GLX_QUERY( GLUT_WINDOW_ACCUM_GREEN_SIZE,    GLX_ACCUM_GREEN_SIZE    );
200     GLX_QUERY( GLUT_WINDOW_ACCUM_BLUE_SIZE,     GLX_ACCUM_BLUE_SIZE     );
201     GLX_QUERY( GLUT_WINDOW_ACCUM_ALPHA_SIZE,    GLX_ACCUM_ALPHA_SIZE    );
202     GLX_QUERY( GLUT_WINDOW_STEREO,              GLX_STEREO              );
203
204 #   undef GLX_QUERY
205
206     /* Colormap size is handled in a bit different way than all the rest */
207     case GLUT_WINDOW_COLORMAP_SIZE:
208         if( (fghGetConfig( GLX_RGBA )) || (fgStructure.CurrentWindow == NULL) )
209         {
210             /*
211              * We've got a RGBA visual, so there is no colormap at all.
212              * The other possibility is that we have no current window set.
213              */
214             return 0;
215         }
216         return fgStructure.CurrentWindow->Window.VisualInfo->visual->map_entries;
217
218     /*
219      * Those calls are somewhat similiar, as they use XGetWindowAttributes()
220      * function
221      */
222     case GLUT_WINDOW_X:
223     case GLUT_WINDOW_Y:
224     case GLUT_WINDOW_BORDER_WIDTH:
225     case GLUT_WINDOW_HEADER_HEIGHT:
226     {
227         int x, y;
228         Window w;
229
230         if( fgStructure.CurrentWindow == NULL )
231             return 0;
232
233         XTranslateCoordinates(
234             fgDisplay.Display,
235             fgStructure.CurrentWindow->Window.Handle,
236             fgDisplay.RootWindow,
237             0, 0, &x, &y, &w);
238
239         switch ( eWhat )
240         {
241         case GLUT_WINDOW_X: return x;
242         case GLUT_WINDOW_Y: return y;
243         }
244
245         if ( w == 0 )
246             return 0;
247         XTranslateCoordinates(
248             fgDisplay.Display,
249             fgStructure.CurrentWindow->Window.Handle,
250             w, 0, 0, &x, &y, &w);
251
252         switch ( eWhat )
253         {
254         case GLUT_WINDOW_BORDER_WIDTH:  return x;
255         case GLUT_WINDOW_HEADER_HEIGHT: return y;
256         }
257     }
258
259     case GLUT_WINDOW_WIDTH:
260     case GLUT_WINDOW_HEIGHT:
261     {
262         XWindowAttributes winAttributes;
263
264         if( fgStructure.CurrentWindow == NULL )
265             return 0;
266         XGetWindowAttributes(
267             fgDisplay.Display,
268             fgStructure.CurrentWindow->Window.Handle,
269             &winAttributes
270         );
271         switch ( eWhat )
272         {
273         case GLUT_WINDOW_WIDTH:            return winAttributes.width ;
274         case GLUT_WINDOW_HEIGHT:           return winAttributes.height ;
275         }
276     }
277
278     /* I do not know yet if there will be a fgChooseVisual() function for Win32 */
279     case GLUT_DISPLAY_MODE_POSSIBLE:
280     {
281         XVisualInfo* visualInfo = fgChooseVisual();
282         if ( visualInfo == NULL ) {
283             return 0;
284         } else {
285             XFree( visualInfo );
286             return 1;
287         }
288     }
289
290     /* This is system-dependant */
291     case GLUT_WINDOW_FORMAT_ID:
292         if( fgStructure.CurrentWindow == NULL )
293             return 0;
294
295         return fgStructure.CurrentWindow->Window.VisualInfo->visualid;
296
297 #elif TARGET_HOST_MS_WINDOWS
298
299     case GLUT_WINDOW_NUM_SAMPLES:
300       glGetIntegerv(WGL_SAMPLES_ARB, &nsamples);
301       return nsamples;
302
303     /* Handle the OpenGL inquiries */
304     case GLUT_WINDOW_RGBA:
305       glGetBooleanv ( GL_RGBA_MODE, &boolValue );
306       returnValue = boolValue ? 1 : 0;
307       return returnValue;
308     case GLUT_WINDOW_DOUBLEBUFFER:
309       glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue );
310       returnValue = boolValue ? 1 : 0;
311       return returnValue;
312     case GLUT_WINDOW_STEREO:
313       glGetBooleanv ( GL_STEREO, &boolValue );
314       returnValue = boolValue ? 1 : 0;
315       return returnValue;
316
317     case GLUT_WINDOW_RED_SIZE:
318       glGetIntegerv ( GL_RED_BITS, &returnValue );
319       return returnValue;
320     case GLUT_WINDOW_GREEN_SIZE:
321       glGetIntegerv ( GL_GREEN_BITS, &returnValue );
322       return returnValue;
323     case GLUT_WINDOW_BLUE_SIZE:
324       glGetIntegerv ( GL_BLUE_BITS, &returnValue );
325       return returnValue;
326     case GLUT_WINDOW_ALPHA_SIZE:
327       glGetIntegerv ( GL_ALPHA_BITS, &returnValue );
328       return returnValue;
329     case GLUT_WINDOW_ACCUM_RED_SIZE:
330       glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue );
331       return returnValue;
332     case GLUT_WINDOW_ACCUM_GREEN_SIZE:
333       glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue );
334       return returnValue;
335     case GLUT_WINDOW_ACCUM_BLUE_SIZE:
336       glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue );
337       return returnValue;
338     case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
339       glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue );
340       return returnValue;
341     case GLUT_WINDOW_DEPTH_SIZE:
342       glGetIntegerv ( GL_DEPTH_BITS, &returnValue );
343       return returnValue;
344
345     case GLUT_WINDOW_BUFFER_SIZE:
346       returnValue = 1 ;                                      /* ????? */
347       return returnValue;
348     case GLUT_WINDOW_STENCIL_SIZE:
349       returnValue = 0 ;                                      /* ????? */
350       return returnValue;
351
352     case GLUT_WINDOW_X:
353     case GLUT_WINDOW_Y:
354     case GLUT_WINDOW_WIDTH:
355     case GLUT_WINDOW_HEIGHT:
356     {
357         /*
358          *  There is considerable confusion about the "right thing to
359          *  do" concerning window  size and position.  GLUT itself is
360          *  not consistent between Windows and UNIX/X11; since
361          *  platform independence is a virtue for "freeglut", we
362          *  decided to break with GLUT's behaviour.
363          *
364          *  Under UNIX/X11, it is apparently not possible to get the
365          *  window border sizes in order to subtract them off the
366          *  window's initial position until some time after the window
367          *  has been created.  Therefore we decided on the following
368          *  behaviour, both under Windows and under UNIX/X11:
369          *  - When you create a window with position (x,y) and size
370          *    (w,h), the upper left hand corner of the outside of the
371          *    window is at (x,y) and the size of the drawable area  is
372          *    (w,h).
373          *  - When you query the size and position of the window--as
374          *    is happening here for Windows--"freeglut" will return
375          *    the size of the drawable area--the (w,h) that you
376          *    specified when you created the window--and the coordinates
377          *    of the upper left hand corner of the drawable
378          *    area--which is NOT the (x,y) you specified.
379          */
380
381         RECT winRect;
382
383         freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
384
385         /*
386          * We need to call GetWindowRect() first...
387          *  (this returns the pixel coordinates of the outside of the window)
388          */
389         GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect );
390
391         /* ...then we've got to correct the results we've just received... */
392
393 #if !defined(_WIN32_WCE)
394         if ( ( fgStructure.GameModeWindow != fgStructure.CurrentWindow ) && ( fgStructure.CurrentWindow->Parent == NULL ) &&
395              ( ! fgStructure.CurrentWindow->IsMenu ) )
396         {
397           winRect.left   += GetSystemMetrics( SM_CXSIZEFRAME );
398           winRect.right  -= GetSystemMetrics( SM_CXSIZEFRAME );
399           winRect.top    += GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION );
400           winRect.bottom -= GetSystemMetrics( SM_CYSIZEFRAME );
401         }
402 #endif /* !defined(_WIN32_WCE) */
403
404         switch( eWhat )
405         {
406         case GLUT_WINDOW_X:      return winRect.left                ;
407         case GLUT_WINDOW_Y:      return winRect.top                 ;
408         case GLUT_WINDOW_WIDTH:  return winRect.right - winRect.left;
409         case GLUT_WINDOW_HEIGHT: return winRect.bottom - winRect.top;
410         }
411     }
412     break;
413
414     case GLUT_WINDOW_BORDER_WIDTH :
415 #if defined(_WIN32_WCE)
416         return 0;
417 #else
418         return GetSystemMetrics( SM_CXSIZEFRAME );
419 #endif /* !defined(_WIN32_WCE) */
420
421     case GLUT_WINDOW_HEADER_HEIGHT :
422 #if defined(_WIN32_WCE)
423         return 0;
424 #else
425         return GetSystemMetrics( SM_CYCAPTION );
426 #endif /* defined(_WIN32_WCE) */
427
428     case GLUT_DISPLAY_MODE_POSSIBLE:
429 #if defined(_WIN32_WCE)
430         return 0;
431 #else
432         return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
433                                     PFD_MAIN_PLANE );
434 #endif /* defined(_WIN32_WCE) */
435
436
437     case GLUT_WINDOW_FORMAT_ID:
438 #if !defined(_WIN32_WCE)
439         if( fgStructure.CurrentWindow != NULL )
440             return GetPixelFormat( fgStructure.CurrentWindow->Window.Device );
441 #endif /* defined(_WIN32_WCE) */
442         return 0;
443
444 #endif
445
446     /* The window structure queries */
447     case GLUT_WINDOW_PARENT:
448         if( fgStructure.CurrentWindow         == NULL ) return 0;
449         if( fgStructure.CurrentWindow->Parent == NULL ) return 0;
450         return fgStructure.CurrentWindow->Parent->ID;
451
452     case GLUT_WINDOW_NUM_CHILDREN:
453         if( fgStructure.CurrentWindow == NULL )
454             return 0;
455         return fgListLength( &fgStructure.CurrentWindow->Children );
456
457     case GLUT_WINDOW_CURSOR:
458         if( fgStructure.CurrentWindow == NULL )
459             return 0;
460         return fgStructure.CurrentWindow->State.Cursor;
461
462     case GLUT_MENU_NUM_ITEMS:
463         if( fgStructure.CurrentMenu == NULL )
464             return 0;
465         return fgListLength( &fgStructure.CurrentMenu->Entries );
466
467     case GLUT_ACTION_ON_WINDOW_CLOSE:
468         return fgState.ActionOnWindowClose;
469
470     case GLUT_VERSION :
471         return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH;
472
473     case GLUT_RENDERING_CONTEXT:
474         return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
475                                          : GLUT_CREATE_NEW_CONTEXT;
476
477     case GLUT_DIRECT_RENDERING:
478         return fgState.DirectContext;
479         break;
480
481     default:
482         fgWarning( "glutGet(): missing enum handle %d", eWhat );
483         break;
484     }
485     return -1;
486 }
487
488 /*
489  * Returns various device information.
490  */
491 int FGAPIENTRY glutDeviceGet( GLenum eWhat )
492 {
493     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDeviceGet" );
494
495     /* XXX WARNING: we are mostly lying in this function. */
496     switch( eWhat )
497     {
498     case GLUT_HAS_KEYBOARD:
499         /*
500          * Win32 is assumed a keyboard, and this cannot be queried,
501          * except for WindowsCE.
502          *
503          * X11 has a core keyboard by definition, although it can
504          * be present as a virtual/dummy keyboard. For now, there
505          * is no reliable way to tell if a real keyboard is present.
506          */
507 #if defined(_WIN32_CE)
508         return ( GetKeyboardStatus() & KBDI_KEYBOARD_PRESENT ) ? 1 : 0;
509 #   if FREEGLUT_LIB_PRAGMAS
510 #       pragma comment (lib,"Kbdui.lib")
511 #   endif
512
513 #else
514         return 1;
515 #endif
516
517 #if TARGET_HOST_POSIX_X11
518
519     /* X11 has a mouse by definition */
520     case GLUT_HAS_MOUSE:
521         return 1 ;
522
523     case GLUT_NUM_MOUSE_BUTTONS:
524         /* We should be able to pass NULL when the last argument is zero,
525          * but at least one X server has a bug where this causes a segfault.
526          *
527          * In XFree86/Xorg servers, a mouse wheel is seen as two buttons
528          * rather than an Axis; "freeglut_main.c" expects this when
529          * checking for a wheel event.
530          */
531         {
532             unsigned char map;
533             int nbuttons = XGetPointerMapping(fgDisplay.Display, &map,0);
534             return nbuttons;
535         }
536
537 #elif TARGET_HOST_MS_WINDOWS
538
539     case GLUT_HAS_MOUSE:
540         /*
541          * MS Windows can be booted without a mouse.
542          */
543         return GetSystemMetrics( SM_MOUSEPRESENT );
544
545     case GLUT_NUM_MOUSE_BUTTONS:
546 #  if defined(_WIN32_WCE)
547         return 1;
548 #  else
549         return GetSystemMetrics( SM_CMOUSEBUTTONS );
550 #  endif
551 #endif
552
553     case GLUT_HAS_JOYSTICK:
554         return fgJoystickDetect ();
555
556     case GLUT_OWNS_JOYSTICK:
557         return fgState.JoysticksInitialised;
558
559     case GLUT_JOYSTICK_POLL_RATE:
560         return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.JoystickPollRate : 0;
561
562     /* XXX The following two are only for Joystick 0 but this is an improvement */
563     case GLUT_JOYSTICK_BUTTONS:
564         return glutJoystickGetNumButtons ( 0 );
565
566     case GLUT_JOYSTICK_AXES:
567         return glutJoystickGetNumAxes ( 0 );
568
569     case GLUT_HAS_DIAL_AND_BUTTON_BOX:
570         return fgInputDeviceDetect ();
571
572     case GLUT_NUM_DIALS:
573         if ( fgState.InputDevsInitialised ) return 8;
574         return 0;
575  
576     case GLUT_NUM_BUTTON_BOX_BUTTONS:
577         return 0;
578
579     case GLUT_HAS_SPACEBALL:
580     case GLUT_HAS_TABLET:
581         return 0;
582
583     case GLUT_NUM_SPACEBALL_BUTTONS:
584     case GLUT_NUM_TABLET_BUTTONS:
585         return 0;
586
587     case GLUT_DEVICE_IGNORE_KEY_REPEAT:
588         return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.IgnoreKeyRepeat : 0;
589
590     case GLUT_DEVICE_KEY_REPEAT:
591         return fgState.KeyRepeat;
592
593     default:
594         fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
595         break;
596     }
597
598     /* And now -- the failure. */
599     return -1;
600 }
601
602 /*
603  * This should return the current state of ALT, SHIFT and CTRL keys.
604  */
605 int FGAPIENTRY glutGetModifiers( void )
606 {
607     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
608     if( fgState.Modifiers == INVALID_MODIFIERS )
609     {
610         fgWarning( "glutGetModifiers() called outside an input callback" );
611         return 0;
612     }
613
614     return fgState.Modifiers;
615 }
616
617 /*
618  * Return the state of the GLUT API overlay subsystem. A misery ;-)
619  */
620 int FGAPIENTRY glutLayerGet( GLenum eWhat )
621 {
622     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLayerGet" );
623
624     /*
625      * This is easy as layers are not implemented ;-)
626      *
627      * XXX Can we merge the UNIX/X11 and WIN32 sections?  Or
628      * XXX is overlay support planned?
629      */
630     switch( eWhat )
631     {
632
633 #if TARGET_HOST_POSIX_X11
634
635     case GLUT_OVERLAY_POSSIBLE:
636         return 0;
637
638     case GLUT_LAYER_IN_USE:
639         return GLUT_NORMAL;
640
641     case GLUT_HAS_OVERLAY:
642         return 0;
643
644     case GLUT_TRANSPARENT_INDEX:
645         /*
646          * Return just anything, which is always defined as zero
647          *
648          * XXX HUH?
649          */
650         return 0;
651
652     case GLUT_NORMAL_DAMAGED:
653         /* XXX Actually I do not know. Maybe. */
654         return 0;
655
656     case GLUT_OVERLAY_DAMAGED:
657         return -1;
658
659 #elif TARGET_HOST_MS_WINDOWS
660
661     case GLUT_OVERLAY_POSSIBLE:
662 /*      return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
663                                    PFD_OVERLAY_PLANE ); */
664       return 0 ;
665
666     case GLUT_LAYER_IN_USE:
667         return GLUT_NORMAL;
668
669     case GLUT_HAS_OVERLAY:
670         return 0;
671
672     case GLUT_TRANSPARENT_INDEX:
673         /*
674          * Return just anything, which is always defined as zero
675          *
676          * XXX HUH?
677          */
678         return 0;
679
680     case GLUT_NORMAL_DAMAGED:
681         /* XXX Actually I do not know. Maybe. */
682         return 0;
683
684     case GLUT_OVERLAY_DAMAGED:
685         return -1;
686 #endif
687
688     default:
689         fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
690         break;
691     }
692
693     /* And fail. That's good. Programs do love failing. */
694     return -1;
695 }
696
697 /*** END OF FILE ***/