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