Search
lxdream.org :: lxdream/src/pvr2/glutil.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/glutil.c
changeset 667:0e1ac8da75d9
prev653:3202ff01d48e
next687:6bdc2b7032ea
author nkeynes
date Mon May 12 10:00:13 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Cleanup most of the -Wall warnings (getting a bit sloppy...)
Convert FP code to use fixed banks rather than indirect pointer
(3-4% faster this way 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 gboolean isGLSecondaryColorSupported()
    22 {
    23 	return isGLExtensionSupported("GL_EXT_secondary_color");
    24 }
    26 gboolean isGLVertexBufferSupported()
    27 {
    28 	return isGLExtensionSupported("GL_ARB_vertex_buffer_object");
    29 }
    31 gboolean isGLPixelBufferSupported()
    32 {
    33 	return isGLExtensionSupported("GL_ARB_pixel_buffer_object");
    34 }
    36 gboolean isGLMirroredTextureSupported()
    37 {
    38 	return isGLExtensionSupported("GL_ARB_texture_mirrored_repeat");
    39 }
    41 /**
    42  * Test if a specific extension is supported. From opengl.org
    43  * @param extension extension name to check for
    44  * @return TRUE if supported, otherwise FALSE.
    45  */
    46 gboolean isGLExtensionSupported( const char *extension )
    47 {
    48     const GLubyte *extensions = NULL;
    49     const GLubyte *start;
    50     GLubyte *where, *terminator;
    52     /* Extension names should not have spaces. */
    53     where = (GLubyte *) strchr(extension, ' ');
    54     if (where || *extension == '\0')
    55 	return 0;
    56     extensions = glGetString(GL_EXTENSIONS);
    57     if( extensions == NULL ) {
    58 	/* No GL available, so we're pretty sure the extension isn't
    59 	 * available either. */
    60 	return FALSE;
    61     }
    62     /* It takes a bit of care to be fool-proof about parsing the
    63        OpenGL extensions string. Don't be fooled by sub-strings,
    64        etc. */
    65     start = extensions;
    66     for (;;) {
    67 	where = (GLubyte *) strstr((const char *) start, extension);
    68 	if (!where)
    69 	    break;
    70 	terminator = where + strlen(extension);
    71 	if (where == start || *(where - 1) == ' ')
    72 	    if (*terminator == ' ' || *terminator == '\0')
    73 		return TRUE;
    74 	start = terminator;
    75     }
    76     return FALSE;
    77 }
.