Search
lxdream.org :: lxdream/src/pvr2/glutil.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/glutil.c
changeset 636:2ccf94f966fc
prev635:76c63aac3590
next645:a7392098299c
author nkeynes
date Thu Feb 14 14:06:41 2008 +0000 (13 years ago)
branchlxdream-render
permissions -rw-r--r--
last change Update svn:keywords
file annotate diff log raw
nkeynes@635
     1
/**
nkeynes@636
     2
 * $Id$
nkeynes@635
     3
 *
nkeynes@635
     4
 * GL-based support functions 
nkeynes@635
     5
 *
nkeynes@635
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@635
     7
 *
nkeynes@635
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@635
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@635
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@635
    11
 * (at your option) any later version.
nkeynes@635
    12
 *
nkeynes@635
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@635
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@635
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@635
    16
 * GNU General Public License for more details.
nkeynes@635
    17
 */
nkeynes@635
    18
nkeynes@635
    19
#include "pvr2/glutil.h"
nkeynes@635
    20
nkeynes@635
    21
/**
nkeynes@635
    22
 * Test if a specific extension is supported. From opengl.org
nkeynes@635
    23
 * @param extension extension name to check for
nkeynes@635
    24
 * @return TRUE if supported, otherwise FALSE.
nkeynes@635
    25
 */
nkeynes@635
    26
gboolean isGLExtensionSupported( const char *extension )
nkeynes@635
    27
{
nkeynes@635
    28
    const GLubyte *extensions = NULL;
nkeynes@635
    29
    const GLubyte *start;
nkeynes@635
    30
    GLubyte *where, *terminator;
nkeynes@635
    31
nkeynes@635
    32
    /* Extension names should not have spaces. */
nkeynes@635
    33
    where = (GLubyte *) strchr(extension, ' ');
nkeynes@635
    34
    if (where || *extension == '\0')
nkeynes@635
    35
	return 0;
nkeynes@635
    36
    extensions = glGetString(GL_EXTENSIONS);
nkeynes@635
    37
    /* It takes a bit of care to be fool-proof about parsing the
nkeynes@635
    38
       OpenGL extensions string. Don't be fooled by sub-strings,
nkeynes@635
    39
       etc. */
nkeynes@635
    40
    start = extensions;
nkeynes@635
    41
    for (;;) {
nkeynes@635
    42
	where = (GLubyte *) strstr((const char *) start, extension);
nkeynes@635
    43
	if (!where)
nkeynes@635
    44
	    break;
nkeynes@635
    45
	terminator = where + strlen(extension);
nkeynes@635
    46
	if (where == start || *(where - 1) == ' ')
nkeynes@635
    47
	    if (*terminator == ' ' || *terminator == '\0')
nkeynes@635
    48
		return TRUE;
nkeynes@635
    49
	start = terminator;
nkeynes@635
    50
    }
nkeynes@635
    51
    return FALSE;
nkeynes@635
    52
}
.