filename | src/pvr2/glutil.c |
changeset | 736:a02d1475ccfd |
prev | 700:4650d0c7f6f9 |
next | 1066:ddffe9d2b332 |
author | nkeynes |
date | Wed Jul 30 22:50:44 2008 +0000 (15 years ago) |
permissions | -rw-r--r-- |
last change | Bug #61: OpenBSD support (Modified) patch from bsdmaniak, thanks! |
view | annotate | diff | log | raw |
1 /**
2 * $Id$
3 *
4 * GL-based support functions
5 *
6 * Copyright (c) 2005 Nathan Keynes.
7 *
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.
12 *
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.
17 */
19 #include <string.h>
20 #include <glib/gstrfuncs.h>
21 #include "pvr2/glutil.h"
23 gboolean isGLSecondaryColorSupported()
24 {
25 return isGLExtensionSupported("GL_EXT_secondary_color");
26 }
28 gboolean isGLVertexBufferSupported()
29 {
30 return isGLExtensionSupported("GL_ARB_vertex_buffer_object");
31 }
33 gboolean isGLPixelBufferSupported()
34 {
35 return isGLExtensionSupported("GL_ARB_pixel_buffer_object");
36 }
38 gboolean isGLMirroredTextureSupported()
39 {
40 return isGLExtensionSupported("GL_ARB_texture_mirrored_repeat");
41 }
43 /**
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.
47 */
48 gboolean isGLExtensionSupported( const char *extension )
49 {
50 const GLubyte *extensions = NULL;
51 const GLubyte *start;
52 GLubyte *where, *terminator;
54 /* Extension names should not have spaces. */
55 where = (GLubyte *) strchr(extension, ' ');
56 if (where || *extension == '\0')
57 return 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. */
62 return FALSE;
63 }
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,
66 etc. */
67 start = extensions;
68 for (;;) {
69 where = (GLubyte *) strstr((const char *) start, extension);
70 if (!where)
71 break;
72 terminator = where + strlen(extension);
73 if (where == start || *(where - 1) == ' ')
74 if (*terminator == ' ' || *terminator == '\0')
75 return TRUE;
76 start = terminator;
77 }
78 return FALSE;
79 }
81 void glPrintInfo( FILE *out )
82 {
83 const gchar *extensions = (const gchar *)glGetString(GL_EXTENSIONS);
84 gchar **ext_split = g_strsplit(extensions, " ", 0);
85 unsigned int i;
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] );
94 }
95 g_strfreev(ext_split);
96 }
.