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.
20 #include <glib/gstrfuncs.h>
21 #include "pvr2/glutil.h"
23 gboolean isGLSecondaryColorSupported()
25 return isGLExtensionSupported("GL_EXT_secondary_color");
28 gboolean isGLVertexBufferSupported()
30 return isGLExtensionSupported("GL_ARB_vertex_buffer_object");
33 gboolean isGLPixelBufferSupported()
35 return isGLExtensionSupported("GL_ARB_pixel_buffer_object");
38 gboolean isGLMirroredTextureSupported()
40 return isGLExtensionSupported("GL_ARB_texture_mirrored_repeat");
44 * Test if a specific extension is supported. From opengl.org
45 * @param extension extension name to check for
46 * @return TRUE if supported, otherwise FALSE.
48 gboolean isGLExtensionSupported( const char *extension )
50 const GLubyte *extensions = NULL;
52 GLubyte *where, *terminator;
54 /* Extension names should not have spaces. */
55 where = (GLubyte *) strchr(extension, ' ');
56 if (where || *extension == '\0')
58 extensions = glGetString(GL_EXTENSIONS);
59 if( extensions == NULL ) {
60 /* No GL available, so we're pretty sure the extension isn't
61 * available either. */
64 /* It takes a bit of care to be fool-proof about parsing the
65 OpenGL extensions string. Don't be fooled by sub-strings,
69 where = (GLubyte *) strstr((const char *) start, extension);
72 terminator = where + strlen(extension);
73 if (where == start || *(where - 1) == ' ')
74 if (*terminator == ' ' || *terminator == '\0')
81 void glPrintInfo( FILE *out )
83 const gchar *extensions = (const gchar *)glGetString(GL_EXTENSIONS);
84 gchar **ext_split = g_strsplit(extensions, " ", 0);
87 fprintf( out, "GL Vendor: %s\n", glGetString(GL_VENDOR) );
88 fprintf( out, "GL Renderer: %s\n", glGetString(GL_RENDERER) );
89 fprintf( out, "GL Version: %s\n", glGetString(GL_VERSION) );
91 fprintf( out, "Supported GL Extensions:\n" );
92 for( i=0; ext_split[i] != NULL; i++ ) {
93 fprintf( out, " %s\n", ext_split[i] );
95 g_strfreev(ext_split);
.