4 * Various freeglut initialization functions.
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 2 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.
32 #define G_LOG_DOMAIN "freeglut-init"
34 #include "../include/GL/freeglut.h"
35 #include "../include/GL/freeglut_internal.h"
38 * TODO BEFORE THE STABLE RELEASE:
40 * fgDeinitialize() -- Win32's OK, X11 needs the OS-specific deinitialization done
41 * glutInitDisplayString() -- display mode string parsing
43 * Wouldn't it be cool to use gettext() for error messages? I just love bash saying
44 * "nie znaleziono pliku" instead of "file not found" :) Is gettext easily portable?
47 /* -- GLOBAL VARIABLES ----------------------------------------------------- */
50 * A structure pointed by g_pDisplay holds all information
51 * regarding the display, screen, root window etc.
53 SFG_Display fgDisplay;
56 * The settings for the current freeglut session
58 SFG_State fgState = { { -1, -1, FALSE }, { 300, 300, TRUE }, GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH,
59 FALSE, TRUE, FALSE, FALSE, FALSE, TRUE,
60 #ifdef TARGET_HOST_WIN32
65 { NULL, NULL }, NULL, NULL, NULL, { 640, 480, TRUE }, 16, 72, GLUT_ACTION_EXIT, GLUT_EXEC_STATE_INIT } ;
68 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
71 * A call to this function should initialize all the display stuff...
73 void fgInitialize( const char* displayName )
75 #if TARGET_HOST_UNIX_X11
77 * Have the display created
79 fgDisplay.Display = XOpenDisplay( displayName );
81 if( fgDisplay.Display == NULL )
84 * Failed to open a display. That's no good.
86 fgError( "failed to open display '%s'", XDisplayName( displayName ) );
90 * Check for the OpenGL GLX extension availability:
92 if( !glXQueryExtension( fgDisplay.Display, NULL, NULL ) )
95 * GLX extensions have not been found...
97 fgError( "OpenGL GLX extension not supported by display '%s'", XDisplayName( displayName ) );
101 * Grab the default screen for the display we have just opened
103 fgDisplay.Screen = DefaultScreen( fgDisplay.Display );
106 * The same applying to the root window
108 fgDisplay.RootWindow = RootWindow(
114 * Grab the logical screen's geometry
116 fgDisplay.ScreenWidth = DisplayWidth(
121 fgDisplay.ScreenHeight = DisplayHeight(
127 * Grab the physical screen's geometry
129 fgDisplay.ScreenWidthMM = DisplayWidthMM(
134 fgDisplay.ScreenHeightMM = DisplayHeightMM(
140 * The display's connection number
142 fgDisplay.Connection = ConnectionNumber( fgDisplay.Display );
145 * Create the window deletion atom
147 fgDisplay.DeleteWindow = XInternAtom(
153 #elif TARGET_HOST_WIN32
159 * What we need to do is to initialize the fgDisplay global structure here...
161 fgDisplay.Instance = GetModuleHandle( NULL );
164 * Check if the freeglut window class has been registered before...
166 atom = GetClassInfo( fgDisplay.Instance, "FREEGLUT", &wc );
169 * ...nope, it has not, and we have to do it right now:
174 * Make sure the unitialized fields are reset to zero
176 ZeroMemory( &wc, sizeof(WNDCLASS) );
179 * Each of the windows should have its own device context...
182 wc.lpfnWndProc = fgWindowProc;
185 wc.hInstance = fgDisplay.Instance;
186 wc.hIcon = LoadIcon( NULL, IDI_WINLOGO );
187 wc.hCursor = LoadCursor( NULL, IDC_ARROW );
188 wc.hbrBackground = NULL;
189 wc.lpszMenuName = NULL;
190 wc.lpszClassName = "FREEGLUT";
193 * Register the window class
195 atom = RegisterClass( &wc );
200 * The screen dimensions can be obtained via GetSystemMetrics() calls
202 fgDisplay.ScreenWidth = GetSystemMetrics( SM_CXSCREEN );
203 fgDisplay.ScreenHeight = GetSystemMetrics( SM_CYSCREEN );
207 * Checking the display's size in millimeters isn't too hard, too:
209 HWND desktop = GetDesktopWindow();
210 HDC context = GetDC( desktop );
213 * Grab the appropriate values now (HORZSIZE and VERTSIZE respectably):
215 fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
216 fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
219 * Whoops, forgot to release the device context :)
221 ReleaseDC( desktop, context );
227 * Have the joystick device initialized now
233 * Perform the freeglut deinitialization...
235 void fgDeinitialize( void )
240 * Check if initialization has been performed before
242 if( !fgState.Time.Set )
244 fgWarning( "fgDeinitialize(): fgState.Timer is null => no valid initialization has been performed" );
249 * Perform the freeglut structure deinitialization
251 fgDestroyStructure();
254 * Delete all the timers and their storage list
256 while ( (timer = fgState.Timers.First) != NULL )
258 fgListRemove ( &fgState.Timers, &timer->Node ) ;
263 * Deinitialize the joystick device
268 * Reset the state structure
271 fgState.Position.X = -1 ;
272 fgState.Position.Y = -1 ;
273 fgState.Position.Use = FALSE ;
275 fgState.Size.X = 300 ;
276 fgState.Size.Y = 300 ;
277 fgState.Size.Use = TRUE ;
280 * The default display mode to be used
282 fgState.DisplayMode = GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH;
284 fgState.ForceDirectContext = FALSE;
285 fgState.TryDirectContext = TRUE;
286 fgState.ForceIconic = FALSE;
287 fgState.GLDebugSwitch = FALSE;
288 fgState.XSyncSwitch = FALSE;
289 fgState.ActionOnWindowClose = GLUT_ACTION_EXIT ;
290 fgState.ExecState = GLUT_EXEC_STATE_INIT ;
293 * Assume we want to ignore the automatic key repeat
295 fgState.IgnoreKeyRepeat = TRUE;
298 * Set the default game mode settings
300 fgState.GameModeSize.X = 640;
301 fgState.GameModeSize.Y = 480;
302 fgState.GameModeDepth = 16;
303 fgState.GameModeRefresh = 72;
305 fgState.Time.Set = FALSE ;
307 fgState.Timers.First = fgState.Timers.Last = NULL ;
308 fgState.IdleCallback = NULL ;
309 fgState.MenuStateCallback = (FGCBmenuState)NULL ;
310 fgState.MenuStatusCallback = (FGCBmenuStatus)NULL ;
312 #if TARGET_HOST_UNIX_X11
315 * Make sure all X-client data we have created will be destroyed on display closing
317 XSetCloseDownMode( fgDisplay.Display, DestroyAll );
320 * Close the display connection, destroying all windows we have created so far
322 XCloseDisplay( fgDisplay.Display );
328 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
331 * Perform initialization. This usually happens on the program startup
332 * and restarting after glutMainLoop termination...
334 void FGAPIENTRY glutInit( int* pargc, char** argv )
336 char* displayName = NULL;
337 int i, j, argc = *pargc;
340 * Do not allow multiple initialization of the library
342 if( fgState.Time.Set )
345 * We can't have multiple initialization performed
347 fgError( "illegal glutInit() reinitialization attemp" );
351 * Have the internal freeglut structure initialized now
356 * Remember the function's call time
358 #if TARGET_HOST_UNIX_X11
359 gettimeofday(&fgState.Time.Value, NULL);
360 #elif TARGET_HOST_WIN32
361 fgState.Time.Value = timeGetTime();
363 fgState.Time.Set = TRUE;
366 * Grab the environment variable indicating the X display to use.
367 * This is harmless under Win32, so let's let it stay here...
369 displayName = strdup( getenv( "DISPLAY" ) );
372 * Have the program arguments parsed.
374 for( i=1; i<argc; i++ )
377 * The X display name settings
379 if( strcmp( argv[ i ], "-display" ) == 0 )
382 * Check for possible lack of the next argument
385 fgError( "-display parameter must be followed by display name" );
388 * Release the previous display name (the one from app's environment)
393 * Make a working copy of the name for us to use
395 displayName = strdup( argv[ i ] );
398 * Have both arguments removed
400 argv[ i - 1 ] = NULL;
406 * The geometry settings
408 else if( strcmp( argv[ i ], "-geometry" ) == 0 )
414 * Again, check if there is at least one more argument
417 fgError( "-geometry parameter must be followed by window geometry settings" );
420 * Otherwise scan the geometry settings...
422 result = sscanf ( argv[i], "%dx%d+%d+%d", &x, &y, &w, &h );
425 * Check what we have been supplied with...
436 fgState.Position.Y = fgDisplay.ScreenHeight + y - fgState.Size.Y;
438 fgState.Position.Y = y;
444 fgState.Position.X = fgDisplay.ScreenWidth + x - fgState.Size.X;
446 fgState.Position.X = x;
450 * Have both arguments removed
452 argv[ i - 1 ] = NULL;
458 * The direct/indirect OpenGL contexts settings
460 else if( strcmp( argv[ i ], "-direct" ) == 0)
463 * We try to force direct rendering...
465 if( fgState.TryDirectContext == FALSE )
466 fgError( "parameters ambiguity, -direct and -indirect cannot be both specified" );
468 fgState.ForceDirectContext = TRUE;
472 else if( strcmp( argv[ i ], "-indirect" ) == 0 )
475 * We try to force indirect rendering...
477 if( fgState.ForceDirectContext == TRUE )
478 fgError( "parameters ambiguity, -direct and -indirect cannot be both specified" );
480 fgState.TryDirectContext = FALSE;
486 * The '-iconic' parameter makes all new top-level
487 * windows created in iconified state...
489 else if( strcmp( argv[ i ], "-iconic" ) == 0 )
491 fgState.ForceIconic = TRUE;
497 * The '-gldebug' option activates some OpenGL state debugging features
499 else if( strcmp( argv[ i ], "-gldebug" ) == 0 )
501 fgState.GLDebugSwitch = TRUE;
507 * The '-sync' option activates X protocol synchronization (for debugging purposes)
509 else if( strcmp( argv[ i ], "-sync" ) == 0 )
511 fgState.XSyncSwitch = TRUE;
518 * Have the arguments list compacted now
521 for( i = 1; i < *pargc; i++, j++ )
523 if( argv[ i ] == NULL )
525 while ( argv[j] == NULL ) j++ ; /* Guaranteed to end because there are "*pargc" arguments left */
531 * Have the display created now. As I am too lazy to implement
532 * the program arguments parsing, we will have the DISPLAY
533 * environment variable used for opening the X display:
535 fgInitialize( displayName );
538 * Check for the minus one settings for both position and size...
540 if( fgState.Position.X < 0 || fgState.Position.Y < 0 )
541 fgState.Position.Use = FALSE;
543 if( fgState.Size.X < 0 || fgState.Size.Y < 0 )
544 fgState.Size.Use = FALSE;
547 * Do not forget about releasing the display name string
553 * Sets the default initial window position for new windows
555 void FGAPIENTRY glutInitWindowPosition( int x, int y )
558 * The settings can be disables when both coordinates are negative
560 if( (x >= 0) && (y >= 0) )
563 * We want to specify the initial position of each of the windows
565 fgState.Position.X = x;
566 fgState.Position.Y = y;
567 fgState.Position.Use = TRUE;
572 * The initial position of each of the windows is specified by the wm
574 fgState.Position.X = -1;
575 fgState.Position.Y = -1;
576 fgState.Position.Use = FALSE;
581 * Sets the default initial window size for new windows
583 void FGAPIENTRY glutInitWindowSize( int width, int height )
586 * The settings can be disables when both values are negative
588 if( (width > 0) && (height > 0) )
591 * We want to specify the initial size of each of the windows
593 fgState.Size.X = width;
594 fgState.Size.Y = height;
595 fgState.Size.Use = TRUE;
600 * The initial size of each of the windows is specified by the wm (officially this is an error condition)
604 fgState.Size.Use = FALSE;
609 * Sets the default display mode for all new windows
611 void FGAPIENTRY glutInitDisplayMode( int displayMode )
614 * We will make use of this value when creating a new OpenGL context...
616 fgState.DisplayMode = displayMode;
620 /* -- INIT DISPLAY STRING PARSING ------------------------------------------ */
622 #if 0 /* FIXME: CJP */
624 * There is a discrete number of comparison operators we can encounter:
626 * comparison ::= "=" | "!=" | "<" | ">" | "<=" | ">=" | "~"
628 #define FG_NONE 0x0000
629 #define FG_EQUAL 0x0001
630 #define FG_NOT_EQUAL 0x0002
631 #define FG_LESS 0x0003
632 #define FG_MORE 0x0004
633 #define FG_LESS_OR_EQUAL 0x0005
634 #define FG_MORE_OR_EQUAL 0x0006
635 #define FG_CLOSEST 0x0007
638 * The caller can feed us with a number of capability tokens:
640 * capability ::= "alpha" | "acca" | "acc" | "blue" | "buffer" | "conformant" | "depth" | "double" |
641 * "green" | "index" | "num" | "red" | "rgba" | "rgb" | "luminance" | "stencil" |
642 * "single" | "stereo" | "samples" | "slow" | "win32pdf" | "xvisual" | "xstaticgray" |
643 * "xgrayscale" | "xstaticcolor" | "xpseudocolor" | "xtruecolor" | "xdirectcolor"
645 static gchar* g_Tokens[] =
647 "none", "alpha", "acca", "acc", "blue", "buffer", "conformant", "depth", "double", "green",
648 "index", "num", "red", "rgba", "rgb", "luminance", "stencil", "single", "stereo", "samples",
649 "slow", "win32pdf", "xvisual", "xstaticgray", "xgrayscale", "xstaticcolor", "xpseudocolor",
650 "xtruecolor", "xdirectcolor", NULL
654 * The structure to hold the parsed display string tokens
656 typedef struct tagSFG_Capability SFG_Capability;
657 struct tagSFG_Capability
659 gint capability; /* the capability token enumerator */
660 gint comparison; /* the comparison operator used */
661 gint value; /* the value we're comparing to */
665 * The scanner configuration for the init display string
667 static GScannerConfig fgInitDisplayStringScannerConfig =
669 ( " \t\r\n" ) /* cset_skip_characters */,
674 ) /* cset_identifier_first */,
682 ) /* cset_identifier_nth */,
683 ( "#\n" ) /* cpair_comment_single */,
684 FALSE /* case_sensitive */,
685 TRUE /* skip_comment_multi */,
686 TRUE /* skip_comment_single */,
687 TRUE /* scan_comment_multi */,
688 TRUE /* scan_identifier */,
689 FALSE /* scan_identifier_1char */,
690 FALSE /* scan_identifier_NULL */,
691 TRUE /* scan_symbols */,
692 FALSE /* scan_binary */,
693 TRUE /* scan_octal */,
694 TRUE /* scan_float */,
696 FALSE /* scan_hex_dollar */,
697 TRUE /* scan_string_sq */,
698 TRUE /* scan_string_dq */,
699 TRUE /* numbers_2_int */,
700 FALSE /* int_2_float */,
701 FALSE /* identifier_2_string */,
702 TRUE /* char_2_token */,
703 FALSE /* symbol_2_token */,
704 FALSE /* scope_0_fallback */,
708 * Sets the default display mode for all new windows using a string
710 void FGAPIENTRY glutInitDisplayString( char* displayMode )
713 * display_string ::= (switch)
714 * switch ::= capability [comparison value]
715 * comparison ::= "=" | "!=" | "<" | ">" | "<=" | ">=" | "~"
716 * capability ::= "alpha" | "acca" | "acc" | "blue" | "buffer" | "conformant" |
717 * "depth" | "double" | "green" | "index" | "num" | "red" | "rgba" |
718 * "rgb" | "luminance" | "stencil" | "single" | "stereo" |
719 * "samples" | "slow" | "win32pdf" | "xvisual" | "xstaticgray" |
720 * "xgrayscale" | "xstaticcolor" | "xpseudocolor" |
721 * "xtruecolor" | "xdirectcolor"
722 * value ::= 0..9 [value]
724 * The display string grammar. This should be EBNF, but I couldn't find the definitions so, to
725 * clarify: (expr) means 0 or more times the expression, [expr] means 0 or 1 times expr.
727 * Create a new GLib lexical analyzer to process the display mode string
729 GScanner* scanner = g_scanner_new( &fgInitDisplayStringScannerConfig );
734 * Fail if the display mode string is empty or the scanner failed to initialize
736 freeglut_return_if_fail( (scanner != NULL) && (strlen( displayMode ) > 0) );
739 * Set the scanner's input name (for debugging)
741 scanner->input_name = "glutInitDisplayString";
744 * Start the lexical analysis of the extensions string
746 g_scanner_input_text( scanner, displayMode, strlen( displayMode ) );
749 * While there are any more tokens to be checked...
751 while( !g_scanner_eof( scanner ) )
754 * Actually we're expecting only string tokens
756 GTokenType tokenType = g_scanner_get_next_token( scanner );
759 * We are looking for identifiers
761 if( tokenType == G_TOKEN_IDENTIFIER )
763 gchar* capability = NULL; /* the capability identifier string (always present) */
764 gint capID = 0; /* the capability identifier value (from g_Tokens) */
765 gint comparison = 0; /* the comparison operator value, see definitions */
766 gchar* valueString = NULL; /* if the previous one is present, this is needed */
767 gint value = 0; /* the integer value converted using a strtol call */
768 SFG_Capability* capStruct; /* the capability description structure */
771 * OK. The general rule of thumb that we always should be getting a capability identifier
772 * string (see the grammar description). If it is followed by a comparison identifier, then
773 * there must follow an integer value we're comparing the capability to...
775 * Have the current token analyzed with that in mind...
777 for( i=0; i<(gint) strlen( scanner->value.v_identifier ); i++ )
779 gchar c = scanner->value.v_identifier[ i ];
781 if( (c == '=') || (c == '!') || (c == '<') || (c == '>') || (c == '~') )
786 * Here we go with the length of the capability identifier string.
787 * In the worst of cases, it is as long as the token identifier.
789 capability = g_strndup( scanner->value.v_identifier, i );
792 * OK. Is there a chance for comparison and value identifiers to follow?
793 * Note: checking against i+1 as this handles two cases: single character
794 * comparison operator and first of value's digits, which must always be
795 * there, or the two-character comparison operators.
797 if( (i + 1) < (gint) strlen( scanner->value.v_identifier ) )
800 * Yeah, indeed, it is the i-th character to start the identifier, then.
802 gchar c1 = scanner->value.v_identifier[ i + 0 ];
803 gchar c2 = scanner->value.v_identifier[ i + 1 ];
805 if( (c1 == '=') ) { i += 1; comparison = FG_EQUAL; } else
806 if( (c1 == '!') && (c2 == '=') ) { i += 2; comparison = FG_NOT_EQUAL; } else
807 if( (c1 == '<') && (c2 == '=') ) { i += 2; comparison = FG_LESS_OR_EQUAL; } else
808 if( (c1 == '>') && (c2 == '=') ) { i += 2; comparison = FG_MORE_OR_EQUAL; } else
809 if( (c1 == '<') ) { i += 1; comparison = FG_LESS; } else
810 if( (c1 == '>') ) { i += 1; comparison = FG_MORE; } else
811 if( (c1 == '~') ) { i += 1; comparison = FG_CLOSEST; } else
812 g_warning( "invalid comparison operator in token `%s'", scanner->value.v_identifier );
816 * Grab the value string that must follow the comparison operator...
818 if( comparison != FG_NONE && i < (gint) strlen( scanner->value.v_identifier ) )
819 valueString = g_strdup( scanner->value.v_identifier + i );
822 * If there was a value string, convert it to integer...
824 if( comparison != FG_NONE && strlen( valueString ) > 0 )
825 value = strtol( valueString, NULL, 0 );
828 * Now we need to match the capability string and its ID
830 for( i=0; g_Tokens[ i ]!=NULL; i++ )
832 if( strcmp( capability, g_Tokens[ i ] ) == 0 )
835 * Looks like we've found the one we were looking for
843 * Create a new capability description structure
845 capStruct = g_new0( SFG_Capability, 1 );
848 * Fill in the cap's values, as we have parsed it:
850 capStruct->capability = capID;
851 capStruct->comparison = comparison;
852 capStruct->value = value;
855 * Add the new capabaility to the caps list
857 caps = g_list_append( caps, capStruct );
860 * Clean up the local mess and keep rolling on
862 g_free( valueString );
863 g_free( capability );
868 * Now that we have converted the string into somewhat more machine-friendly
869 * form, proceed with matching the frame buffer configuration...
871 * The caps list could be passed to a function that would try finding the closest
872 * matching pixel format, visual, frame buffer configuration or whatever. It would
873 * be good to convert the glutInitDisplayMode() to use the same method.
876 g_message( "found %i capability preferences", g_list_length( caps ) );
878 g_message( "token `%s': cap: %i, com: %i, val: %i",
879 scanner->value.v_identifier,
880 capStruct->capability,
881 capStruct->comparison,
887 * Free the capabilities we have parsed
889 for( i=0; i<(gint) g_list_length( caps ); i++ )
890 g_free( g_list_nth( caps, i )->data );
893 * Destroy the capabilities list itself
898 * Free the lexical scanner now...
900 g_scanner_destroy( scanner );
904 #define NUM_TOKENS 28
905 static char* Tokens[] =
907 "alpha", "acca", "acc", "blue", "buffer", "conformant", "depth", "double", "green",
908 "index", "num", "red", "rgba", "rgb", "luminance", "stencil", "single", "stereo", "samples",
909 "slow", "win32pdf", "xvisual", "xstaticgray", "xgrayscale", "xstaticcolor", "xpseudocolor",
910 "xtruecolor", "xdirectcolor"
913 static int TokenLengths[] =
915 5, 4, 3, 4, 6, 10, 5, 6, 5,
916 5, 3, 3, 4, 3, 9, 7, 6, 6, 7,
917 4, 8, 7, 11, 10, 12, 12,
921 void FGAPIENTRY glutInitDisplayString( char* displayMode )
923 int glut_state_flag = 0 ;
925 * Unpack a lot of options from a character string. The options are delimited by blanks or tabs.
928 int len = strlen ( displayMode ) ;
929 char *buffer = malloc ( (len+1) * sizeof(char) ) ;
930 memcpy ( buffer, displayMode, len ) ;
933 token = strtok ( buffer, " \t" ) ;
940 for ( i = 0; i < NUM_TOKENS; i++ )
942 if ( strncmp ( token, Tokens[i], TokenLengths[i] ) == 0 ) break ;
947 case 0 : /* "alpha": Alpha color buffer precision in bits */
948 glut_state_flag |= GLUT_ALPHA ; /* Somebody fix this for me! */
951 case 1 : /* "acca": Red, green, blue, and alpha accumulation buffer precision in bits */
954 case 2 : /* "acc": Red, green, and blue accumulation buffer precision in bits with zero bits alpha */
955 glut_state_flag |= GLUT_ACCUM ; /* Somebody fix this for me! */
958 case 3 : /* "blue": Blue color buffer precision in bits */
961 case 4 : /* "buffer": Number of bits in the color index color buffer */
964 case 5 : /* "conformant": Boolean indicating if the frame buffer configuration is conformant or not */
967 case 6 : /* "depth": Number of bits of precsion in the depth buffer */
968 glut_state_flag |= GLUT_DEPTH ; /* Somebody fix this for me! */
971 case 7 : /* "double": Boolean indicating if the color buffer is double buffered */
972 glut_state_flag |= GLUT_DOUBLE ;
975 case 8 : /* "green": Green color buffer precision in bits */
978 case 9 : /* "index": Boolean if the color model is color index or not */
979 glut_state_flag |= GLUT_INDEX ;
982 case 10 : /* "num": A special capability name indicating where the value represents the Nth frame buffer configuration matching the description string */
985 case 11 : /* "red": Red color buffer precision in bits */
988 case 12 : /* "rgba": Number of bits of red, green, blue, and alpha in the RGBA color buffer */
989 glut_state_flag |= GLUT_RGBA ; /* Somebody fix this for me! */
992 case 13 : /* "rgb": Number of bits of red, green, and blue in the RGBA color buffer with zero bits alpha */
993 glut_state_flag |= GLUT_RGB ; /* Somebody fix this for me! */
996 case 14 : /* "luminance": Number of bits of red in the RGBA and zero bits of green, blue (alpha not specified) of color buffer precision */
997 glut_state_flag |= GLUT_LUMINANCE ; /* Somebody fix this for me! */
1000 case 15 : /* "stencil": Number of bits in the stencil buffer */
1001 glut_state_flag |= GLUT_STENCIL ; /* Somebody fix this for me! */
1004 case 16 : /* "single": Boolean indicate the color buffer is single buffered */
1005 glut_state_flag |= GLUT_SINGLE ;
1008 case 17 : /* "stereo": Boolean indicating the color buffer supports OpenGL-style stereo */
1009 glut_state_flag |= GLUT_STEREO ;
1012 case 18 : /* "samples": Indicates the number of multisamples to use based on GLX's SGIS_multisample extension (for antialiasing) */
1013 glut_state_flag |= GLUT_MULTISAMPLE ; /* Somebody fix this for me! */
1016 case 19 : /* "slow": Boolean indicating if the frame buffer configuration is slow or not */
1019 case 20 : /* "win32pdf": matches the Win32 Pixel Format Descriptor by number */
1020 #ifdef TARGET_HOST_WIN32
1024 case 21 : /* "xvisual": matches the X visual ID by number */
1025 #ifdef TARGET_HOST_UNIX_X11
1029 case 22 : /* "xstaticgray": boolean indicating if the frame buffer configuration's X visual is of type StaticGray */
1030 #ifdef TARGET_HOST_UNIX_X11
1034 case 23 : /* "xgrayscale": boolean indicating if the frame buffer configuration's X visual is of type GrayScale */
1035 #ifdef TARGET_HOST_UNIX_X11
1039 case 24 : /* "xstaticcolor": boolean indicating if the frame buffer configuration's X visual is of type StaticColor */
1040 #ifdef TARGET_HOST_UNIX_X11
1044 case 25 : /* "xpseudocolor": boolean indicating if the frame buffer configuration's X visual is of type PseudoColor */
1045 #ifdef TARGET_HOST_UNIX_X11
1049 case 26 : /* "xtruecolor": boolean indicating if the frame buffer configuration's X visual is of type TrueColor */
1050 #ifdef TARGET_HOST_UNIX_X11
1054 case 27 : /* "xdirectcolor": boolean indicating if the frame buffer configuration's X visual is of type DirectColor */
1055 #ifdef TARGET_HOST_UNIX_X11
1059 case 28 : /* Unrecognized */
1060 printf ( "WARNING - Display string token not recognized: %s\n", token ) ;
1064 token = strtok ( NULL, " \t" ) ;
1070 * We will make use of this value when creating a new OpenGL context...
1072 fgState.DisplayMode = glut_state_flag;
1075 /*** END OF FILE ***/