4 * GL-based support functions
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #include <glib/gstrfuncs.h>
20 #include "pvr2/glutil.h"
22 gboolean isGLSecondaryColorSupported()
24 return isGLExtensionSupported("GL_EXT_secondary_color");
27 gboolean isGLVertexBufferSupported()
29 return isGLExtensionSupported("GL_ARB_vertex_buffer_object");
32 gboolean isGLPixelBufferSupported()
34 return isGLExtensionSupported("GL_ARB_pixel_buffer_object");
37 gboolean isGLMirroredTextureSupported()
39 return isGLExtensionSupported("GL_ARB_texture_mirrored_repeat");
43 * Test if a specific extension is supported. From opengl.org
44 * @param extension extension name to check for
45 * @return TRUE if supported, otherwise FALSE.
47 gboolean isGLExtensionSupported( const char *extension )
49 const GLubyte *extensions = NULL;
51 GLubyte *where, *terminator;
53 /* Extension names should not have spaces. */
54 where = (GLubyte *) strchr(extension, ' ');
55 if (where || *extension == '\0')
57 extensions = glGetString(GL_EXTENSIONS);
58 if( extensions == NULL ) {
59 /* No GL available, so we're pretty sure the extension isn't
60 * available either. */
63 /* It takes a bit of care to be fool-proof about parsing the
64 OpenGL extensions string. Don't be fooled by sub-strings,
68 where = (GLubyte *) strstr((const char *) start, extension);
71 terminator = where + strlen(extension);
72 if (where == start || *(where - 1) == ' ')
73 if (*terminator == ' ' || *terminator == '\0')
80 void glPrintInfo( FILE *out )
82 const GLubyte *extensions = glGetString(GL_EXTENSIONS);
83 gchar **ext_split = g_strsplit(extensions, " ", 0);
86 fprintf( out, "GL Vendor: %s\n", glGetString(GL_VENDOR) );
87 fprintf( out, "GL Renderer: %s\n", glGetString(GL_RENDERER) );
88 fprintf( out, "GL Version: %s\n", glGetString(GL_VERSION) );
90 fprintf( out, "Supported GL Extensions:\n" );
91 for( i=0; ext_split[i] != NULL; i++ ) {
92 fprintf( out, " %s\n", ext_split[i] );
94 g_strfreev(ext_split);
.