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)
file annotate diff log raw
nkeynes@280
     1
/**
nkeynes@290
     2
 * $Id: video_gl.c,v 1.2 2007-01-15 12:57:12 nkeynes Exp $
nkeynes@280
     3
 *
nkeynes@280
     4
 * Common GL code that doesn't depend on a specific implementation
nkeynes@280
     5
 *
nkeynes@280
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@280
     7
 *
nkeynes@280
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@280
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@280
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@280
    11
 * (at your option) any later version.
nkeynes@280
    12
 *
nkeynes@280
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@280
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@280
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@280
    16
 * GNU General Public License for more details.
nkeynes@280
    17
 */
nkeynes@280
    18
nkeynes@280
    19
#include "dream.h"
nkeynes@280
    20
#include "drivers/video_gl.h"
nkeynes@280
    21
#include <GL/gl.h>
nkeynes@280
    22
nkeynes@280
    23
char *required_extensions[] = { "GL_EXT_framebuffer_object", NULL };
nkeynes@280
    24
nkeynes@280
    25
/**
nkeynes@280
    26
 * Test if a specific extension is supported. From opengl.org
nkeynes@280
    27
 * @param extension extension name to check for
nkeynes@280
    28
 * @return TRUE if supported, otherwise FALSE.
nkeynes@280
    29
 */
nkeynes@280
    30
gboolean isGLExtensionSupported( const char *extension )
nkeynes@280
    31
{
nkeynes@280
    32
    const GLubyte *extensions = NULL;
nkeynes@280
    33
    const GLubyte *start;
nkeynes@280
    34
    GLubyte *where, *terminator;
nkeynes@280
    35
nkeynes@280
    36
    /* Extension names should not have spaces. */
nkeynes@280
    37
    where = (GLubyte *) strchr(extension, ' ');
nkeynes@280
    38
    if (where || *extension == '\0')
nkeynes@280
    39
	return 0;
nkeynes@280
    40
    extensions = glGetString(GL_EXTENSIONS);
nkeynes@280
    41
    /* It takes a bit of care to be fool-proof about parsing the
nkeynes@280
    42
       OpenGL extensions string. Don't be fooled by sub-strings,
nkeynes@280
    43
       etc. */
nkeynes@280
    44
    start = extensions;
nkeynes@280
    45
    for (;;) {
nkeynes@280
    46
	where = (GLubyte *) strstr((const char *) start, extension);
nkeynes@280
    47
	if (!where)
nkeynes@280
    48
	    break;
nkeynes@280
    49
	terminator = where + strlen(extension);
nkeynes@280
    50
	if (where == start || *(where - 1) == ' ')
nkeynes@280
    51
	    if (*terminator == ' ' || *terminator == '\0')
nkeynes@280
    52
		return TRUE;
nkeynes@280
    53
	start = terminator;
nkeynes@280
    54
    }
nkeynes@280
    55
    return FALSE;
nkeynes@280
    56
}
nkeynes@280
    57
nkeynes@280
    58
gboolean hasRequiredGLExtensions( ) 
nkeynes@280
    59
{
nkeynes@280
    60
    int i;
nkeynes@280
    61
    gboolean isOK = TRUE;
nkeynes@280
    62
nkeynes@280
    63
    for( i=0; required_extensions[i] != NULL; i++ ) {
nkeynes@280
    64
	if( !isGLExtensionSupported(required_extensions[i]) ) {
nkeynes@280
    65
	    ERROR( "Required OpenGL extension not supported: %s", required_extensions[i] );
nkeynes@280
    66
	    isOK = FALSE;
nkeynes@280
    67
	}
nkeynes@280
    68
    }
nkeynes@280
    69
    return isOK;
nkeynes@280
    70
}
.