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 #include "../include/GL/freeglut.h"
33 #include "freeglut_internal.h"
36 * TODO BEFORE THE STABLE RELEASE:
38 * fgDeinitialize() -- Win32's OK, X11 needs the OS-specific
39 * deinitialization done
40 * glutInitDisplayString() -- display mode string parsing
42 * Wouldn't it be cool to use gettext() for error messages? I just love
43 * bash saying "nie znaleziono pliku" instead of "file not found" :)
44 * 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 }, /* Position */
59 { 300, 300, TRUE }, /* Size */
60 GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH, /* DisplayMode */
61 FALSE, /* ForceDirectContext */
62 TRUE, /* TryDirectContext */
63 FALSE, /* ForceIconic */
64 FALSE, /* UseCurrentContext */
65 FALSE, /* GLDebugSwitch */
66 FALSE, /* XSyncSwitch */
67 TRUE, /* IgnoreKeyRepeat */
72 { 0, FALSE }, /* Time */
76 { NULL, NULL }, /* Timers */
77 NULL, /* IdleCallback */
78 FALSE, /* BuildingAMenu */
80 NULL, /* MenuStateCallback */
81 NULL, /* MenuStatusCallback */
82 { 640, 480, TRUE }, /* GameModeSize */
83 16, /* GameModeDepth */
84 72, /* GameModeRefresh */
85 GLUT_ACTION_EXIT, /* ActionOnWindowClose */
86 GLUT_EXEC_STATE_INIT /* ExecState */
90 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
93 * A call to this function should initialize all the display stuff...
95 void fgInitialize( const char* displayName )
97 #if TARGET_HOST_UNIX_X11
98 fgDisplay.Display = XOpenDisplay( displayName );
100 if( fgDisplay.Display == NULL )
101 fgError( "failed to open display '%s'", XDisplayName( displayName ) );
103 if( !glXQueryExtension( fgDisplay.Display, NULL, NULL ) )
104 fgError( "OpenGL GLX extension not supported by display '%s'",
105 XDisplayName( displayName ) );
107 fgDisplay.Screen = DefaultScreen( fgDisplay.Display );
108 fgDisplay.RootWindow = RootWindow(
113 fgDisplay.ScreenWidth = DisplayWidth(
117 fgDisplay.ScreenHeight = DisplayHeight(
122 fgDisplay.ScreenWidthMM = DisplayWidthMM(
126 fgDisplay.ScreenHeightMM = DisplayHeightMM(
131 fgDisplay.Connection = ConnectionNumber( fgDisplay.Display );
134 * Create the window deletion atom
136 fgDisplay.DeleteWindow = XInternAtom(
142 #elif TARGET_HOST_WIN32
148 * What we need to do is to initialize the fgDisplay global structure here...
150 fgDisplay.Instance = GetModuleHandle( NULL );
152 atom = GetClassInfo( fgDisplay.Instance, "FREEGLUT", &wc );
155 ZeroMemory( &wc, sizeof(WNDCLASS) );
158 * Each of the windows should have its own device context...
161 wc.lpfnWndProc = fgWindowProc;
164 wc.hInstance = fgDisplay.Instance;
165 wc.hIcon = LoadIcon( fgDisplay.Instance, "GLUT_ICON" );
167 wc.hIcon = LoadIcon( NULL, IDI_WINLOGO );
169 wc.hCursor = LoadCursor( NULL, IDC_ARROW );
170 wc.hbrBackground = NULL;
171 wc.lpszMenuName = NULL;
172 wc.lpszClassName = "FREEGLUT";
175 * Register the window class
177 atom = RegisterClass( &wc );
182 * The screen dimensions can be obtained via GetSystemMetrics() calls
184 fgDisplay.ScreenWidth = GetSystemMetrics( SM_CXSCREEN );
185 fgDisplay.ScreenHeight = GetSystemMetrics( SM_CYSCREEN );
188 HWND desktop = GetDesktopWindow();
189 HDC context = GetDC( desktop );
191 fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
192 fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
194 ReleaseDC( desktop, context );
203 * Perform the freeglut deinitialization...
205 void fgDeinitialize( void )
209 if( !fgState.Time.Set )
211 fgWarning( "fgDeinitialize(): fgState.Timer is null => "
212 "no valid initialization has been performed" );
217 * If there was a menu created, destroy the rendering context
219 if( fgStructure.MenuContext )
221 free( fgStructure.MenuContext );
222 fgStructure.MenuContext = NULL;
225 fgDestroyStructure();
227 while( timer = (SFG_Timer *)fgState.Timers.First )
229 fgListRemove ( &fgState.Timers, &timer->Node );
235 fgState.Position.X = -1;
236 fgState.Position.Y = -1;
237 fgState.Position.Use = FALSE;
239 fgState.Size.X = 300;
240 fgState.Size.Y = 300;
241 fgState.Size.Use = TRUE;
243 fgState.DisplayMode = GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH;
245 fgState.ForceDirectContext = FALSE;
246 fgState.TryDirectContext = TRUE;
247 fgState.ForceIconic = FALSE;
248 fgState.UseCurrentContext = FALSE;
249 fgState.GLDebugSwitch = FALSE;
250 fgState.XSyncSwitch = FALSE;
251 fgState.ActionOnWindowClose = GLUT_ACTION_EXIT ;
252 fgState.ExecState = GLUT_EXEC_STATE_INIT ;
254 fgState.IgnoreKeyRepeat = TRUE;
256 fgState.GameModeSize.X = 640;
257 fgState.GameModeSize.Y = 480;
258 fgState.GameModeDepth = 16;
259 fgState.GameModeRefresh = 72;
261 fgState.Time.Set = FALSE;
263 fgState.Timers.First = fgState.Timers.Last = NULL;
264 fgState.IdleCallback = NULL;
265 fgState.MenuStateCallback = (FGCBMenuState)NULL;
266 fgState.MenuStatusCallback = (FGCBMenuStatus)NULL;
268 fgState.SwapCount = 0;
269 fgState.SwapTime = 0;
270 fgState.FPSInterval = 0;
272 if( fgState.ProgramName )
274 free( fgState.ProgramName );
275 fgState.ProgramName = NULL;
279 #if TARGET_HOST_UNIX_X11
282 * Make sure all X-client data we have created will be destroyed on
285 XSetCloseDownMode( fgDisplay.Display, DestroyAll );
288 * Close the display connection, destroying all windows we have
291 XCloseDisplay( fgDisplay.Display );
297 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
300 * Perform initialization. This usually happens on the program startup
301 * and restarting after glutMainLoop termination...
303 void FGAPIENTRY glutInit( int* pargc, char** argv )
305 char* displayName = NULL;
306 int i, j, argc = *pargc;
308 if (pargc && *pargc && argv && *argv && **argv)
309 fgState.ProgramName = strdup (*argv);
311 fgState.ProgramName = strdup ("");
312 if (!fgState.ProgramName)
313 fgError ("Could not allocate space for the program's name.");
315 if( fgState.Time.Set )
316 fgError( "illegal glutInit() reinitialization attemp" );
320 #if TARGET_HOST_UNIX_X11
321 gettimeofday(&fgState.Time.Value, NULL);
322 #elif TARGET_HOST_WIN32
323 fgState.Time.Value = timeGetTime();
325 fgState.Time.Set = TRUE;
327 /* check if GLUT_FPS env var is set */
329 const char *fps = getenv ( "GLUT_FPS" );
332 sscanf( fps, "%d", &fgState.FPSInterval );
333 if( fgState.FPSInterval <= 0 )
334 fgState.FPSInterval = 5000; /* 5000 milliseconds */
338 #if TARGET_HOST_WIN32
339 if( !getenv( "DISPLAY" ) )
340 displayName = strdup( "" );
343 displayName = strdup( getenv( "DISPLAY" ) );
345 fgError ("Could not allocate space for display name.");
347 for( i=1; i<argc; i++ )
349 if( strcmp( argv[ i ], "-display" ) == 0 )
352 fgError( "-display parameter must be followed by display name" );
356 displayName = strdup( argv[ i ] );
358 fgError( "Could not allocate space for display name (%s)",
361 argv[ i - 1 ] = NULL;
365 else if( strcmp( argv[ i ], "-geometry" ) == 0 )
371 fgError( "-geometry parameter must be followed by window "
372 "geometry settings" );
373 result = sscanf ( argv[i], "%dx%d+%d+%d", &x, &y, &w, &h );
384 fgDisplay.ScreenHeight + y - fgState.Size.Y;
386 fgState.Position.Y = y;
393 fgDisplay.ScreenWidth + x - fgState.Size.X;
395 fgState.Position.X = x;
398 argv[ i - 1 ] = NULL;
402 else if( strcmp( argv[ i ], "-direct" ) == 0)
404 if( fgState.TryDirectContext == FALSE )
405 fgError( "parameters ambiguity, -direct and -indirect "
406 "cannot be both specified" );
408 fgState.ForceDirectContext = TRUE;
412 else if( strcmp( argv[ i ], "-indirect" ) == 0 )
414 if( fgState.ForceDirectContext == TRUE )
415 fgError( "parameters ambiguity, -direct and -indirect "
416 "cannot be both specified" );
418 fgState.TryDirectContext = FALSE;
422 else if( strcmp( argv[ i ], "-iconic" ) == 0 )
424 fgState.ForceIconic = TRUE;
428 else if( strcmp( argv[ i ], "-gldebug" ) == 0 )
430 fgState.GLDebugSwitch = TRUE;
434 else if( strcmp( argv[ i ], "-sync" ) == 0 )
436 fgState.XSyncSwitch = TRUE;
446 for( i = 1; i < *pargc; i++, j++ )
448 if( argv[ i ] == NULL )
450 /* Guaranteed to end because there are "*pargc" arguments left */
451 while ( argv[j] == NULL )
458 * Have the display created now. As I am too lazy to implement
459 * the program arguments parsing, we will have the DISPLAY
460 * environment variable used for opening the X display:
462 * XXX The above comment is rather unclear. We have just
463 * XXX completed parsing of the program arguments for GLUT
464 * XXX parameters. We obviously canNOT parse the application-
465 * XXX specific parameters. Can someone re-write the above
468 fgInitialize( displayName );
471 * Check for the minus one settings for both position and size...
473 if( fgState.Position.X < 0 || fgState.Position.Y < 0 )
474 fgState.Position.Use = FALSE;
476 if( fgState.Size.X < 0 || fgState.Size.Y < 0 )
477 fgState.Size.Use = FALSE;
484 * Sets the default initial window position for new windows
486 void FGAPIENTRY glutInitWindowPosition( int x, int y )
488 if( (x >= 0) && (y >= 0) )
490 fgState.Position.X = x;
491 fgState.Position.Y = y;
492 fgState.Position.Use = TRUE;
496 fgState.Position.X = -1;
497 fgState.Position.Y = -1;
498 fgState.Position.Use = FALSE;
503 * Sets the default initial window size for new windows
505 void FGAPIENTRY glutInitWindowSize( int width, int height )
507 if( (width > 0) && (height > 0) )
509 fgState.Size.X = width;
510 fgState.Size.Y = height;
511 fgState.Size.Use = TRUE;
517 fgState.Size.Use = FALSE;
522 * Sets the default display mode for all new windows
524 void FGAPIENTRY glutInitDisplayMode( unsigned int displayMode )
527 * We will make use of this value when creating a new OpenGL context...
529 fgState.DisplayMode = displayMode;
533 /* -- INIT DISPLAY STRING PARSING ------------------------------------------ */
535 #if 0 /* FIXME: CJP */
537 * There is a discrete number of comparison operators we can encounter:
539 * comparison ::= "=" | "!=" | "<" | ">" | "<=" | ">=" | "~"
541 #define FG_NONE 0x0000
542 #define FG_EQUAL 0x0001
543 #define FG_NOT_EQUAL 0x0002
544 #define FG_LESS 0x0003
545 #define FG_MORE 0x0004
546 #define FG_LESS_OR_EQUAL 0x0005
547 #define FG_MORE_OR_EQUAL 0x0006
548 #define FG_CLOSEST 0x0007
551 * The caller can feed us with a number of capability tokens:
553 * capability ::= "alpha" | "acca" | "acc" | "blue" | "buffer" | "conformant" | "depth" | "double" |
554 * "green" | "index" | "num" | "red" | "rgba" | "rgb" | "luminance" | "stencil" |
555 * "single" | "stereo" | "samples" | "slow" | "win32pdf" | "xvisual" | "xstaticgray" |
556 * "xgrayscale" | "xstaticcolor" | "xpseudocolor" | "xtruecolor" | "xdirectcolor"
558 static gchar* g_Tokens[] =
560 "none", "alpha", "acca", "acc", "blue", "buffer", "conformant", "depth", "double", "green",
561 "index", "num", "red", "rgba", "rgb", "luminance", "stencil", "single", "stereo", "samples",
562 "slow", "win32pdf", "xvisual", "xstaticgray", "xgrayscale", "xstaticcolor", "xpseudocolor",
563 "xtruecolor", "xdirectcolor", NULL
567 * The structure to hold the parsed display string tokens
569 typedef struct tagSFG_Capability SFG_Capability;
570 struct tagSFG_Capability
572 gint capability; /* the capability token enumerator */
573 gint comparison; /* the comparison operator used */
574 gint value; /* the value we're comparing to */
578 * The scanner configuration for the init display string
580 static GScannerConfig fgInitDisplayStringScannerConfig =
582 ( " \t\r\n" ) /* cset_skip_characters */,
587 ) /* cset_identifier_first */,
595 ) /* cset_identifier_nth */,
596 ( "#\n" ) /* cpair_comment_single */,
597 FALSE /* case_sensitive */,
598 TRUE /* skip_comment_multi */,
599 TRUE /* skip_comment_single */,
600 TRUE /* scan_comment_multi */,
601 TRUE /* scan_identifier */,
602 FALSE /* scan_identifier_1char */,
603 FALSE /* scan_identifier_NULL */,
604 TRUE /* scan_symbols */,
605 FALSE /* scan_binary */,
606 TRUE /* scan_octal */,
607 TRUE /* scan_float */,
609 FALSE /* scan_hex_dollar */,
610 TRUE /* scan_string_sq */,
611 TRUE /* scan_string_dq */,
612 TRUE /* numbers_2_int */,
613 FALSE /* int_2_float */,
614 FALSE /* identifier_2_string */,
615 TRUE /* char_2_token */,
616 FALSE /* symbol_2_token */,
617 FALSE /* scope_0_fallback */,
621 * Sets the default display mode for all new windows using a string
623 void FGAPIENTRY glutInitDisplayString( char* displayMode )
626 * display_string ::= (switch)
627 * switch ::= capability [comparison value]
628 * comparison ::= "=" | "!=" | "<" | ">" | "<=" | ">=" | "~"
629 * capability ::= "alpha" | "acca" | "acc" | "blue" | "buffer" | "conformant" |
630 * "depth" | "double" | "green" | "index" | "num" | "red" | "rgba" |
631 * "rgb" | "luminance" | "stencil" | "single" | "stereo" |
632 * "samples" | "slow" | "win32pdf" | "xvisual" | "xstaticgray" |
633 * "xgrayscale" | "xstaticcolor" | "xpseudocolor" |
634 * "xtruecolor" | "xdirectcolor"
635 * value ::= 0..9 [value]
637 * The display string grammar. This should be EBNF, but I couldn't find the definitions so, to
638 * clarify: (expr) means 0 or more times the expression, [expr] means 0 or 1 times expr.
640 * Create a new GLib lexical analyzer to process the display mode string
642 GScanner* scanner = g_scanner_new( &fgInitDisplayStringScannerConfig );
647 * Fail if the display mode string is empty or the scanner failed to initialize
649 freeglut_return_if_fail( (scanner != NULL) && (strlen( displayMode ) > 0) );
652 * Set the scanner's input name (for debugging)
654 scanner->input_name = "glutInitDisplayString";
657 * Start the lexical analysis of the extensions string
659 g_scanner_input_text( scanner, displayMode, strlen( displayMode ) );
662 * While there are any more tokens to be checked...
664 while( !g_scanner_eof( scanner ) )
667 * Actually we're expecting only string tokens
669 GTokenType tokenType = g_scanner_get_next_token( scanner );
672 * We are looking for identifiers
674 if( tokenType == G_TOKEN_IDENTIFIER )
676 gchar* capability = NULL; /* the capability identifier string (always present) */
677 gint capID = 0; /* the capability identifier value (from g_Tokens) */
678 gint comparison = 0; /* the comparison operator value, see definitions */
679 gchar* valueString = NULL; /* if the previous one is present, this is needed */
680 gint value = 0; /* the integer value converted using a strtol call */
681 SFG_Capability* capStruct; /* the capability description structure */
684 * OK. The general rule of thumb that we always should be getting a capability identifier
685 * string (see the grammar description). If it is followed by a comparison identifier, then
686 * there must follow an integer value we're comparing the capability to...
688 * Have the current token analyzed with that in mind...
690 for( i=0; i<(gint) strlen( scanner->value.v_identifier ); i++ )
692 gchar c = scanner->value.v_identifier[ i ];
694 if( (c == '=') || (c == '!') || (c == '<') || (c == '>') || (c == '~') )
699 * Here we go with the length of the capability identifier string.
700 * In the worst of cases, it is as long as the token identifier.
702 capability = g_strndup( scanner->value.v_identifier, i );
705 * OK. Is there a chance for comparison and value identifiers to follow?
706 * Note: checking against i+1 as this handles two cases: single character
707 * comparison operator and first of value's digits, which must always be
708 * there, or the two-character comparison operators.
710 if( (i + 1) < (gint) strlen( scanner->value.v_identifier ) )
713 * Yeah, indeed, it is the i-th character to start the identifier, then.
715 gchar c1 = scanner->value.v_identifier[ i + 0 ];
716 gchar c2 = scanner->value.v_identifier[ i + 1 ];
718 if( (c1 == '=') ) { i += 1; comparison = FG_EQUAL; } else
719 if( (c1 == '!') && (c2 == '=') ) { i += 2; comparison = FG_NOT_EQUAL; } else
720 if( (c1 == '<') && (c2 == '=') ) { i += 2; comparison = FG_LESS_OR_EQUAL; } else
721 if( (c1 == '>') && (c2 == '=') ) { i += 2; comparison = FG_MORE_OR_EQUAL; } else
722 if( (c1 == '<') ) { i += 1; comparison = FG_LESS; } else
723 if( (c1 == '>') ) { i += 1; comparison = FG_MORE; } else
724 if( (c1 == '~') ) { i += 1; comparison = FG_CLOSEST; } else
725 g_warning( "invalid comparison operator in token `%s'", scanner->value.v_identifier );
729 * Grab the value string that must follow the comparison operator...
731 if( comparison != FG_NONE && i < (gint) strlen( scanner->value.v_identifier ) )
733 valueString = strdup( scanner->value.v_identifier + i );
735 fgError ("Could not allocate an internal string.");
739 * If there was a value string, convert it to integer...
741 if( comparison != FG_NONE && strlen( valueString ) > 0 )
742 value = strtol( valueString, NULL, 0 );
745 * Now we need to match the capability string and its ID
747 for( i=0; g_Tokens[ i ]!=NULL; i++ )
749 if( strcmp( capability, g_Tokens[ i ] ) == 0 )
752 * Looks like we've found the one we were looking for
760 * Create a new capability description structure
762 capStruct = g_new0( SFG_Capability, 1 );
765 * Fill in the cap's values, as we have parsed it:
767 capStruct->capability = capID;
768 capStruct->comparison = comparison;
769 capStruct->value = value;
772 * Add the new capabaility to the caps list
774 caps = g_list_append( caps, capStruct );
777 * Clean up the local mess and keep rolling on
779 g_free( valueString );
780 g_free( capability );
785 * Now that we have converted the string into somewhat more machine-friendly
786 * form, proceed with matching the frame buffer configuration...
788 * The caps list could be passed to a function that would try finding the closest
789 * matching pixel format, visual, frame buffer configuration or whatever. It would
790 * be good to convert the glutInitDisplayMode() to use the same method.
793 g_message( "found %i capability preferences", g_list_length( caps ) );
795 g_message( "token `%s': cap: %i, com: %i, val: %i",
796 scanner->value.v_identifier,
797 capStruct->capability,
798 capStruct->comparison,
804 * Free the capabilities we have parsed
806 for( i=0; i<(gint) g_list_length( caps ); i++ )
807 g_free( g_list_nth( caps, i )->data );
810 * Destroy the capabilities list itself
815 * Free the lexical scanner now...
817 g_scanner_destroy( scanner );
821 #define NUM_TOKENS 28
822 static char* Tokens[] =
824 "alpha", "acca", "acc", "blue", "buffer", "conformant", "depth", "double", "green",
825 "index", "num", "red", "rgba", "rgb", "luminance", "stencil", "single", "stereo", "samples",
826 "slow", "win32pdf", "xvisual", "xstaticgray", "xgrayscale", "xstaticcolor", "xpseudocolor",
827 "xtruecolor", "xdirectcolor"
830 static int TokenLengths[] =
832 5, 4, 3, 4, 6, 10, 5, 6, 5,
833 5, 3, 3, 4, 3, 9, 7, 6, 6, 7,
834 4, 8, 7, 11, 10, 12, 12,
838 void FGAPIENTRY glutInitDisplayString( const char* displayMode )
840 int glut_state_flag = 0 ;
842 * Unpack a lot of options from a character string. The options are delimited by blanks or tabs.
845 int len = strlen ( displayMode ) ;
846 char *buffer = (char *)malloc ( (len+1) * sizeof(char) ) ;
847 memcpy ( buffer, displayMode, len ) ;
850 token = strtok ( buffer, " \t" ) ;
857 for ( i = 0; i < NUM_TOKENS; i++ )
859 if ( strncmp ( token, Tokens[i], TokenLengths[i] ) == 0 ) break ;
864 case 0 : /* "alpha": Alpha color buffer precision in bits */
865 glut_state_flag |= GLUT_ALPHA ; /* Somebody fix this for me! */
868 case 1 : /* "acca": Red, green, blue, and alpha accumulation buffer precision in bits */
871 case 2 : /* "acc": Red, green, and blue accumulation buffer precision in bits with zero bits alpha */
872 glut_state_flag |= GLUT_ACCUM ; /* Somebody fix this for me! */
875 case 3 : /* "blue": Blue color buffer precision in bits */
878 case 4 : /* "buffer": Number of bits in the color index color buffer */
881 case 5 : /* "conformant": Boolean indicating if the frame buffer configuration is conformant or not */
884 case 6 : /* "depth": Number of bits of precsion in the depth buffer */
885 glut_state_flag |= GLUT_DEPTH ; /* Somebody fix this for me! */
888 case 7 : /* "double": Boolean indicating if the color buffer is double buffered */
889 glut_state_flag |= GLUT_DOUBLE ;
892 case 8 : /* "green": Green color buffer precision in bits */
895 case 9 : /* "index": Boolean if the color model is color index or not */
896 glut_state_flag |= GLUT_INDEX ;
899 case 10 : /* "num": A special capability name indicating where the value represents the Nth frame buffer configuration matching the description string */
902 case 11 : /* "red": Red color buffer precision in bits */
905 case 12 : /* "rgba": Number of bits of red, green, blue, and alpha in the RGBA color buffer */
906 glut_state_flag |= GLUT_RGBA ; /* Somebody fix this for me! */
909 case 13 : /* "rgb": Number of bits of red, green, and blue in the RGBA color buffer with zero bits alpha */
910 glut_state_flag |= GLUT_RGB ; /* Somebody fix this for me! */
913 case 14 : /* "luminance": Number of bits of red in the RGBA and zero bits of green, blue (alpha not specified) of color buffer precision */
914 glut_state_flag |= GLUT_LUMINANCE ; /* Somebody fix this for me! */
917 case 15 : /* "stencil": Number of bits in the stencil buffer */
918 glut_state_flag |= GLUT_STENCIL ; /* Somebody fix this for me! */
921 case 16 : /* "single": Boolean indicate the color buffer is single buffered */
922 glut_state_flag |= GLUT_SINGLE ;
925 case 17 : /* "stereo": Boolean indicating the color buffer supports OpenGL-style stereo */
926 glut_state_flag |= GLUT_STEREO ;
929 case 18 : /* "samples": Indicates the number of multisamples to use based on GLX's SGIS_multisample extension (for antialiasing) */
930 glut_state_flag |= GLUT_MULTISAMPLE ; /* Somebody fix this for me! */
933 case 19 : /* "slow": Boolean indicating if the frame buffer configuration is slow or not */
936 case 20 : /* "win32pdf": matches the Win32 Pixel Format Descriptor by number */
937 #if TARGET_HOST_WIN32
941 case 21 : /* "xvisual": matches the X visual ID by number */
942 #if TARGET_HOST_UNIX_X11
946 case 22 : /* "xstaticgray": boolean indicating if the frame buffer configuration's X visual is of type StaticGray */
947 #if TARGET_HOST_UNIX_X11
951 case 23 : /* "xgrayscale": boolean indicating if the frame buffer configuration's X visual is of type GrayScale */
952 #if TARGET_HOST_UNIX_X11
956 case 24 : /* "xstaticcolor": boolean indicating if the frame buffer configuration's X visual is of type StaticColor */
957 #if TARGET_HOST_UNIX_X11
961 case 25 : /* "xpseudocolor": boolean indicating if the frame buffer configuration's X visual is of type PseudoColor */
962 #if TARGET_HOST_UNIX_X11
966 case 26 : /* "xtruecolor": boolean indicating if the frame buffer configuration's X visual is of type TrueColor */
967 #if TARGET_HOST_UNIX_X11
971 case 27 : /* "xdirectcolor": boolean indicating if the frame buffer configuration's X visual is of type DirectColor */
972 #if TARGET_HOST_UNIX_X11
976 case 28 : /* Unrecognized */
977 printf ( "WARNING - Display string token not recognized: %s\n", token ) ;
981 token = strtok ( NULL, " \t" ) ;
987 * We will make use of this value when creating a new OpenGL context...
989 fgState.DisplayMode = glut_state_flag;
992 /*** END OF FILE ***/