Search
lxdream.org :: lxdream/src/pvr2/glutil.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/glutil.c
changeset 653:3202ff01d48e
next667:0e1ac8da75d9
author nkeynes
date Fri Mar 28 12:32:25 2008 +0000 (16 years ago)
permissions -rw-r--r--
last change Merge lxdream-render branch (643:670) to trunk
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/pvr2/glutil.c Fri Mar 28 12:32:25 2008 +0000
1.3 @@ -0,0 +1,57 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * GL-based support functions
1.8 + *
1.9 + * Copyright (c) 2005 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +#include <string.h>
1.22 +#include "pvr2/glutil.h"
1.23 +
1.24 +/**
1.25 + * Test if a specific extension is supported. From opengl.org
1.26 + * @param extension extension name to check for
1.27 + * @return TRUE if supported, otherwise FALSE.
1.28 + */
1.29 +gboolean isGLExtensionSupported( const char *extension )
1.30 +{
1.31 + const GLubyte *extensions = NULL;
1.32 + const GLubyte *start;
1.33 + GLubyte *where, *terminator;
1.34 +
1.35 + /* Extension names should not have spaces. */
1.36 + where = (GLubyte *) strchr(extension, ' ');
1.37 + if (where || *extension == '\0')
1.38 + return 0;
1.39 + extensions = glGetString(GL_EXTENSIONS);
1.40 + if( extensions == NULL ) {
1.41 + /* No GL available, so we're pretty sure the extension isn't
1.42 + * available either. */
1.43 + return FALSE;
1.44 + }
1.45 + /* It takes a bit of care to be fool-proof about parsing the
1.46 + OpenGL extensions string. Don't be fooled by sub-strings,
1.47 + etc. */
1.48 + start = extensions;
1.49 + for (;;) {
1.50 + where = (GLubyte *) strstr((const char *) start, extension);
1.51 + if (!where)
1.52 + break;
1.53 + terminator = where + strlen(extension);
1.54 + if (where == start || *(where - 1) == ' ')
1.55 + if (*terminator == ' ' || *terminator == '\0')
1.56 + return TRUE;
1.57 + start = terminator;
1.58 + }
1.59 + return FALSE;
1.60 +}
.