Search
lxdream.org :: lxdream/src/pvr2/glutil.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/glutil.c
changeset 645:a7392098299c
prev636:2ccf94f966fc
next1066:ddffe9d2b332
author nkeynes
date Thu Mar 06 08:22:00 2008 +0000 (12 years ago)
branchlxdream-render
permissions -rw-r--r--
last change More refactor work in progress - nearly done now
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 "pvr2/glutil.h"
    21 /**
    22  * Test if a specific extension is supported. From opengl.org
    23  * @param extension extension name to check for
    24  * @return TRUE if supported, otherwise FALSE.
    25  */
    26 gboolean isGLExtensionSupported( const char *extension )
    27 {
    28     const GLubyte *extensions = NULL;
    29     const GLubyte *start;
    30     GLubyte *where, *terminator;
    32     /* Extension names should not have spaces. */
    33     where = (GLubyte *) strchr(extension, ' ');
    34     if (where || *extension == '\0')
    35 	return 0;
    36     extensions = glGetString(GL_EXTENSIONS);
    37     if( extensions == NULL ) {
    38 	/* No GL available, so we're pretty sure the extension isn't
    39 	 * available either. */
    40 	return FALSE;
    41     }
    42     /* It takes a bit of care to be fool-proof about parsing the
    43        OpenGL extensions string. Don't be fooled by sub-strings,
    44        etc. */
    45     start = extensions;
    46     for (;;) {
    47 	where = (GLubyte *) strstr((const char *) start, extension);
    48 	if (!where)
    49 	    break;
    50 	terminator = where + strlen(extension);
    51 	if (where == start || *(where - 1) == ' ')
    52 	    if (*terminator == ' ' || *terminator == '\0')
    53 		return TRUE;
    54 	start = terminator;
    55     }
    56     return FALSE;
    57 }
.