filename | src/pvr2/glutil.c |
changeset | 687:6bdc2b7032ea |
prev | 667:0e1ac8da75d9 |
next | 700:4650d0c7f6f9 |
author | nkeynes |
date | Sat Jun 14 11:54:15 2008 +0000 (15 years ago) |
permissions | -rw-r--r-- |
last change | Change colour params to float Convert background processing over to scene structure (fixes some depth issues as well) Add color unclamp when supported |
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 */
18 #include <string.h>
19 #include <glib/gstrfuncs.h>
20 #include "pvr2/glutil.h"
22 gboolean isGLSecondaryColorSupported()
23 {
24 return isGLExtensionSupported("GL_EXT_secondary_color");
25 }
27 gboolean isGLVertexBufferSupported()
28 {
29 return isGLExtensionSupported("GL_ARB_vertex_buffer_object");
30 }
32 gboolean isGLPixelBufferSupported()
33 {
34 return isGLExtensionSupported("GL_ARB_pixel_buffer_object");
35 }
37 gboolean isGLMirroredTextureSupported()
38 {
39 return isGLExtensionSupported("GL_ARB_texture_mirrored_repeat");
40 }
42 /**
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.
46 */
47 gboolean isGLExtensionSupported( const char *extension )
48 {
49 const GLubyte *extensions = NULL;
50 const GLubyte *start;
51 GLubyte *where, *terminator;
53 /* Extension names should not have spaces. */
54 where = (GLubyte *) strchr(extension, ' ');
55 if (where || *extension == '\0')
56 return 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. */
61 return FALSE;
62 }
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,
65 etc. */
66 start = extensions;
67 for (;;) {
68 where = (GLubyte *) strstr((const char *) start, extension);
69 if (!where)
70 break;
71 terminator = where + strlen(extension);
72 if (where == start || *(where - 1) == ' ')
73 if (*terminator == ' ' || *terminator == '\0')
74 return TRUE;
75 start = terminator;
76 }
77 return FALSE;
78 }
80 void glPrintInfo( FILE *out )
81 {
82 const GLubyte *extensions = glGetString(GL_EXTENSIONS);
83 gchar **ext_split = g_strsplit(extensions, " ", 0);
84 unsigned int i;
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] );
93 }
94 g_strfreev(ext_split);
95 }
.