Search
lxdream.org :: lxdream/src/pvr2/glutil.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/glutil.c
changeset 1134:f502f3d32f90
prev1129:7b16bbd6209c
next1140:7dc1c71ece76
author nkeynes
date Sun Oct 24 15:22:59 2010 +1000 (13 years ago)
permissions -rw-r--r--
last change Eliminate GL_REPLACE tex mode in favour of GL_MODULATE (by setting colour
values to 1.0) - one less case for shaders to care about later
file annotate diff log raw
1.1 --- a/src/pvr2/glutil.c Fri Sep 17 20:05:34 2010 +1000
1.2 +++ b/src/pvr2/glutil.c Sun Oct 24 15:22:59 2010 +1000
1.3 @@ -41,6 +41,12 @@
1.4 return isGLExtensionSupported("GL_ARB_texture_mirrored_repeat");
1.5 }
1.6
1.7 +gboolean isGLVertexRangeSupported()
1.8 +{
1.9 + return isGLExtensionSupported("GL_APPLE_vertex_array_range") ||
1.10 + isGLExtensionSupported("GL_NV_vertex_array_range");
1.11 +}
1.12 +
1.13 /**
1.14 * Test if a specific extension is supported. From opengl.org
1.15 * @param extension extension name to check for
1.16 @@ -86,23 +92,66 @@
1.17 return strcmp(*ca, *cb);
1.18 }
1.19
1.20 -void glPrintInfo( FILE *out )
1.21 +#define DEFAULT_TERMINAL_COLUMNS 80
1.22 +#define DEFAULT_COLUMN_WIDTH 34
1.23 +
1.24 +/**
1.25 + * Format a GL extension list (or other space-separated string) nicely, and
1.26 + * print to the given output stream.
1.27 + */
1.28 +
1.29 +void fprint_extensions( FILE *out, const char *extensions )
1.30 {
1.31 - const gchar *extensions = (const gchar *)glGetString(GL_EXTENSIONS);
1.32 - gchar **ext_split = g_strsplit(extensions, " ", 0);
1.33 - unsigned int i, count;
1.34 + unsigned int i, j, count, maxlen = DEFAULT_COLUMN_WIDTH, columns, per_column, terminal_columns;
1.35 + const char *terminal_columns_str = getenv("COLUMNS");
1.36 + if( terminal_columns_str == NULL || (terminal_columns = strtol(terminal_columns_str,0,10)) == 0 )
1.37 + terminal_columns = DEFAULT_TERMINAL_COLUMNS;
1.38
1.39 - for( count = 0; ext_split[count] != NULL; count++ );
1.40 + if( extensions == NULL || extensions[0] == '\0' )
1.41 + return;
1.42 +
1.43 + gchar *ext_dup = g_strdup(extensions);
1.44 + gchar **ext_split = g_strsplit(g_strstrip(extensions), " ", 0);
1.45 + for( count = 0; ext_split[count] != NULL; count++ ) {
1.46 + unsigned len = strlen(ext_split[count]);
1.47 + if( len > maxlen )
1.48 + maxlen = len;
1.49 + }
1.50 +
1.51 + columns = terminal_columns / (maxlen+2);
1.52 + if( columns == 0 )
1.53 + columns = 1;
1.54 + per_column = (count+columns-1) / columns;
1.55
1.56 qsort(ext_split, count, sizeof(gchar *), compare_charp);
1.57
1.58 + for( i=0; i<per_column; i++ ) {
1.59 + for( j=0; j<columns; j++ ) {
1.60 + unsigned idx = i + (j*per_column);
1.61 + if( idx < count )
1.62 + fprintf( out, " %-*s", maxlen, ext_split[idx] );
1.63 + }
1.64 + fprintf( out, "\n" );
1.65 + }
1.66 + g_strfreev(ext_split);
1.67 + g_free(ext_dup);
1.68 +}
1.69 +
1.70 +void glPrintInfo( FILE *out )
1.71 +{
1.72 fprintf( out, "GL Vendor: %s\n", glGetString(GL_VENDOR) );
1.73 fprintf( out, "GL Renderer: %s\n", glGetString(GL_RENDERER) );
1.74 fprintf( out, "GL Version: %s\n", glGetString(GL_VERSION) );
1.75 + if( glsl_is_supported() ) {
1.76 + const char * version = glsl_get_version();
1.77 + fprintf( out, "SL Version: %s\n", version );
1.78 + }
1.79
1.80 - fprintf( out, "Supported GL Extensions:\n" );
1.81 - for( i=0; ext_split[i] != NULL; i++ ) {
1.82 - fprintf( out, " %s\n", ext_split[i] );
1.83 + fprintf( out, "GL Extensions:\n" );
1.84 +
1.85 + fprint_extensions( out, (const gchar *)glGetString(GL_EXTENSIONS) );
1.86 + if( display_driver && display_driver->print_info ) {
1.87 + fprintf( out, "\n");
1.88 + display_driver->print_info(out);
1.89 }
1.90 - g_strfreev(ext_split);
1.91 }
.