Adding initialization checking to all GLUT interface functions and removing asserts...
[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 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31
32 #include <GL/freeglut.h>
33 #include "freeglut_internal.h"
34
35 /*
36  * TODO BEFORE THE STABLE RELEASE:
37  *
38  *  glutGet()               -- X11 tests passed, but check if all enums
39  *                             handled (what about Win32?)
40  *  glutDeviceGet()         -- X11 tests passed, but check if all enums
41  *                             handled (what about Win32?)
42  *  glutGetModifiers()      -- OK, but could also remove the limitation
43  *  glutLayerGet()          -- what about GLUT_NORMAL_DAMAGED?
44  *
45  * The fail-on-call policy will help adding the most needed things imho.
46  */
47
48 /* -- LOCAL DEFINITIONS ---------------------------------------------------- */
49
50 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
51
52 #if TARGET_HOST_UNIX_X11
53 /*
54  * Queries the GL context about some attributes
55  */
56 static int fghGetConfig( int attribute )
57 {
58   int returnValue = 0;
59
60   if( fgStructure.Window )
61       glXGetConfig( fgDisplay.Display, fgStructure.Window->Window.VisualInfo,
62                     attribute, &returnValue );
63
64   return returnValue;
65 }
66 #endif
67
68 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
69
70 /*
71  * General settings assignment method
72  */
73 void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
74 {
75     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetOption" );
76
77     /*
78      * XXX In chronological code add order.  (WHY in that order?)
79      */
80     switch( eWhat )
81     {
82     case GLUT_INIT_WINDOW_X:
83         fgState.Position.X = (GLint)value;
84         break;
85
86     case GLUT_INIT_WINDOW_Y:
87         fgState.Position.Y = (GLint)value;
88         break;
89
90     case GLUT_INIT_WINDOW_WIDTH:
91         fgState.Size.X = (GLint)value;
92         break;
93
94     case GLUT_INIT_WINDOW_HEIGHT:
95         fgState.Size.Y = (GLint)value;
96         break;
97
98     case GLUT_INIT_DISPLAY_MODE:
99         fgState.DisplayMode = (unsigned int)value;
100         break;
101
102     case GLUT_ACTION_ON_WINDOW_CLOSE:
103         fgState.ActionOnWindowClose = value;
104         break;
105
106     case GLUT_RENDERING_CONTEXT:
107         fgState.UseCurrentContext =
108             ( value == GLUT_USE_CURRENT_CONTEXT ) ? GL_TRUE : GL_FALSE;
109         break;
110
111     case GLUT_DIRECT_RENDERING:
112         fgState.DirectContext = value;
113         break;
114
115     case GLUT_WINDOW_CURSOR:
116         if( fgStructure.Window != NULL )
117             fgStructure.Window->State.Cursor = value;
118         break;
119
120     default:
121         fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
122         break;
123     }
124 }
125
126 /*
127  * General settings query method
128  */
129 int FGAPIENTRY glutGet( GLenum eWhat )
130 {
131 #if TARGET_HOST_WIN32 || TARGET_HOST_WINCE
132     int returnValue ;
133     GLboolean boolValue ;
134 #endif
135
136     switch (eWhat)
137     {
138     case GLUT_INIT_STATE:
139         return fgState.Initialised;
140
141     case GLUT_ELAPSED_TIME:
142         return fgElapsedTime();
143     }
144
145     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGet" );
146
147     /* XXX In chronological code add order.  (WHY in that order?) */
148     switch( eWhat )
149     {
150     /* Following values are stored in fgState and fgDisplay global structures */
151     case GLUT_SCREEN_WIDTH:         return fgDisplay.ScreenWidth   ;
152     case GLUT_SCREEN_HEIGHT:        return fgDisplay.ScreenHeight  ;
153     case GLUT_SCREEN_WIDTH_MM:      return fgDisplay.ScreenWidthMM ;
154     case GLUT_SCREEN_HEIGHT_MM:     return fgDisplay.ScreenHeightMM;
155     case GLUT_INIT_WINDOW_X:        return fgState.Position.X      ;
156     case GLUT_INIT_WINDOW_Y:        return fgState.Position.Y      ;
157     case GLUT_INIT_WINDOW_WIDTH:    return fgState.Size.X          ;
158     case GLUT_INIT_WINDOW_HEIGHT:   return fgState.Size.Y          ;
159     case GLUT_INIT_DISPLAY_MODE:    return fgState.DisplayMode     ;
160
161     /*
162      * The window/context specific queries are handled mostly by
163      * fghGetConfig().
164      */
165     case GLUT_WINDOW_NUM_SAMPLES:
166         /* XXX Multisampling. Return what I know about multisampling. */
167         return 0;
168
169 #if TARGET_HOST_UNIX_X11
170     /*
171      * The rest of GLX queries under X are general enough to use a macro to
172      * check them
173      */
174 #   define GLX_QUERY(a,b) case a: return fghGetConfig( b );
175
176     GLX_QUERY( GLUT_WINDOW_RGBA,                GLX_RGBA                );
177     GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER,        GLX_DOUBLEBUFFER        );
178     GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE,         GLX_BUFFER_SIZE         );
179     GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE,        GLX_STENCIL_SIZE        );
180     GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE,          GLX_DEPTH_SIZE          );
181     GLX_QUERY( GLUT_WINDOW_RED_SIZE,            GLX_RED_SIZE            );
182     GLX_QUERY( GLUT_WINDOW_GREEN_SIZE,          GLX_GREEN_SIZE          );
183     GLX_QUERY( GLUT_WINDOW_BLUE_SIZE,           GLX_BLUE_SIZE           );
184     GLX_QUERY( GLUT_WINDOW_ALPHA_SIZE,          GLX_ALPHA_SIZE          );
185     GLX_QUERY( GLUT_WINDOW_ACCUM_RED_SIZE,      GLX_ACCUM_RED_SIZE      );
186     GLX_QUERY( GLUT_WINDOW_ACCUM_GREEN_SIZE,    GLX_ACCUM_GREEN_SIZE    );
187     GLX_QUERY( GLUT_WINDOW_ACCUM_BLUE_SIZE,     GLX_ACCUM_BLUE_SIZE     );
188     GLX_QUERY( GLUT_WINDOW_ACCUM_ALPHA_SIZE,    GLX_ACCUM_ALPHA_SIZE    );
189     GLX_QUERY( GLUT_WINDOW_STEREO,              GLX_STEREO              );
190
191 #   undef GLX_QUERY
192
193     /* Colormap size is handled in a bit different way than all the rest */
194     case GLUT_WINDOW_COLORMAP_SIZE:
195         if( (fghGetConfig( GLX_RGBA )) || (fgStructure.Window == NULL) )
196         {
197             /*
198              * We've got a RGBA visual, so there is no colormap at all.
199              * The other possibility is that we have no current window set.
200              */
201             return 0;
202         }
203         return fgStructure.Window->Window.VisualInfo->visual->map_entries;
204
205     /*
206      * Those calls are somewhat similiar, as they use XGetWindowAttributes()
207      * function
208      */
209     case GLUT_WINDOW_X:
210     case GLUT_WINDOW_Y:
211     case GLUT_WINDOW_BORDER_WIDTH:
212     case GLUT_WINDOW_HEADER_HEIGHT:
213     {
214         int x, y;
215         Window w;
216
217         if( fgStructure.Window == NULL )
218             return 0;
219
220         XTranslateCoordinates(
221             fgDisplay.Display,
222             fgStructure.Window->Window.Handle,
223             fgDisplay.RootWindow,
224             0, 0, &x, &y, &w);
225
226         switch ( eWhat )
227         {
228         case GLUT_WINDOW_X: return x;
229         case GLUT_WINDOW_Y: return y;
230         }
231
232         if ( w == 0 )
233             return 0;
234         XTranslateCoordinates(
235             fgDisplay.Display,
236             fgStructure.Window->Window.Handle,
237             w, 0, 0, &x, &y, &w);
238
239         switch ( eWhat )
240         {
241         case GLUT_WINDOW_BORDER_WIDTH:  return x;
242         case GLUT_WINDOW_HEADER_HEIGHT: return y;
243         }
244     }
245
246     case GLUT_WINDOW_WIDTH:
247     case GLUT_WINDOW_HEIGHT:
248     {
249         XWindowAttributes winAttributes;
250
251         if( fgStructure.Window == NULL )
252             return 0;
253         XGetWindowAttributes(
254             fgDisplay.Display,
255             fgStructure.Window->Window.Handle,
256             &winAttributes
257         );
258         switch ( eWhat )
259         {
260         case GLUT_WINDOW_WIDTH:            return winAttributes.width ;
261         case GLUT_WINDOW_HEIGHT:           return winAttributes.height ;
262         }
263     }
264
265     /* I do not know yet if there will be a fgChooseVisual() function for Win32 */
266     case GLUT_DISPLAY_MODE_POSSIBLE:
267         return( fgChooseVisual() == NULL ? 0 : 1 );
268
269     /* This is system-dependant */
270     case GLUT_WINDOW_FORMAT_ID:
271         if( fgStructure.Window == NULL )
272             return 0;
273
274         return fgStructure.Window->Window.VisualInfo->visualid;
275
276 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
277
278     /* Handle the OpenGL inquiries */
279     case GLUT_WINDOW_RGBA:
280       glGetBooleanv ( GL_RGBA_MODE, &boolValue );
281       returnValue = boolValue ? 1 : 0;
282       return returnValue;
283     case GLUT_WINDOW_DOUBLEBUFFER:
284       glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue );
285       returnValue = boolValue ? 1 : 0;
286       return returnValue;
287     case GLUT_WINDOW_STEREO:
288       glGetBooleanv ( GL_STEREO, &boolValue );
289       returnValue = boolValue ? 1 : 0;
290       return returnValue;
291
292     case GLUT_WINDOW_RED_SIZE:
293       glGetIntegerv ( GL_RED_BITS, &returnValue );
294       return returnValue;
295     case GLUT_WINDOW_GREEN_SIZE:
296       glGetIntegerv ( GL_GREEN_BITS, &returnValue );
297       return returnValue;
298     case GLUT_WINDOW_BLUE_SIZE:
299       glGetIntegerv ( GL_BLUE_BITS, &returnValue );
300       return returnValue;
301     case GLUT_WINDOW_ALPHA_SIZE:
302       glGetIntegerv ( GL_ALPHA_BITS, &returnValue );
303       return returnValue;
304     case GLUT_WINDOW_ACCUM_RED_SIZE:
305       glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue );
306       return returnValue;
307     case GLUT_WINDOW_ACCUM_GREEN_SIZE:
308       glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue );
309       return returnValue;
310     case GLUT_WINDOW_ACCUM_BLUE_SIZE:
311       glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue );
312       return returnValue;
313     case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
314       glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue );
315       return returnValue;
316     case GLUT_WINDOW_DEPTH_SIZE:
317       glGetIntegerv ( GL_DEPTH_BITS, &returnValue );
318       return returnValue;
319
320     case GLUT_WINDOW_BUFFER_SIZE:
321       returnValue = 1 ;                                      /* ????? */
322       return returnValue;
323     case GLUT_WINDOW_STENCIL_SIZE:
324       returnValue = 0 ;                                      /* ????? */
325       return returnValue;
326
327     case GLUT_WINDOW_X:
328     case GLUT_WINDOW_Y:
329     case GLUT_WINDOW_WIDTH:
330     case GLUT_WINDOW_HEIGHT:
331     {
332         /*
333          *  There is considerable confusion about the "right thing to
334          *  do" concerning window  size and position.  GLUT itself is
335          *  not consistent between Windows and UNIX/X11; since
336          *  platform independence is a virtue for "freeglut", we
337          *  decided to break with GLUT's behaviour.
338          *
339          *  Under UNIX/X11, it is apparently not possible to get the
340          *  window border sizes in order to subtract them off the
341          *  window's initial position until some time after the window
342          *  has been created.  Therefore we decided on the following
343          *  behaviour, both under Windows and under UNIX/X11:
344          *  - When you create a window with position (x,y) and size
345          *    (w,h), the upper left hand corner of the outside of the
346          *    window is at (x,y) and the size of the drawable area  is
347          *    (w,h).
348          *  - When you query the size and position of the window--as
349          *    is happening here for Windows--"freeglut" will return
350          *    the size of the drawable area--the (w,h) that you
351          *    specified when you created the window--and the coordinates
352          *    of the upper left hand corner of the drawable
353          *    area--which is NOT the (x,y) you specified.
354          */
355
356         RECT winRect;
357
358         freeglut_return_val_if_fail( fgStructure.Window != NULL, 0 );
359
360         /*
361          * We need to call GetWindowRect() first...
362          *  (this returns the pixel coordinates of the outside of the window)
363          */
364         GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
365
366         /* ...then we've got to correct the results we've just received... */
367
368 #if !TARGET_HOST_WINCE
369         if ( ( fgStructure.GameMode != fgStructure.Window ) && ( fgStructure.Window->Parent == NULL ) &&
370              ( ! fgStructure.Window->IsMenu ) )
371         {
372           winRect.left   += GetSystemMetrics( SM_CXSIZEFRAME );
373           winRect.right  -= GetSystemMetrics( SM_CXSIZEFRAME );
374           winRect.top    += GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION );
375           winRect.bottom -= GetSystemMetrics( SM_CYSIZEFRAME );
376         }
377 #endif /* !TARGET_HOST_WINCE */
378
379         switch( eWhat )
380         {
381         case GLUT_WINDOW_X:      return winRect.left                ;
382         case GLUT_WINDOW_Y:      return winRect.top                 ;
383         case GLUT_WINDOW_WIDTH:  return winRect.right - winRect.left;
384         case GLUT_WINDOW_HEIGHT: return winRect.bottom - winRect.top;
385         }
386     }
387     break;
388
389     case GLUT_WINDOW_BORDER_WIDTH :
390 #if TARGET_HOST_WINCE
391         return 0;
392 #else
393         return GetSystemMetrics( SM_CXSIZEFRAME );
394 #endif /* !TARGET_HOST_WINCE */
395
396     case GLUT_WINDOW_HEADER_HEIGHT :
397 #if TARGET_HOST_WINCE
398         return 0;
399 #else
400         return GetSystemMetrics( SM_CYCAPTION );
401 #endif /* TARGET_HOST_WINCE */
402
403     case GLUT_DISPLAY_MODE_POSSIBLE:
404 #if TARGET_HOST_WINCE
405         return GL_FALSE;
406 #else
407         return fgSetupPixelFormat( fgStructure.Window, GL_TRUE,
408                                     PFD_MAIN_PLANE );
409 #endif /* TARGET_HOST_WINCE */
410
411
412     case GLUT_WINDOW_FORMAT_ID:
413 #if !TARGET_HOST_WINCE
414         if( fgStructure.Window != NULL )
415             return GetPixelFormat( fgStructure.Window->Window.Device );
416 #endif /* TARGET_HOST_WINCE */
417         return 0;
418
419 #endif
420
421     /* The window structure queries */
422     case GLUT_WINDOW_PARENT:
423         if( fgStructure.Window         == NULL ) return 0;
424         if( fgStructure.Window->Parent == NULL ) return 0;
425         return fgStructure.Window->Parent->ID;
426
427     case GLUT_WINDOW_NUM_CHILDREN:
428         if( fgStructure.Window == NULL )
429             return 0;
430         return fgListLength( &fgStructure.Window->Children );
431
432     case GLUT_WINDOW_CURSOR:
433         if( fgStructure.Window == NULL )
434             return 0;
435         return fgStructure.Window->State.Cursor;
436
437     case GLUT_MENU_NUM_ITEMS:
438         if( fgStructure.Menu == NULL )
439             return 0;
440         return fgListLength( &fgStructure.Menu->Entries );
441
442     case GLUT_ACTION_ON_WINDOW_CLOSE:
443         return fgState.ActionOnWindowClose;
444
445     case GLUT_VERSION :
446         return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH;
447
448     case GLUT_RENDERING_CONTEXT:
449         return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
450                                          : GLUT_CREATE_NEW_CONTEXT;
451
452     case GLUT_DIRECT_RENDERING:
453         return fgState.DirectContext;
454         break;
455
456     default:
457         fgWarning( "glutGet(): missing enum handle %d", eWhat );
458         break;
459     }
460     return -1;
461 }
462
463 /*
464  * Returns various device information.
465  */
466 int FGAPIENTRY glutDeviceGet( GLenum eWhat )
467 {
468     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDeviceGet" );
469
470     /* XXX WARNING: we are mostly lying in this function. */
471     switch( eWhat )
472     {
473     case GLUT_HAS_KEYBOARD:
474         /*
475          * We always have a keyboard present on PC machines...
476          *
477          * XXX I think that some of my PCs will boot without a keyboard.
478          * XXX Also, who says that we are running on a PC?  UNIX/X11
479          * XXX is much more generic, and X11 can go over a network.
480          * XXX Though in actuality, we can probably assume BOTH a
481          * XXX mouse and keyboard for most/all of our users.
482          */
483         return TRUE ;
484
485 #if TARGET_HOST_UNIX_X11
486
487     case GLUT_HAS_MOUSE:
488         return TRUE ;
489
490     case GLUT_NUM_MOUSE_BUTTONS:
491         /*
492          * Return the number of mouse buttons available. This is a big guess.
493          *
494          * XXX We can probe /var/run/dmesg.boot which is world-readable.
495          * XXX This would be somewhat system-dependant, but is doable.
496          * XXX E.g., on NetBSD, my USB mouse registers:
497          * XXX   ums0 at uhidev0: 3 buttons and Z dir.
498          * XXX We can also probe /var/log/XFree86\..*\.log to get
499          * XXX lines such as:
500          * XXX   (**) Option "Buttons" "5"
501          * XXX   (**) Option "ZAxisMapping" "4 5"
502          * XXX   (**) Mouse0: ZAxisMapping: buttons 4 and 5
503          * XXX   (**) Mouse0: Buttons: 5
504          * XXX ...which tells us even more, and is a bit less
505          * XXX system-dependant.  (Other than MS-WINDOWS, all
506          * XXX target hosts with actual users are probably running
507          * XXX XFree86...)  It is at least worth taking a look at
508          * XXX this file.
509          */
510         return 3 ;
511
512 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
513
514     case GLUT_HAS_MOUSE:
515         /*
516          * The Windows can be booted without a mouse.
517          * It would be nice to have this reported.
518          */
519         return GetSystemMetrics( SM_MOUSEPRESENT );
520
521     case GLUT_NUM_MOUSE_BUTTONS:
522         /* We are much more fortunate under Win32 about this... */
523 #if TARGET_HOST_WINCE
524         return 1;
525 #else
526         return GetSystemMetrics( SM_CMOUSEBUTTONS );
527 #endif /* TARGET_HOST_WINCE */
528
529 #endif
530
531     case GLUT_HAS_JOYSTICK:
532         return fgJoystickDetect ();
533
534     case GLUT_OWNS_JOYSTICK:
535         return fgState.JoysticksInitialised;
536
537     case GLUT_JOYSTICK_POLL_RATE:
538         return fgStructure.Window ? fgStructure.Window->State.JoystickPollRate : 0;
539
540     /* XXX The following two are only for Joystick 0 but this is an improvement */
541     case GLUT_JOYSTICK_BUTTONS:
542         return glutJoystickGetNumButtons ( 0 );
543
544     case GLUT_JOYSTICK_AXES:
545         return glutJoystickGetNumAxes ( 0 );
546
547     case GLUT_HAS_SPACEBALL:
548     case GLUT_HAS_DIAL_AND_BUTTON_BOX:
549     case GLUT_HAS_TABLET:
550         return FALSE;
551
552     case GLUT_NUM_SPACEBALL_BUTTONS:
553     case GLUT_NUM_BUTTON_BOX_BUTTONS:
554     case GLUT_NUM_DIALS:
555     case GLUT_NUM_TABLET_BUTTONS:
556         return 0;
557
558     case GLUT_DEVICE_IGNORE_KEY_REPEAT:
559         return fgStructure.Window ? fgStructure.Window->State.IgnoreKeyRepeat : 0;
560
561     case GLUT_DEVICE_KEY_REPEAT:
562         /* XXX WARNING: THIS IS A BIG LIE! */
563         return GLUT_KEY_REPEAT_DEFAULT;
564
565     default:
566         fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
567         break;
568     }
569
570     /* And now -- the failure. */
571     return -1;
572 }
573
574 /*
575  * This should return the current state of ALT, SHIFT and CTRL keys.
576  */
577 int FGAPIENTRY glutGetModifiers( void )
578 {
579     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
580     if( fgState.Modifiers == 0xffffffff )
581     {
582         fgWarning( "glutGetModifiers() called outside an input callback" );
583         return 0;
584     }
585
586     return fgState.Modifiers;
587 }
588
589 /*
590  * Return the state of the GLUT API overlay subsystem. A misery ;-)
591  */
592 int FGAPIENTRY glutLayerGet( GLenum eWhat )
593 {
594     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLayerGet" );
595
596     /*
597      * This is easy as layers are not implemented ;-)
598      *
599      * XXX Can we merge the UNIX/X11 and WIN32 sections?  Or
600      * XXX is overlay support planned?
601      */
602     switch( eWhat )
603     {
604
605 #if TARGET_HOST_UNIX_X11
606
607     case GLUT_OVERLAY_POSSIBLE:
608         return FALSE;
609
610     case GLUT_LAYER_IN_USE:
611         return GLUT_NORMAL;
612
613     case GLUT_HAS_OVERLAY:
614         return FALSE;
615
616     case GLUT_TRANSPARENT_INDEX:
617         /*
618          * Return just anything, which is always defined as zero
619          *
620          * XXX HUH?
621          */
622         return 0;
623
624     case GLUT_NORMAL_DAMAGED:
625         /* XXX Actually I do not know. Maybe. */
626         return FALSE;
627
628     case GLUT_OVERLAY_DAMAGED:
629         return -1;
630
631 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
632
633     case GLUT_OVERLAY_POSSIBLE:
634 /*      return fgSetupPixelFormat( fgStructure.Window, GL_TRUE,
635                                    PFD_OVERLAY_PLANE ); */
636       return FALSE ;
637
638     case GLUT_LAYER_IN_USE:
639         return GLUT_NORMAL;
640
641     case GLUT_HAS_OVERLAY:
642         return FALSE;
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 FALSE;
655
656     case GLUT_OVERLAY_DAMAGED:
657         return -1;
658 #endif
659
660     default:
661         fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
662         break;
663     }
664
665     /* And fail. That's good. Programs do love failing. */
666     return -1;
667 }
668
669 /*** END OF FILE ***/