4 * Freeglut state query methods.
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
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:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
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.
28 #include <GL/freeglut.h>
29 #include "freeglut_internal.h"
32 * TODO BEFORE THE STABLE RELEASE:
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?
41 * The fail-on-call policy will help adding the most needed things imho.
44 /* -- LOCAL DEFINITIONS ---------------------------------------------------- */
46 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
48 #if TARGET_HOST_POSIX_X11
50 * Queries the GL context about some attributes
52 static int fghGetConfig( int attribute )
55 int result; /* Not checked */
57 if( fgStructure.CurrentWindow )
58 result = glXGetFBConfigAttrib( fgDisplay.Display,
59 *(fgStructure.CurrentWindow->Window.FBConfig),
67 /* Check if the window is in full screen state. */
68 static int fghCheckFullScreen(void)
70 #if TARGET_HOST_POSIX_X11
75 if (fgDisplay.StateFullScreen != None)
77 result = fgHintPresent(fgStructure.CurrentWindow->Window.Handle,
79 fgDisplay.StateFullScreen);
91 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
94 * General settings assignment method
96 void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
98 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetOption" );
101 * XXX In chronological code add order. (WHY in that order?)
105 case GLUT_INIT_WINDOW_X:
106 fgState.Position.X = (GLint)value;
109 case GLUT_INIT_WINDOW_Y:
110 fgState.Position.Y = (GLint)value;
113 case GLUT_INIT_WINDOW_WIDTH:
114 fgState.Size.X = (GLint)value;
117 case GLUT_INIT_WINDOW_HEIGHT:
118 fgState.Size.Y = (GLint)value;
121 case GLUT_INIT_DISPLAY_MODE:
122 fgState.DisplayMode = (unsigned int)value;
125 case GLUT_ACTION_ON_WINDOW_CLOSE:
126 fgState.ActionOnWindowClose = value;
129 case GLUT_RENDERING_CONTEXT:
130 fgState.UseCurrentContext =
131 ( value == GLUT_USE_CURRENT_CONTEXT ) ? GL_TRUE : GL_FALSE;
134 case GLUT_DIRECT_RENDERING:
135 fgState.DirectContext = value;
138 case GLUT_WINDOW_CURSOR:
139 if( fgStructure.CurrentWindow != NULL )
140 fgStructure.CurrentWindow->State.Cursor = value;
144 fgState.AuxiliaryBufferNumber = value;
147 case GLUT_MULTISAMPLE:
148 fgState.SampleNumber = value;
152 fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
157 #if TARGET_HOST_MS_WINDOWS
158 /* The following include file is available from SGI but is not standard:
159 * #include <GL/wglext.h>
160 * So we copy the necessary parts out of it to support the multisampling query
162 #define WGL_SAMPLES_ARB 0x2042
167 * General settings query method
169 int FGAPIENTRY glutGet( GLenum eWhat )
171 #if TARGET_HOST_MS_WINDOWS
173 GLboolean boolValue ;
180 case GLUT_INIT_STATE:
181 return fgState.Initialised;
183 case GLUT_ELAPSED_TIME:
184 return fgElapsedTime();
187 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGet" );
189 /* XXX In chronological code add order. (WHY in that order?) */
192 /* Following values are stored in fgState and fgDisplay global structures */
193 case GLUT_SCREEN_WIDTH: return fgDisplay.ScreenWidth ;
194 case GLUT_SCREEN_HEIGHT: return fgDisplay.ScreenHeight ;
195 case GLUT_SCREEN_WIDTH_MM: return fgDisplay.ScreenWidthMM ;
196 case GLUT_SCREEN_HEIGHT_MM: return fgDisplay.ScreenHeightMM;
197 case GLUT_INIT_WINDOW_X: return fgState.Position.Use ?
198 fgState.Position.X : -1 ;
199 case GLUT_INIT_WINDOW_Y: return fgState.Position.Use ?
200 fgState.Position.Y : -1 ;
201 case GLUT_INIT_WINDOW_WIDTH: return fgState.Size.Use ?
202 fgState.Size.X : -1 ;
203 case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Use ?
204 fgState.Size.Y : -1 ;
205 case GLUT_INIT_DISPLAY_MODE: return fgState.DisplayMode ;
206 case GLUT_INIT_MAJOR_VERSION: return fgState.MajorVersion ;
207 case GLUT_INIT_MINOR_VERSION: return fgState.MinorVersion ;
208 case GLUT_INIT_FLAGS: return fgState.ContextFlags ;
209 case GLUT_INIT_PROFILE: return fgState.ContextProfile ;
211 #if TARGET_HOST_POSIX_X11
213 * The window/context specific queries are handled mostly by
216 case GLUT_WINDOW_NUM_SAMPLES:
217 #ifdef GLX_VERSION_1_3
218 glGetIntegerv(GL_SAMPLES, &nsamples);
223 * The rest of GLX queries under X are general enough to use a macro to
226 # define GLX_QUERY(a,b) case a: return fghGetConfig( b );
228 GLX_QUERY( GLUT_WINDOW_RGBA, GLX_RGBA );
229 GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER, GLX_DOUBLEBUFFER );
230 GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE, GLX_BUFFER_SIZE );
231 GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE, GLX_STENCIL_SIZE );
232 GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE, GLX_DEPTH_SIZE );
233 GLX_QUERY( GLUT_WINDOW_RED_SIZE, GLX_RED_SIZE );
234 GLX_QUERY( GLUT_WINDOW_GREEN_SIZE, GLX_GREEN_SIZE );
235 GLX_QUERY( GLUT_WINDOW_BLUE_SIZE, GLX_BLUE_SIZE );
236 GLX_QUERY( GLUT_WINDOW_ALPHA_SIZE, GLX_ALPHA_SIZE );
237 GLX_QUERY( GLUT_WINDOW_ACCUM_RED_SIZE, GLX_ACCUM_RED_SIZE );
238 GLX_QUERY( GLUT_WINDOW_ACCUM_GREEN_SIZE, GLX_ACCUM_GREEN_SIZE );
239 GLX_QUERY( GLUT_WINDOW_ACCUM_BLUE_SIZE, GLX_ACCUM_BLUE_SIZE );
240 GLX_QUERY( GLUT_WINDOW_ACCUM_ALPHA_SIZE, GLX_ACCUM_ALPHA_SIZE );
241 GLX_QUERY( GLUT_WINDOW_STEREO, GLX_STEREO );
245 /* Colormap size is handled in a bit different way than all the rest */
246 case GLUT_WINDOW_COLORMAP_SIZE:
247 if( (fghGetConfig( GLX_RGBA )) || (fgStructure.CurrentWindow == NULL) )
250 * We've got a RGBA visual, so there is no colormap at all.
251 * The other possibility is that we have no current window set.
257 const GLXFBConfig * fbconfig =
258 fgStructure.CurrentWindow->Window.FBConfig;
260 XVisualInfo * visualInfo =
261 glXGetVisualFromFBConfig( fgDisplay.Display, *fbconfig );
263 const int result = visualInfo->visual->map_entries;
271 * Those calls are somewhat similiar, as they use XGetWindowAttributes()
276 case GLUT_WINDOW_BORDER_WIDTH:
277 case GLUT_WINDOW_HEADER_HEIGHT:
282 if( fgStructure.CurrentWindow == NULL )
285 XTranslateCoordinates(
287 fgStructure.CurrentWindow->Window.Handle,
288 fgDisplay.RootWindow,
293 case GLUT_WINDOW_X: return x;
294 case GLUT_WINDOW_Y: return y;
299 XTranslateCoordinates(
301 fgStructure.CurrentWindow->Window.Handle,
302 w, 0, 0, &x, &y, &w);
306 case GLUT_WINDOW_BORDER_WIDTH: return x;
307 case GLUT_WINDOW_HEADER_HEIGHT: return y;
311 case GLUT_WINDOW_WIDTH:
312 case GLUT_WINDOW_HEIGHT:
314 XWindowAttributes winAttributes;
316 if( fgStructure.CurrentWindow == NULL )
318 XGetWindowAttributes(
320 fgStructure.CurrentWindow->Window.Handle,
325 case GLUT_WINDOW_WIDTH: return winAttributes.width ;
326 case GLUT_WINDOW_HEIGHT: return winAttributes.height ;
330 /* I do not know yet if there will be a fgChooseVisual() function for Win32 */
331 case GLUT_DISPLAY_MODE_POSSIBLE:
333 /* We should not have to call fgChooseFBConfig again here. */
334 GLXFBConfig * fbconfig;
337 fbconfig = fgChooseFBConfig();
339 if (fbconfig == NULL)
352 /* This is system-dependant */
353 case GLUT_WINDOW_FORMAT_ID:
354 if( fgStructure.CurrentWindow == NULL )
357 return fghGetConfig( GLX_VISUAL_ID );
359 #elif TARGET_HOST_MS_WINDOWS
361 case GLUT_WINDOW_NUM_SAMPLES:
362 glGetIntegerv(WGL_SAMPLES_ARB, &nsamples);
365 /* Handle the OpenGL inquiries */
366 case GLUT_WINDOW_RGBA:
367 #if defined(_WIN32_WCE)
368 boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
370 glGetBooleanv ( GL_RGBA_MODE, &boolValue );
371 returnValue = boolValue ? 1 : 0;
374 case GLUT_WINDOW_DOUBLEBUFFER:
375 #if defined(_WIN32_WCE)
376 boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
378 glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue );
379 returnValue = boolValue ? 1 : 0;
382 case GLUT_WINDOW_STEREO:
383 #if defined(_WIN32_WCE)
384 boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
386 glGetBooleanv ( GL_STEREO, &boolValue );
387 returnValue = boolValue ? 1 : 0;
391 case GLUT_WINDOW_RED_SIZE:
392 glGetIntegerv ( GL_RED_BITS, &returnValue );
394 case GLUT_WINDOW_GREEN_SIZE:
395 glGetIntegerv ( GL_GREEN_BITS, &returnValue );
397 case GLUT_WINDOW_BLUE_SIZE:
398 glGetIntegerv ( GL_BLUE_BITS, &returnValue );
400 case GLUT_WINDOW_ALPHA_SIZE:
401 glGetIntegerv ( GL_ALPHA_BITS, &returnValue );
403 case GLUT_WINDOW_ACCUM_RED_SIZE:
404 #if defined(_WIN32_WCE)
405 returnValue = 0; /* WinCE doesn't support this feature */
407 glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue );
410 case GLUT_WINDOW_ACCUM_GREEN_SIZE:
411 #if defined(_WIN32_WCE)
412 returnValue = 0; /* WinCE doesn't support this feature */
414 glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue );
417 case GLUT_WINDOW_ACCUM_BLUE_SIZE:
418 #if defined(_WIN32_WCE)
419 returnValue = 0; /* WinCE doesn't support this feature */
421 glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue );
424 case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
425 #if defined(_WIN32_WCE)
426 returnValue = 0; /* WinCE doesn't support this feature */
428 glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue );
431 case GLUT_WINDOW_DEPTH_SIZE:
432 glGetIntegerv ( GL_DEPTH_BITS, &returnValue );
435 case GLUT_WINDOW_BUFFER_SIZE:
436 returnValue = 1 ; /* ????? */
438 case GLUT_WINDOW_STENCIL_SIZE:
439 returnValue = 0 ; /* ????? */
444 case GLUT_WINDOW_WIDTH:
445 case GLUT_WINDOW_HEIGHT:
448 * There is considerable confusion about the "right thing to
449 * do" concerning window size and position. GLUT itself is
450 * not consistent between Windows and UNIX/X11; since
451 * platform independence is a virtue for "freeglut", we
452 * decided to break with GLUT's behaviour.
454 * Under UNIX/X11, it is apparently not possible to get the
455 * window border sizes in order to subtract them off the
456 * window's initial position until some time after the window
457 * has been created. Therefore we decided on the following
458 * behaviour, both under Windows and under UNIX/X11:
459 * - When you create a window with position (x,y) and size
460 * (w,h), the upper left hand corner of the outside of the
461 * window is at (x,y) and the size of the drawable area is
463 * - When you query the size and position of the window--as
464 * is happening here for Windows--"freeglut" will return
465 * the size of the drawable area--the (w,h) that you
466 * specified when you created the window--and the coordinates
467 * of the upper left hand corner of the drawable
468 * area--which is NOT the (x,y) you specified.
473 freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
476 * We need to call GetWindowRect() first...
477 * (this returns the pixel coordinates of the outside of the window)
479 GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect );
481 /* ...then we've got to correct the results we've just received... */
483 #if !defined(_WIN32_WCE)
484 if ( ( fgStructure.GameModeWindow != fgStructure.CurrentWindow ) && ( fgStructure.CurrentWindow->Parent == NULL ) &&
485 ( ! fgStructure.CurrentWindow->IsMenu ) )
487 winRect.left += GetSystemMetrics( SM_CXSIZEFRAME );
488 winRect.right -= GetSystemMetrics( SM_CXSIZEFRAME );
489 winRect.top += GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION );
490 winRect.bottom -= GetSystemMetrics( SM_CYSIZEFRAME );
492 #endif /* !defined(_WIN32_WCE) */
496 case GLUT_WINDOW_X: return winRect.left ;
497 case GLUT_WINDOW_Y: return winRect.top ;
498 case GLUT_WINDOW_WIDTH: return winRect.right - winRect.left;
499 case GLUT_WINDOW_HEIGHT: return winRect.bottom - winRect.top;
504 case GLUT_WINDOW_BORDER_WIDTH :
505 #if defined(_WIN32_WCE)
508 return GetSystemMetrics( SM_CXSIZEFRAME );
509 #endif /* !defined(_WIN32_WCE) */
511 case GLUT_WINDOW_HEADER_HEIGHT :
512 #if defined(_WIN32_WCE)
515 return GetSystemMetrics( SM_CYCAPTION );
516 #endif /* defined(_WIN32_WCE) */
518 case GLUT_DISPLAY_MODE_POSSIBLE:
519 #if defined(_WIN32_WCE)
522 return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
524 #endif /* defined(_WIN32_WCE) */
527 case GLUT_WINDOW_FORMAT_ID:
528 #if !defined(_WIN32_WCE)
529 if( fgStructure.CurrentWindow != NULL )
530 return GetPixelFormat( fgStructure.CurrentWindow->Window.Device );
531 #endif /* defined(_WIN32_WCE) */
536 /* The window structure queries */
537 case GLUT_WINDOW_PARENT:
538 if( fgStructure.CurrentWindow == NULL ) return 0;
539 if( fgStructure.CurrentWindow->Parent == NULL ) return 0;
540 return fgStructure.CurrentWindow->Parent->ID;
542 case GLUT_WINDOW_NUM_CHILDREN:
543 if( fgStructure.CurrentWindow == NULL )
545 return fgListLength( &fgStructure.CurrentWindow->Children );
547 case GLUT_WINDOW_CURSOR:
548 if( fgStructure.CurrentWindow == NULL )
550 return fgStructure.CurrentWindow->State.Cursor;
552 case GLUT_MENU_NUM_ITEMS:
553 if( fgStructure.CurrentMenu == NULL )
555 return fgListLength( &fgStructure.CurrentMenu->Entries );
557 case GLUT_ACTION_ON_WINDOW_CLOSE:
558 return fgState.ActionOnWindowClose;
561 return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH;
563 case GLUT_RENDERING_CONTEXT:
564 return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
565 : GLUT_CREATE_NEW_CONTEXT;
567 case GLUT_DIRECT_RENDERING:
568 return fgState.DirectContext;
570 case GLUT_FULL_SCREEN:
571 return fghCheckFullScreen();
574 return fgState.AuxiliaryBufferNumber;
576 case GLUT_MULTISAMPLE:
577 return fgState.SampleNumber;
580 fgWarning( "glutGet(): missing enum handle %d", eWhat );
587 * Returns various device information.
589 int FGAPIENTRY glutDeviceGet( GLenum eWhat )
591 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDeviceGet" );
593 /* XXX WARNING: we are mostly lying in this function. */
596 case GLUT_HAS_KEYBOARD:
598 * Win32 is assumed a keyboard, and this cannot be queried,
599 * except for WindowsCE.
601 * X11 has a core keyboard by definition, although it can
602 * be present as a virtual/dummy keyboard. For now, there
603 * is no reliable way to tell if a real keyboard is present.
605 #if defined(_WIN32_CE)
606 return ( GetKeyboardStatus() & KBDI_KEYBOARD_PRESENT ) ? 1 : 0;
607 # if FREEGLUT_LIB_PRAGMAS
608 # pragma comment (lib,"Kbdui.lib")
615 #if TARGET_HOST_POSIX_X11
617 /* X11 has a mouse by definition */
621 case GLUT_NUM_MOUSE_BUTTONS:
622 /* We should be able to pass NULL when the last argument is zero,
623 * but at least one X server has a bug where this causes a segfault.
625 * In XFree86/Xorg servers, a mouse wheel is seen as two buttons
626 * rather than an Axis; "freeglut_main.c" expects this when
627 * checking for a wheel event.
631 int nbuttons = XGetPointerMapping(fgDisplay.Display, &map,0);
635 #elif TARGET_HOST_MS_WINDOWS
639 * MS Windows can be booted without a mouse.
641 return GetSystemMetrics( SM_MOUSEPRESENT );
643 case GLUT_NUM_MOUSE_BUTTONS:
644 # if defined(_WIN32_WCE)
647 return GetSystemMetrics( SM_CMOUSEBUTTONS );
651 case GLUT_HAS_JOYSTICK:
652 return fgJoystickDetect ();
654 case GLUT_OWNS_JOYSTICK:
655 return fgState.JoysticksInitialised;
657 case GLUT_JOYSTICK_POLL_RATE:
658 return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.JoystickPollRate : 0;
660 /* XXX The following two are only for Joystick 0 but this is an improvement */
661 case GLUT_JOYSTICK_BUTTONS:
662 return glutJoystickGetNumButtons ( 0 );
664 case GLUT_JOYSTICK_AXES:
665 return glutJoystickGetNumAxes ( 0 );
667 case GLUT_HAS_DIAL_AND_BUTTON_BOX:
668 return fgInputDeviceDetect ();
671 if ( fgState.InputDevsInitialised ) return 8;
674 case GLUT_NUM_BUTTON_BOX_BUTTONS:
677 case GLUT_HAS_SPACEBALL:
678 return fgHasSpaceball();
680 case GLUT_HAS_TABLET:
683 case GLUT_NUM_SPACEBALL_BUTTONS:
684 return fgSpaceballNumButtons();
686 case GLUT_NUM_TABLET_BUTTONS:
689 case GLUT_DEVICE_IGNORE_KEY_REPEAT:
690 return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.IgnoreKeyRepeat : 0;
692 case GLUT_DEVICE_KEY_REPEAT:
693 return fgState.KeyRepeat;
696 fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
700 /* And now -- the failure. */
705 * This should return the current state of ALT, SHIFT and CTRL keys.
707 int FGAPIENTRY glutGetModifiers( void )
709 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
710 if( fgState.Modifiers == INVALID_MODIFIERS )
712 fgWarning( "glutGetModifiers() called outside an input callback" );
716 return fgState.Modifiers;
720 * Return the state of the GLUT API overlay subsystem. A misery ;-)
722 int FGAPIENTRY glutLayerGet( GLenum eWhat )
724 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLayerGet" );
727 * This is easy as layers are not implemented ;-)
729 * XXX Can we merge the UNIX/X11 and WIN32 sections? Or
730 * XXX is overlay support planned?
735 #if TARGET_HOST_POSIX_X11
737 case GLUT_OVERLAY_POSSIBLE:
740 case GLUT_LAYER_IN_USE:
743 case GLUT_HAS_OVERLAY:
746 case GLUT_TRANSPARENT_INDEX:
748 * Return just anything, which is always defined as zero
754 case GLUT_NORMAL_DAMAGED:
755 /* XXX Actually I do not know. Maybe. */
758 case GLUT_OVERLAY_DAMAGED:
761 #elif TARGET_HOST_MS_WINDOWS
763 case GLUT_OVERLAY_POSSIBLE:
764 /* return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
765 PFD_OVERLAY_PLANE ); */
768 case GLUT_LAYER_IN_USE:
771 case GLUT_HAS_OVERLAY:
774 case GLUT_TRANSPARENT_INDEX:
776 * Return just anything, which is always defined as zero
782 case GLUT_NORMAL_DAMAGED:
783 /* XXX Actually I do not know. Maybe. */
786 case GLUT_OVERLAY_DAMAGED:
791 fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
795 /* And fail. That's good. Programs do love failing. */
799 int * FGAPIENTRY glutGetModeValues(GLenum eWhat, int * size)
803 #if TARGET_HOST_POSIX_X11
805 GLXFBConfig * fbconfigArray; /* Array of FBConfigs */
806 int fbconfigArraySize; /* Number of FBConfigs in the array */
807 int attribute_name = 0;
810 FREEGLUT_EXIT_IF_NOT_INITIALISED("glutGetModeValues");
817 #if TARGET_HOST_POSIX_X11
819 case GLUT_MULTISAMPLE:
821 attributes[0] = GLX_BUFFER_SIZE;
822 attributes[1] = GLX_DONT_CARE;
828 FBConfigs are now sorted by increasing number of auxiliary
829 buffers. We want at least one buffer.
831 attributes[2] = GLX_AUX_BUFFERS;
833 attributes[4] = None;
835 attribute_name = GLX_AUX_BUFFERS;
840 case GLUT_MULTISAMPLE:
841 attributes[2] = GLX_AUX_BUFFERS;
842 attributes[3] = GLX_DONT_CARE;
843 attributes[4] = GLX_SAMPLE_BUFFERS;
846 FBConfigs are now sorted by increasing number of samples per
847 pixel. We want at least one sample.
849 attributes[6] = GLX_SAMPLES;
851 attributes[8] = None;
853 attribute_name = GLX_SAMPLES;
858 fbconfigArray = glXChooseFBConfig(fgDisplay.Display,
863 if (fbconfigArray != NULL)
866 int result; /* Returned by glXGetFBConfigAttrib. Not checked. */
870 temp_array = malloc(sizeof(int) * fbconfigArraySize);
873 for (i = 0; i < fbconfigArraySize; i++)
877 result = glXGetFBConfigAttrib(fgDisplay.Display,
881 if (value > previous_value)
883 temp_array[*size] = value;
884 previous_value = value;
889 array = malloc(sizeof(int) * (*size));
890 for (i = 0; i < *size; i++)
892 array[i] = temp_array[i];
896 XFree(fbconfigArray);
909 /*** END OF FILE ***/