535569232b7500da719f3e0b28f0fcdfb7b5af0a
[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.X      ;
163     case GLUT_INIT_WINDOW_Y:        return fgState.Position.Y      ;
164     case GLUT_INIT_WINDOW_WIDTH:    return fgState.Size.X          ;
165     case GLUT_INIT_WINDOW_HEIGHT:   return fgState.Size.Y          ;
166     case GLUT_INIT_DISPLAY_MODE:    return fgState.DisplayMode     ;
167
168 #if TARGET_HOST_POSIX_X11
169     /*
170      * The window/context specific queries are handled mostly by
171      * fghGetConfig().
172      */
173     case GLUT_WINDOW_NUM_SAMPLES:
174 #ifdef GLX_VERSION_1_3
175         glGetIntegerv(GL_SAMPLES, &nsamples);
176 #endif
177         return nsamples;
178
179     /*
180      * The rest of GLX queries under X are general enough to use a macro to
181      * check them
182      */
183 #   define GLX_QUERY(a,b) case a: return fghGetConfig( b );
184
185     GLX_QUERY( GLUT_WINDOW_RGBA,                GLX_RGBA                );
186     GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER,        GLX_DOUBLEBUFFER        );
187     GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE,         GLX_BUFFER_SIZE         );
188     GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE,        GLX_STENCIL_SIZE        );
189     GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE,          GLX_DEPTH_SIZE          );
190     GLX_QUERY( GLUT_WINDOW_RED_SIZE,            GLX_RED_SIZE            );
191     GLX_QUERY( GLUT_WINDOW_GREEN_SIZE,          GLX_GREEN_SIZE          );
192     GLX_QUERY( GLUT_WINDOW_BLUE_SIZE,           GLX_BLUE_SIZE           );
193     GLX_QUERY( GLUT_WINDOW_ALPHA_SIZE,          GLX_ALPHA_SIZE          );
194     GLX_QUERY( GLUT_WINDOW_ACCUM_RED_SIZE,      GLX_ACCUM_RED_SIZE      );
195     GLX_QUERY( GLUT_WINDOW_ACCUM_GREEN_SIZE,    GLX_ACCUM_GREEN_SIZE    );
196     GLX_QUERY( GLUT_WINDOW_ACCUM_BLUE_SIZE,     GLX_ACCUM_BLUE_SIZE     );
197     GLX_QUERY( GLUT_WINDOW_ACCUM_ALPHA_SIZE,    GLX_ACCUM_ALPHA_SIZE    );
198     GLX_QUERY( GLUT_WINDOW_STEREO,              GLX_STEREO              );
199
200 #   undef GLX_QUERY
201
202     /* Colormap size is handled in a bit different way than all the rest */
203     case GLUT_WINDOW_COLORMAP_SIZE:
204         if( (fghGetConfig( GLX_RGBA )) || (fgStructure.CurrentWindow == NULL) )
205         {
206             /*
207              * We've got a RGBA visual, so there is no colormap at all.
208              * The other possibility is that we have no current window set.
209              */
210             return 0;
211         }
212         return fgStructure.CurrentWindow->Window.VisualInfo->visual->map_entries;
213
214     /*
215      * Those calls are somewhat similiar, as they use XGetWindowAttributes()
216      * function
217      */
218     case GLUT_WINDOW_X:
219     case GLUT_WINDOW_Y:
220     case GLUT_WINDOW_BORDER_WIDTH:
221     case GLUT_WINDOW_HEADER_HEIGHT:
222     {
223         int x, y;
224         Window w;
225
226         if( fgStructure.CurrentWindow == NULL )
227             return 0;
228
229         XTranslateCoordinates(
230             fgDisplay.Display,
231             fgStructure.CurrentWindow->Window.Handle,
232             fgDisplay.RootWindow,
233             0, 0, &x, &y, &w);
234
235         switch ( eWhat )
236         {
237         case GLUT_WINDOW_X: return x;
238         case GLUT_WINDOW_Y: return y;
239         }
240
241         if ( w == 0 )
242             return 0;
243         XTranslateCoordinates(
244             fgDisplay.Display,
245             fgStructure.CurrentWindow->Window.Handle,
246             w, 0, 0, &x, &y, &w);
247
248         switch ( eWhat )
249         {
250         case GLUT_WINDOW_BORDER_WIDTH:  return x;
251         case GLUT_WINDOW_HEADER_HEIGHT: return y;
252         }
253     }
254
255     case GLUT_WINDOW_WIDTH:
256     case GLUT_WINDOW_HEIGHT:
257     {
258         XWindowAttributes winAttributes;
259
260         if( fgStructure.CurrentWindow == NULL )
261             return 0;
262         XGetWindowAttributes(
263             fgDisplay.Display,
264             fgStructure.CurrentWindow->Window.Handle,
265             &winAttributes
266         );
267         switch ( eWhat )
268         {
269         case GLUT_WINDOW_WIDTH:            return winAttributes.width ;
270         case GLUT_WINDOW_HEIGHT:           return winAttributes.height ;
271         }
272     }
273
274     /* I do not know yet if there will be a fgChooseVisual() function for Win32 */
275     case GLUT_DISPLAY_MODE_POSSIBLE:
276     {
277         XVisualInfo* visualInfo = fgChooseVisual();
278         if ( visualInfo == NULL ) {
279             return 0;
280         } else {
281             XFree( visualInfo );
282             return 1;
283         }
284     }
285
286     /* This is system-dependant */
287     case GLUT_WINDOW_FORMAT_ID:
288         if( fgStructure.CurrentWindow == NULL )
289             return 0;
290
291         return fgStructure.CurrentWindow->Window.VisualInfo->visualid;
292
293 #elif TARGET_HOST_MS_WINDOWS
294
295     case GLUT_WINDOW_NUM_SAMPLES:
296       glGetIntegerv(WGL_SAMPLES_ARB, &nsamples);
297       return nsamples;
298
299     /* Handle the OpenGL inquiries */
300     case GLUT_WINDOW_RGBA:
301       glGetBooleanv ( GL_RGBA_MODE, &boolValue );
302       returnValue = boolValue ? 1 : 0;
303       return returnValue;
304     case GLUT_WINDOW_DOUBLEBUFFER:
305       glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue );
306       returnValue = boolValue ? 1 : 0;
307       return returnValue;
308     case GLUT_WINDOW_STEREO:
309       glGetBooleanv ( GL_STEREO, &boolValue );
310       returnValue = boolValue ? 1 : 0;
311       return returnValue;
312
313     case GLUT_WINDOW_RED_SIZE:
314       glGetIntegerv ( GL_RED_BITS, &returnValue );
315       return returnValue;
316     case GLUT_WINDOW_GREEN_SIZE:
317       glGetIntegerv ( GL_GREEN_BITS, &returnValue );
318       return returnValue;
319     case GLUT_WINDOW_BLUE_SIZE:
320       glGetIntegerv ( GL_BLUE_BITS, &returnValue );
321       return returnValue;
322     case GLUT_WINDOW_ALPHA_SIZE:
323       glGetIntegerv ( GL_ALPHA_BITS, &returnValue );
324       return returnValue;
325     case GLUT_WINDOW_ACCUM_RED_SIZE:
326       glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue );
327       return returnValue;
328     case GLUT_WINDOW_ACCUM_GREEN_SIZE:
329       glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue );
330       return returnValue;
331     case GLUT_WINDOW_ACCUM_BLUE_SIZE:
332       glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue );
333       return returnValue;
334     case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
335       glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue );
336       return returnValue;
337     case GLUT_WINDOW_DEPTH_SIZE:
338       glGetIntegerv ( GL_DEPTH_BITS, &returnValue );
339       return returnValue;
340
341     case GLUT_WINDOW_BUFFER_SIZE:
342       returnValue = 1 ;                                      /* ????? */
343       return returnValue;
344     case GLUT_WINDOW_STENCIL_SIZE:
345       returnValue = 0 ;                                      /* ????? */
346       return returnValue;
347
348     case GLUT_WINDOW_X:
349     case GLUT_WINDOW_Y:
350     case GLUT_WINDOW_WIDTH:
351     case GLUT_WINDOW_HEIGHT:
352     {
353         /*
354          *  There is considerable confusion about the "right thing to
355          *  do" concerning window  size and position.  GLUT itself is
356          *  not consistent between Windows and UNIX/X11; since
357          *  platform independence is a virtue for "freeglut", we
358          *  decided to break with GLUT's behaviour.
359          *
360          *  Under UNIX/X11, it is apparently not possible to get the
361          *  window border sizes in order to subtract them off the
362          *  window's initial position until some time after the window
363          *  has been created.  Therefore we decided on the following
364          *  behaviour, both under Windows and under UNIX/X11:
365          *  - When you create a window with position (x,y) and size
366          *    (w,h), the upper left hand corner of the outside of the
367          *    window is at (x,y) and the size of the drawable area  is
368          *    (w,h).
369          *  - When you query the size and position of the window--as
370          *    is happening here for Windows--"freeglut" will return
371          *    the size of the drawable area--the (w,h) that you
372          *    specified when you created the window--and the coordinates
373          *    of the upper left hand corner of the drawable
374          *    area--which is NOT the (x,y) you specified.
375          */
376
377         RECT winRect;
378
379         freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
380
381         /*
382          * We need to call GetWindowRect() first...
383          *  (this returns the pixel coordinates of the outside of the window)
384          */
385         GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect );
386
387         /* ...then we've got to correct the results we've just received... */
388
389 #if !defined(_WIN32_WCE)
390         if ( ( fgStructure.GameModeWindow != fgStructure.CurrentWindow ) && ( fgStructure.CurrentWindow->Parent == NULL ) &&
391              ( ! fgStructure.CurrentWindow->IsMenu ) )
392         {
393           winRect.left   += GetSystemMetrics( SM_CXSIZEFRAME );
394           winRect.right  -= GetSystemMetrics( SM_CXSIZEFRAME );
395           winRect.top    += GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION );
396           winRect.bottom -= GetSystemMetrics( SM_CYSIZEFRAME );
397         }
398 #endif /* !defined(_WIN32_WCE) */
399
400         switch( eWhat )
401         {
402         case GLUT_WINDOW_X:      return winRect.left                ;
403         case GLUT_WINDOW_Y:      return winRect.top                 ;
404         case GLUT_WINDOW_WIDTH:  return winRect.right - winRect.left;
405         case GLUT_WINDOW_HEIGHT: return winRect.bottom - winRect.top;
406         }
407     }
408     break;
409
410     case GLUT_WINDOW_BORDER_WIDTH :
411 #if defined(_WIN32_WCE)
412         return 0;
413 #else
414         return GetSystemMetrics( SM_CXSIZEFRAME );
415 #endif /* !defined(_WIN32_WCE) */
416
417     case GLUT_WINDOW_HEADER_HEIGHT :
418 #if defined(_WIN32_WCE)
419         return 0;
420 #else
421         return GetSystemMetrics( SM_CYCAPTION );
422 #endif /* defined(_WIN32_WCE) */
423
424     case GLUT_DISPLAY_MODE_POSSIBLE:
425 #if defined(_WIN32_WCE)
426         return 0;
427 #else
428         return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
429                                     PFD_MAIN_PLANE );
430 #endif /* defined(_WIN32_WCE) */
431
432
433     case GLUT_WINDOW_FORMAT_ID:
434 #if !defined(_WIN32_WCE)
435         if( fgStructure.CurrentWindow != NULL )
436             return GetPixelFormat( fgStructure.CurrentWindow->Window.Device );
437 #endif /* defined(_WIN32_WCE) */
438         return 0;
439
440 #endif
441
442     /* The window structure queries */
443     case GLUT_WINDOW_PARENT:
444         if( fgStructure.CurrentWindow         == NULL ) return 0;
445         if( fgStructure.CurrentWindow->Parent == NULL ) return 0;
446         return fgStructure.CurrentWindow->Parent->ID;
447
448     case GLUT_WINDOW_NUM_CHILDREN:
449         if( fgStructure.CurrentWindow == NULL )
450             return 0;
451         return fgListLength( &fgStructure.CurrentWindow->Children );
452
453     case GLUT_WINDOW_CURSOR:
454         if( fgStructure.CurrentWindow == NULL )
455             return 0;
456         return fgStructure.CurrentWindow->State.Cursor;
457
458     case GLUT_MENU_NUM_ITEMS:
459         if( fgStructure.CurrentMenu == NULL )
460             return 0;
461         return fgListLength( &fgStructure.CurrentMenu->Entries );
462
463     case GLUT_ACTION_ON_WINDOW_CLOSE:
464         return fgState.ActionOnWindowClose;
465
466     case GLUT_VERSION :
467         return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH;
468
469     case GLUT_RENDERING_CONTEXT:
470         return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
471                                          : GLUT_CREATE_NEW_CONTEXT;
472
473     case GLUT_DIRECT_RENDERING:
474         return fgState.DirectContext;
475         break;
476
477     default:
478         fgWarning( "glutGet(): missing enum handle %d", eWhat );
479         break;
480     }
481     return -1;
482 }
483
484 /*
485  * Returns various device information.
486  */
487 int FGAPIENTRY glutDeviceGet( GLenum eWhat )
488 {
489     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDeviceGet" );
490
491     /* XXX WARNING: we are mostly lying in this function. */
492     switch( eWhat )
493     {
494     case GLUT_HAS_KEYBOARD:
495         /*
496          * Win32 is assumed a keyboard, and this cannot be queried,
497          * except for WindowsCE.
498          *
499          * X11 has a core keyboard by definition, although it can
500          * be present as a virtual/dummy keyboard. For now, there
501          * is no reliable way to tell if a real keyboard is present.
502          */
503 #if defined(_WIN32_CE)
504         return ( GetKeyboardStatus() & KBDI_KEYBOARD_PRESENT ) ? 1 : 0;
505 #   if FREEGLUT_LIB_PRAGMAS
506 #       pragma comment (lib,"Kbdui.lib")
507 #   endif
508
509 #else
510         return 1;
511 #endif
512
513 #if TARGET_HOST_POSIX_X11
514
515     /* X11 has a mouse by definition */
516     case GLUT_HAS_MOUSE:
517         return 1 ;
518
519     case GLUT_NUM_MOUSE_BUTTONS:
520         /* We should be able to pass NULL when the last argument is zero,
521          * but at least one X server has a bug where this causes a segfault.
522          *
523          * In XFree86/Xorg servers, a mouse wheel is seen as two buttons
524          * rather than an Axis; "freeglut_main.c" expects this when
525          * checking for a wheel event.
526          */
527         {
528             unsigned char map;
529             int nbuttons = XGetPointerMapping(fgDisplay.Display, &map,0);
530             return nbuttons;
531         }
532
533 #elif TARGET_HOST_MS_WINDOWS
534
535     case GLUT_HAS_MOUSE:
536         /*
537          * MS Windows can be booted without a mouse.
538          */
539         return GetSystemMetrics( SM_MOUSEPRESENT );
540
541     case GLUT_NUM_MOUSE_BUTTONS:
542 #  if defined(_WIN32_WCE)
543         return 1;
544 #  else
545         return GetSystemMetrics( SM_CMOUSEBUTTONS );
546 #  endif
547 #endif
548
549     case GLUT_HAS_JOYSTICK:
550         return fgJoystickDetect ();
551
552     case GLUT_OWNS_JOYSTICK:
553         return fgState.JoysticksInitialised;
554
555     case GLUT_JOYSTICK_POLL_RATE:
556         return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.JoystickPollRate : 0;
557
558     /* XXX The following two are only for Joystick 0 but this is an improvement */
559     case GLUT_JOYSTICK_BUTTONS:
560         return glutJoystickGetNumButtons ( 0 );
561
562     case GLUT_JOYSTICK_AXES:
563         return glutJoystickGetNumAxes ( 0 );
564
565     case GLUT_HAS_DIAL_AND_BUTTON_BOX:
566         return fgInputDeviceDetect ();
567
568     case GLUT_NUM_DIALS:
569         if ( fgState.InputDevsInitialised ) return 8;
570         return 0;
571  
572     case GLUT_NUM_BUTTON_BOX_BUTTONS:
573         return 0;
574
575     case GLUT_HAS_SPACEBALL:
576     case GLUT_HAS_TABLET:
577         return 0;
578
579     case GLUT_NUM_SPACEBALL_BUTTONS:
580     case GLUT_NUM_TABLET_BUTTONS:
581         return 0;
582
583     case GLUT_DEVICE_IGNORE_KEY_REPEAT:
584         return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.IgnoreKeyRepeat : 0;
585
586     case GLUT_DEVICE_KEY_REPEAT:
587         return fgState.KeyRepeat;
588
589     default:
590         fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
591         break;
592     }
593
594     /* And now -- the failure. */
595     return -1;
596 }
597
598 /*
599  * This should return the current state of ALT, SHIFT and CTRL keys.
600  */
601 int FGAPIENTRY glutGetModifiers( void )
602 {
603     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
604     if( fgState.Modifiers == INVALID_MODIFIERS )
605     {
606         fgWarning( "glutGetModifiers() called outside an input callback" );
607         return 0;
608     }
609
610     return fgState.Modifiers;
611 }
612
613 /*
614  * Return the state of the GLUT API overlay subsystem. A misery ;-)
615  */
616 int FGAPIENTRY glutLayerGet( GLenum eWhat )
617 {
618     FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLayerGet" );
619
620     /*
621      * This is easy as layers are not implemented ;-)
622      *
623      * XXX Can we merge the UNIX/X11 and WIN32 sections?  Or
624      * XXX is overlay support planned?
625      */
626     switch( eWhat )
627     {
628
629 #if TARGET_HOST_POSIX_X11
630
631     case GLUT_OVERLAY_POSSIBLE:
632         return 0;
633
634     case GLUT_LAYER_IN_USE:
635         return GLUT_NORMAL;
636
637     case GLUT_HAS_OVERLAY:
638         return 0;
639
640     case GLUT_TRANSPARENT_INDEX:
641         /*
642          * Return just anything, which is always defined as zero
643          *
644          * XXX HUH?
645          */
646         return 0;
647
648     case GLUT_NORMAL_DAMAGED:
649         /* XXX Actually I do not know. Maybe. */
650         return 0;
651
652     case GLUT_OVERLAY_DAMAGED:
653         return -1;
654
655 #elif TARGET_HOST_MS_WINDOWS
656
657     case GLUT_OVERLAY_POSSIBLE:
658 /*      return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
659                                    PFD_OVERLAY_PLANE ); */
660       return 0 ;
661
662     case GLUT_LAYER_IN_USE:
663         return GLUT_NORMAL;
664
665     case GLUT_HAS_OVERLAY:
666         return 0;
667
668     case GLUT_TRANSPARENT_INDEX:
669         /*
670          * Return just anything, which is always defined as zero
671          *
672          * XXX HUH?
673          */
674         return 0;
675
676     case GLUT_NORMAL_DAMAGED:
677         /* XXX Actually I do not know. Maybe. */
678         return 0;
679
680     case GLUT_OVERLAY_DAMAGED:
681         return -1;
682 #endif
683
684     default:
685         fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
686         break;
687     }
688
689     /* And fail. That's good. Programs do love failing. */
690     return -1;
691 }
692
693 /*** END OF FILE ***/