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
71 return fgStructure.CurrentWindow->State.IsFullscreen;
77 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
80 * General settings assignment method
82 void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
84 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetOption" );
87 * XXX In chronological code add order. (WHY in that order?)
91 case GLUT_INIT_WINDOW_X:
92 fgState.Position.X = (GLint)value;
95 case GLUT_INIT_WINDOW_Y:
96 fgState.Position.Y = (GLint)value;
99 case GLUT_INIT_WINDOW_WIDTH:
100 fgState.Size.X = (GLint)value;
103 case GLUT_INIT_WINDOW_HEIGHT:
104 fgState.Size.Y = (GLint)value;
107 case GLUT_INIT_DISPLAY_MODE:
108 fgState.DisplayMode = (unsigned int)value;
111 case GLUT_ACTION_ON_WINDOW_CLOSE:
112 fgState.ActionOnWindowClose = value;
115 case GLUT_RENDERING_CONTEXT:
116 fgState.UseCurrentContext =
117 ( value == GLUT_USE_CURRENT_CONTEXT ) ? GL_TRUE : GL_FALSE;
120 case GLUT_DIRECT_RENDERING:
121 fgState.DirectContext = value;
124 case GLUT_WINDOW_CURSOR:
125 if( fgStructure.CurrentWindow != NULL )
126 fgStructure.CurrentWindow->State.Cursor = value;
130 fgState.AuxiliaryBufferNumber = value;
133 case GLUT_MULTISAMPLE:
134 fgState.SampleNumber = value;
138 fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
143 #if TARGET_HOST_MS_WINDOWS
144 /* The following include file is available from SGI but is not standard:
145 * #include <GL/wglext.h>
146 * So we copy the necessary parts out of it to support the multisampling query
148 #define WGL_SAMPLES_ARB 0x2042
153 * General settings query method
155 int FGAPIENTRY glutGet( GLenum eWhat )
157 #if TARGET_HOST_MS_WINDOWS
159 GLboolean boolValue ;
166 case GLUT_INIT_STATE:
167 return fgState.Initialised;
169 case GLUT_ELAPSED_TIME:
170 return fgElapsedTime();
173 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGet" );
175 /* XXX In chronological code add order. (WHY in that order?) */
178 /* Following values are stored in fgState and fgDisplay global structures */
179 case GLUT_SCREEN_WIDTH: return fgDisplay.ScreenWidth ;
180 case GLUT_SCREEN_HEIGHT: return fgDisplay.ScreenHeight ;
181 case GLUT_SCREEN_WIDTH_MM: return fgDisplay.ScreenWidthMM ;
182 case GLUT_SCREEN_HEIGHT_MM: return fgDisplay.ScreenHeightMM;
183 case GLUT_INIT_WINDOW_X: return fgState.Position.Use ?
184 fgState.Position.X : -1 ;
185 case GLUT_INIT_WINDOW_Y: return fgState.Position.Use ?
186 fgState.Position.Y : -1 ;
187 case GLUT_INIT_WINDOW_WIDTH: return fgState.Size.Use ?
188 fgState.Size.X : -1 ;
189 case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Use ?
190 fgState.Size.Y : -1 ;
191 case GLUT_INIT_DISPLAY_MODE: return fgState.DisplayMode ;
192 case GLUT_INIT_MAJOR_VERSION: return fgState.MajorVersion ;
193 case GLUT_INIT_MINOR_VERSION: return fgState.MinorVersion ;
194 case GLUT_INIT_FLAGS: return fgState.ContextFlags ;
195 case GLUT_INIT_PROFILE: return fgState.ContextProfile ;
197 #if TARGET_HOST_POSIX_X11
199 * The window/context specific queries are handled mostly by
202 case GLUT_WINDOW_NUM_SAMPLES:
203 #ifdef GLX_VERSION_1_3
204 glGetIntegerv(GL_SAMPLES, &nsamples);
209 * The rest of GLX queries under X are general enough to use a macro to
212 # define GLX_QUERY(a,b) case a: return fghGetConfig( b );
214 GLX_QUERY( GLUT_WINDOW_RGBA, GLX_RGBA );
215 GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER, GLX_DOUBLEBUFFER );
216 GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE, GLX_BUFFER_SIZE );
217 GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE, GLX_STENCIL_SIZE );
218 GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE, GLX_DEPTH_SIZE );
219 GLX_QUERY( GLUT_WINDOW_RED_SIZE, GLX_RED_SIZE );
220 GLX_QUERY( GLUT_WINDOW_GREEN_SIZE, GLX_GREEN_SIZE );
221 GLX_QUERY( GLUT_WINDOW_BLUE_SIZE, GLX_BLUE_SIZE );
222 GLX_QUERY( GLUT_WINDOW_ALPHA_SIZE, GLX_ALPHA_SIZE );
223 GLX_QUERY( GLUT_WINDOW_ACCUM_RED_SIZE, GLX_ACCUM_RED_SIZE );
224 GLX_QUERY( GLUT_WINDOW_ACCUM_GREEN_SIZE, GLX_ACCUM_GREEN_SIZE );
225 GLX_QUERY( GLUT_WINDOW_ACCUM_BLUE_SIZE, GLX_ACCUM_BLUE_SIZE );
226 GLX_QUERY( GLUT_WINDOW_ACCUM_ALPHA_SIZE, GLX_ACCUM_ALPHA_SIZE );
227 GLX_QUERY( GLUT_WINDOW_STEREO, GLX_STEREO );
231 /* Colormap size is handled in a bit different way than all the rest */
232 case GLUT_WINDOW_COLORMAP_SIZE:
233 if( (fghGetConfig( GLX_RGBA )) || (fgStructure.CurrentWindow == NULL) )
236 * We've got a RGBA visual, so there is no colormap at all.
237 * The other possibility is that we have no current window set.
243 const GLXFBConfig * fbconfig =
244 fgStructure.CurrentWindow->Window.FBConfig;
246 XVisualInfo * visualInfo =
247 glXGetVisualFromFBConfig( fgDisplay.Display, *fbconfig );
249 const int result = visualInfo->visual->map_entries;
257 * Those calls are somewhat similiar, as they use XGetWindowAttributes()
262 case GLUT_WINDOW_BORDER_WIDTH:
263 case GLUT_WINDOW_HEADER_HEIGHT:
268 if( fgStructure.CurrentWindow == NULL )
271 XTranslateCoordinates(
273 fgStructure.CurrentWindow->Window.Handle,
274 fgDisplay.RootWindow,
279 case GLUT_WINDOW_X: return x;
280 case GLUT_WINDOW_Y: return y;
285 XTranslateCoordinates(
287 fgStructure.CurrentWindow->Window.Handle,
288 w, 0, 0, &x, &y, &w);
292 case GLUT_WINDOW_BORDER_WIDTH: return x;
293 case GLUT_WINDOW_HEADER_HEIGHT: return y;
297 case GLUT_WINDOW_WIDTH:
298 case GLUT_WINDOW_HEIGHT:
300 XWindowAttributes winAttributes;
302 if( fgStructure.CurrentWindow == NULL )
304 XGetWindowAttributes(
306 fgStructure.CurrentWindow->Window.Handle,
311 case GLUT_WINDOW_WIDTH: return winAttributes.width ;
312 case GLUT_WINDOW_HEIGHT: return winAttributes.height ;
316 /* I do not know yet if there will be a fgChooseVisual() function for Win32 */
317 case GLUT_DISPLAY_MODE_POSSIBLE:
319 /* We should not have to call fgChooseFBConfig again here. */
320 GLXFBConfig * fbconfig;
323 fbconfig = fgChooseFBConfig();
325 if (fbconfig == NULL)
338 /* This is system-dependant */
339 case GLUT_WINDOW_FORMAT_ID:
340 if( fgStructure.CurrentWindow == NULL )
343 return fghGetConfig( GLX_VISUAL_ID );
345 #elif TARGET_HOST_MS_WINDOWS
347 case GLUT_WINDOW_NUM_SAMPLES:
348 glGetIntegerv(WGL_SAMPLES_ARB, &nsamples);
351 /* Handle the OpenGL inquiries */
352 case GLUT_WINDOW_RGBA:
353 #if defined(_WIN32_WCE)
354 boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
356 glGetBooleanv ( GL_RGBA_MODE, &boolValue );
357 returnValue = boolValue ? 1 : 0;
360 case GLUT_WINDOW_DOUBLEBUFFER:
361 #if defined(_WIN32_WCE)
362 boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
364 glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue );
365 returnValue = boolValue ? 1 : 0;
368 case GLUT_WINDOW_STEREO:
369 #if defined(_WIN32_WCE)
370 boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
372 glGetBooleanv ( GL_STEREO, &boolValue );
373 returnValue = boolValue ? 1 : 0;
377 case GLUT_WINDOW_RED_SIZE:
378 glGetIntegerv ( GL_RED_BITS, &returnValue );
380 case GLUT_WINDOW_GREEN_SIZE:
381 glGetIntegerv ( GL_GREEN_BITS, &returnValue );
383 case GLUT_WINDOW_BLUE_SIZE:
384 glGetIntegerv ( GL_BLUE_BITS, &returnValue );
386 case GLUT_WINDOW_ALPHA_SIZE:
387 glGetIntegerv ( GL_ALPHA_BITS, &returnValue );
389 case GLUT_WINDOW_ACCUM_RED_SIZE:
390 #if defined(_WIN32_WCE)
391 returnValue = 0; /* WinCE doesn't support this feature */
393 glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue );
396 case GLUT_WINDOW_ACCUM_GREEN_SIZE:
397 #if defined(_WIN32_WCE)
398 returnValue = 0; /* WinCE doesn't support this feature */
400 glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue );
403 case GLUT_WINDOW_ACCUM_BLUE_SIZE:
404 #if defined(_WIN32_WCE)
405 returnValue = 0; /* WinCE doesn't support this feature */
407 glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue );
410 case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
411 #if defined(_WIN32_WCE)
412 returnValue = 0; /* WinCE doesn't support this feature */
414 glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue );
417 case GLUT_WINDOW_DEPTH_SIZE:
418 glGetIntegerv ( GL_DEPTH_BITS, &returnValue );
421 case GLUT_WINDOW_BUFFER_SIZE:
422 returnValue = 1 ; /* ????? */
424 case GLUT_WINDOW_STENCIL_SIZE:
425 returnValue = 0 ; /* ????? */
430 case GLUT_WINDOW_WIDTH:
431 case GLUT_WINDOW_HEIGHT:
434 * There is considerable confusion about the "right thing to
435 * do" concerning window size and position. GLUT itself is
436 * not consistent between Windows and UNIX/X11; since
437 * platform independence is a virtue for "freeglut", we
438 * decided to break with GLUT's behaviour.
440 * Under UNIX/X11, it is apparently not possible to get the
441 * window border sizes in order to subtract them off the
442 * window's initial position until some time after the window
443 * has been created. Therefore we decided on the following
444 * behaviour, both under Windows and under UNIX/X11:
445 * - When you create a window with position (x,y) and size
446 * (w,h), the upper left hand corner of the outside of the
447 * window is at (x,y) and the size of the drawable area is
449 * - When you query the size and position of the window--as
450 * is happening here for Windows--"freeglut" will return
451 * the size of the drawable area--the (w,h) that you
452 * specified when you created the window--and the coordinates
453 * of the upper left hand corner of the drawable
454 * area--which is NOT the (x,y) you specified.
459 freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
462 * We need to call GetWindowRect() first...
463 * (this returns the pixel coordinates of the outside of the window)
465 GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect );
467 /* ...then we've got to correct the results we've just received... */
469 #if !defined(_WIN32_WCE)
470 if ( ( fgStructure.GameModeWindow != fgStructure.CurrentWindow ) && ( fgStructure.CurrentWindow->Parent == NULL ) &&
471 ( ! fgStructure.CurrentWindow->IsMenu ) )
473 winRect.left += GetSystemMetrics( SM_CXSIZEFRAME );
474 winRect.right -= GetSystemMetrics( SM_CXSIZEFRAME );
475 winRect.top += GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION );
476 winRect.bottom -= GetSystemMetrics( SM_CYSIZEFRAME );
478 #endif /* !defined(_WIN32_WCE) */
482 case GLUT_WINDOW_X: return winRect.left ;
483 case GLUT_WINDOW_Y: return winRect.top ;
484 case GLUT_WINDOW_WIDTH: return winRect.right - winRect.left;
485 case GLUT_WINDOW_HEIGHT: return winRect.bottom - winRect.top;
490 case GLUT_WINDOW_BORDER_WIDTH :
491 #if defined(_WIN32_WCE)
494 return GetSystemMetrics( SM_CXSIZEFRAME );
495 #endif /* !defined(_WIN32_WCE) */
497 case GLUT_WINDOW_HEADER_HEIGHT :
498 #if defined(_WIN32_WCE)
501 return GetSystemMetrics( SM_CYCAPTION );
502 #endif /* defined(_WIN32_WCE) */
504 case GLUT_DISPLAY_MODE_POSSIBLE:
505 #if defined(_WIN32_WCE)
508 return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
510 #endif /* defined(_WIN32_WCE) */
513 case GLUT_WINDOW_FORMAT_ID:
514 #if !defined(_WIN32_WCE)
515 if( fgStructure.CurrentWindow != NULL )
516 return GetPixelFormat( fgStructure.CurrentWindow->Window.Device );
517 #endif /* defined(_WIN32_WCE) */
522 /* The window structure queries */
523 case GLUT_WINDOW_PARENT:
524 if( fgStructure.CurrentWindow == NULL ) return 0;
525 if( fgStructure.CurrentWindow->Parent == NULL ) return 0;
526 return fgStructure.CurrentWindow->Parent->ID;
528 case GLUT_WINDOW_NUM_CHILDREN:
529 if( fgStructure.CurrentWindow == NULL )
531 return fgListLength( &fgStructure.CurrentWindow->Children );
533 case GLUT_WINDOW_CURSOR:
534 if( fgStructure.CurrentWindow == NULL )
536 return fgStructure.CurrentWindow->State.Cursor;
538 case GLUT_MENU_NUM_ITEMS:
539 if( fgStructure.CurrentMenu == NULL )
541 return fgListLength( &fgStructure.CurrentMenu->Entries );
543 case GLUT_ACTION_ON_WINDOW_CLOSE:
544 return fgState.ActionOnWindowClose;
547 return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH;
549 case GLUT_RENDERING_CONTEXT:
550 return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
551 : GLUT_CREATE_NEW_CONTEXT;
553 case GLUT_DIRECT_RENDERING:
554 return fgState.DirectContext;
556 case GLUT_FULL_SCREEN:
557 return fghCheckFullScreen();
560 return fgState.AuxiliaryBufferNumber;
562 case GLUT_MULTISAMPLE:
563 return fgState.SampleNumber;
566 fgWarning( "glutGet(): missing enum handle %d", eWhat );
573 * Returns various device information.
575 int FGAPIENTRY glutDeviceGet( GLenum eWhat )
577 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDeviceGet" );
579 /* XXX WARNING: we are mostly lying in this function. */
582 case GLUT_HAS_KEYBOARD:
584 * Win32 is assumed a keyboard, and this cannot be queried,
585 * except for WindowsCE.
587 * X11 has a core keyboard by definition, although it can
588 * be present as a virtual/dummy keyboard. For now, there
589 * is no reliable way to tell if a real keyboard is present.
591 #if defined(_WIN32_CE)
592 return ( GetKeyboardStatus() & KBDI_KEYBOARD_PRESENT ) ? 1 : 0;
593 # if FREEGLUT_LIB_PRAGMAS
594 # pragma comment (lib,"Kbdui.lib")
601 #if TARGET_HOST_POSIX_X11
603 /* X11 has a mouse by definition */
607 case GLUT_NUM_MOUSE_BUTTONS:
608 /* We should be able to pass NULL when the last argument is zero,
609 * but at least one X server has a bug where this causes a segfault.
611 * In XFree86/Xorg servers, a mouse wheel is seen as two buttons
612 * rather than an Axis; "freeglut_main.c" expects this when
613 * checking for a wheel event.
617 int nbuttons = XGetPointerMapping(fgDisplay.Display, &map,0);
621 #elif TARGET_HOST_MS_WINDOWS
625 * MS Windows can be booted without a mouse.
627 return GetSystemMetrics( SM_MOUSEPRESENT );
629 case GLUT_NUM_MOUSE_BUTTONS:
630 # if defined(_WIN32_WCE)
633 return GetSystemMetrics( SM_CMOUSEBUTTONS );
637 case GLUT_HAS_JOYSTICK:
638 return fgJoystickDetect ();
640 case GLUT_OWNS_JOYSTICK:
641 return fgState.JoysticksInitialised;
643 case GLUT_JOYSTICK_POLL_RATE:
644 return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.JoystickPollRate : 0;
646 /* XXX The following two are only for Joystick 0 but this is an improvement */
647 case GLUT_JOYSTICK_BUTTONS:
648 return glutJoystickGetNumButtons ( 0 );
650 case GLUT_JOYSTICK_AXES:
651 return glutJoystickGetNumAxes ( 0 );
653 case GLUT_HAS_DIAL_AND_BUTTON_BOX:
654 return fgInputDeviceDetect ();
657 if ( fgState.InputDevsInitialised ) return 8;
660 case GLUT_NUM_BUTTON_BOX_BUTTONS:
663 case GLUT_HAS_SPACEBALL:
664 return fgHasSpaceball();
666 case GLUT_HAS_TABLET:
669 case GLUT_NUM_SPACEBALL_BUTTONS:
670 return fgSpaceballNumButtons();
672 case GLUT_NUM_TABLET_BUTTONS:
675 case GLUT_DEVICE_IGNORE_KEY_REPEAT:
676 return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.IgnoreKeyRepeat : 0;
678 case GLUT_DEVICE_KEY_REPEAT:
679 return fgState.KeyRepeat;
682 fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
686 /* And now -- the failure. */
691 * This should return the current state of ALT, SHIFT and CTRL keys.
693 int FGAPIENTRY glutGetModifiers( void )
695 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
696 if( fgState.Modifiers == INVALID_MODIFIERS )
698 fgWarning( "glutGetModifiers() called outside an input callback" );
702 return fgState.Modifiers;
706 * Return the state of the GLUT API overlay subsystem. A misery ;-)
708 int FGAPIENTRY glutLayerGet( GLenum eWhat )
710 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLayerGet" );
713 * This is easy as layers are not implemented ;-)
715 * XXX Can we merge the UNIX/X11 and WIN32 sections? Or
716 * XXX is overlay support planned?
721 #if TARGET_HOST_POSIX_X11
723 case GLUT_OVERLAY_POSSIBLE:
726 case GLUT_LAYER_IN_USE:
729 case GLUT_HAS_OVERLAY:
732 case GLUT_TRANSPARENT_INDEX:
734 * Return just anything, which is always defined as zero
740 case GLUT_NORMAL_DAMAGED:
741 /* XXX Actually I do not know. Maybe. */
744 case GLUT_OVERLAY_DAMAGED:
747 #elif TARGET_HOST_MS_WINDOWS
749 case GLUT_OVERLAY_POSSIBLE:
750 /* return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
751 PFD_OVERLAY_PLANE ); */
754 case GLUT_LAYER_IN_USE:
757 case GLUT_HAS_OVERLAY:
760 case GLUT_TRANSPARENT_INDEX:
762 * Return just anything, which is always defined as zero
768 case GLUT_NORMAL_DAMAGED:
769 /* XXX Actually I do not know. Maybe. */
772 case GLUT_OVERLAY_DAMAGED:
777 fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
781 /* And fail. That's good. Programs do love failing. */
785 int * FGAPIENTRY glutGetModeValues(GLenum eWhat, int * size)
789 #if TARGET_HOST_POSIX_X11
791 GLXFBConfig * fbconfigArray; /* Array of FBConfigs */
792 int fbconfigArraySize; /* Number of FBConfigs in the array */
793 int attribute_name = 0;
796 FREEGLUT_EXIT_IF_NOT_INITIALISED("glutGetModeValues");
803 #if TARGET_HOST_POSIX_X11
805 case GLUT_MULTISAMPLE:
807 attributes[0] = GLX_BUFFER_SIZE;
808 attributes[1] = GLX_DONT_CARE;
814 FBConfigs are now sorted by increasing number of auxiliary
815 buffers. We want at least one buffer.
817 attributes[2] = GLX_AUX_BUFFERS;
819 attributes[4] = None;
821 attribute_name = GLX_AUX_BUFFERS;
826 case GLUT_MULTISAMPLE:
827 attributes[2] = GLX_AUX_BUFFERS;
828 attributes[3] = GLX_DONT_CARE;
829 attributes[4] = GLX_SAMPLE_BUFFERS;
832 FBConfigs are now sorted by increasing number of samples per
833 pixel. We want at least one sample.
835 attributes[6] = GLX_SAMPLES;
837 attributes[8] = None;
839 attribute_name = GLX_SAMPLES;
844 fbconfigArray = glXChooseFBConfig(fgDisplay.Display,
849 if (fbconfigArray != NULL)
852 int result; /* Returned by glXGetFBConfigAttrib. Not checked. */
856 temp_array = malloc(sizeof(int) * fbconfigArraySize);
859 for (i = 0; i < fbconfigArraySize; i++)
863 result = glXGetFBConfigAttrib(fgDisplay.Display,
867 if (value > previous_value)
869 temp_array[*size] = value;
870 previous_value = value;
875 array = malloc(sizeof(int) * (*size));
876 for (i = 0; i < *size; i++)
878 array[i] = temp_array[i];
882 XFree(fbconfigArray);
895 /*** END OF FILE ***/