Search
lxdream.org :: lxdream/src/drivers/video_gl.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/video_gl.c
changeset 290:4d11ef6766be
prev280:715202395e0f
author nkeynes
date Mon Jan 15 12:57:12 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Remove extension fprintf (accidental commit)
view annotate diff log raw
     1 /**
     2  * $Id: video_gl.c,v 1.2 2007-01-15 12:57:12 nkeynes Exp $
     3  *
     4  * Common GL code that doesn't depend on a specific implementation
     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  */
    19 #include "dream.h"
    20 #include "drivers/video_gl.h"
    21 #include <GL/gl.h>
    23 char *required_extensions[] = { "GL_EXT_framebuffer_object", NULL };
    25 /**
    26  * Test if a specific extension is supported. From opengl.org
    27  * @param extension extension name to check for
    28  * @return TRUE if supported, otherwise FALSE.
    29  */
    30 gboolean isGLExtensionSupported( const char *extension )
    31 {
    32     const GLubyte *extensions = NULL;
    33     const GLubyte *start;
    34     GLubyte *where, *terminator;
    36     /* Extension names should not have spaces. */
    37     where = (GLubyte *) strchr(extension, ' ');
    38     if (where || *extension == '\0')
    39 	return 0;
    40     extensions = glGetString(GL_EXTENSIONS);
    41     /* It takes a bit of care to be fool-proof about parsing the
    42        OpenGL extensions string. Don't be fooled by sub-strings,
    43        etc. */
    44     start = extensions;
    45     for (;;) {
    46 	where = (GLubyte *) strstr((const char *) start, extension);
    47 	if (!where)
    48 	    break;
    49 	terminator = where + strlen(extension);
    50 	if (where == start || *(where - 1) == ' ')
    51 	    if (*terminator == ' ' || *terminator == '\0')
    52 		return TRUE;
    53 	start = terminator;
    54     }
    55     return FALSE;
    56 }
    58 gboolean hasRequiredGLExtensions( ) 
    59 {
    60     int i;
    61     gboolean isOK = TRUE;
    63     for( i=0; required_extensions[i] != NULL; i++ ) {
    64 	if( !isGLExtensionSupported(required_extensions[i]) ) {
    65 	    ERROR( "Required OpenGL extension not supported: %s", required_extensions[i] );
    66 	    isOK = FALSE;
    67 	}
    68     }
    69     return isOK;
    70 }
.