*/
int FGAPIENTRY glutExtensionSupported( const char* extension )
{
- /*
- * Grab the current context's OpenGL extensions
- * and create a new GLib lexical analyzer...
- */
- gchar *glExtensions = (gchar *) glGetString( GL_EXTENSIONS );
- GScanner* scanner = g_scanner_new( NULL );
- gint i;
-
- /*
- * Make sure there is a current window, and thus -- a current context available
- */
- freeglut_assert_ready; freeglut_return_val_if_fail( fgStructure.Window != NULL, 0 );
-
- /*
- * Fail if there is no extension, extensions or scanner available
- */
- freeglut_return_val_if_fail( (scanner != NULL) && (strlen( extension ) > 0)
- && (strlen( glExtensions ) > 0), 0 );
-
- /*
- * Check if the extension itself looks valid
- */
- for( i=0; i<(gint) strlen( extension ); i++ )
- if( extension[ i ] == ' ' )
- return( 0 );
+ const char *extensions;
+ const char *ptr;
+ int len = strlen ( extension ) ;
+
+ /*
+ * Make sure there is a current window, and thus -- a current context available
+ */
+ freeglut_assert_ready;
+ freeglut_return_val_if_fail( fgStructure.Window != NULL, 0 );
+
+ /*
+ * Note it is safe to query the extensions
+ */
+ extensions = glGetString(GL_EXTENSIONS);
+
+ freeglut_return_val_if_fail( extensions != NULL, 0 );
+
+ /*
+ * Check if the extension itself looks valid
+ */
+ if ( strchr ( extension, ' ' ) != NULL )
+ return( 0 );
+ /*
+ * Look for our extension
+ */
+ for (ptr = extensions; *ptr;)
+ {
/*
- * Set the scanner's input name (for debugging)
+ * Is it the current extension?
*/
- scanner->input_name = "glutExtensionSupported()";
+ if ( strncmp ( extension, extensions, len ) == 0 )
+ return 1 ;
/*
- * Start the lexical analysis of the extensions string
+ * No, go find the next extension. They are separated from each other by one or more blank spaces.
*/
- g_scanner_input_text( scanner, glExtensions, strlen( glExtensions ) );
+ ptr = strchr ( ptr + len, ' ' ) ;
/*
- * While there are any more tokens to be checked...
+ * If we ran off the end of the "extensions" character string, we didn't find it. Return failure.
*/
- while( !g_scanner_eof( scanner ) )
- {
- /*
- * Actually we're expecting only string tokens
- */
- GTokenType tokenType = g_scanner_get_next_token( scanner );
+ if ( !ptr ) return 0 ;
- /*
- * We are looking for identifiers
- */
- if( tokenType == G_TOKEN_IDENTIFIER )
- {
- /*
- * Compare the token and the extension string
- */
- if( strcmp( scanner->value.v_identifier, extension ) == 0 )
- {
- /*
- * OKi, we have found the extension string we've been looking for
- */
- g_scanner_destroy( scanner );
- return( 1 );
- }
- }
- }
+ while ( *ptr == ' ' )
+ ptr++ ;
+ }
- /*
- * Well, looks like we have failed to find the extension string
- */
- g_scanner_destroy( scanner );
- return( 0 );
+ return 0 ;
}
/*
- * This function reports all the errors that happened till now
+ * This function reports all the OpenGL errors that happened till now
*/
void FGAPIENTRY glutReportErrors( void )
{
# undef G_LOG_DOMAIN
# define G_LOG_DOMAIN ((gchar *) 0)
- g_warning( "GL error: %s", gluErrorString( error ) );
+ fgWarning( "GL error: %s", gluErrorString( error ) );
# undef G_LOG_DOMAIN
# define G_LOG_DOMAIN "freeglut_misc.c"
/*
* Turns the ignore key auto repeat feature on and off
*/
-void FGAPIENTRY glutIgnoreKeyRepeat( int ignore )
+void FGAPIENTRY glutIgnoreKeyRepeat( int ignore ) /* DEPRECATED 11/4/02 - Do not use */
{
/*
- * This is simple and not demanging...
+ * This is simple and not damaging...
*/
fgState.IgnoreKeyRepeat = ignore ? TRUE : FALSE;
}
/*
* Whoops, this was not expected at all
*/
- g_assert_not_reached();
+ break;
}
#endif