X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=freeglut-1.3%2Ffreeglut_misc.c;h=496ca4550e36cfd95f3f8aba5039673ba5471ccd;hb=244417cf0e67e55547c077f771513e67f362a8c3;hp=4be9a3becd7e3d5b9b3d2437c31aac52aa771146;hpb=c90e3f21e02020232054f78029ef9071c7359cfb;p=freeglut diff --git a/freeglut-1.3/freeglut_misc.c b/freeglut-1.3/freeglut_misc.c index 4be9a3b..496ca45 100644 --- a/freeglut-1.3/freeglut_misc.c +++ b/freeglut-1.3/freeglut_misc.c @@ -32,7 +32,7 @@ #define G_LOG_DOMAIN "freeglut-misc" #include "../include/GL/freeglut.h" -#include "../include/GL/freeglut_internal.h" +#include "freeglut_internal.h" /* * TODO BEFORE THE STABLE RELEASE: @@ -50,80 +50,59 @@ */ 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 ) { @@ -140,7 +119,7 @@ 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" @@ -155,10 +134,10 @@ void FGAPIENTRY glutReportErrors( void ) /* * 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; } @@ -202,7 +181,7 @@ void FGAPIENTRY glutSetKeyRepeat( int repeatMode ) /* * Whoops, this was not expected at all */ - g_assert_not_reached(); + break; } #endif