Search
lxdream.org :: lxdream/src/drivers/video_gl.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/video_gl.c
changeset 280:715202395e0f
next290:4d11ef6766be
author nkeynes
date Sun Jan 14 02:55:06 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Add GL common file
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/drivers/video_gl.c Sun Jan 14 02:55:06 2007 +0000
1.3 @@ -0,0 +1,72 @@
1.4 +/**
1.5 + * $Id: video_gl.c,v 1.1 2007-01-14 02:55:06 nkeynes Exp $
1.6 + *
1.7 + * Common GL code that doesn't depend on a specific implementation
1.8 + *
1.9 + * Copyright (c) 2005 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#include "dream.h"
1.23 +#include "drivers/video_gl.h"
1.24 +#include <GL/gl.h>
1.25 +
1.26 +char *required_extensions[] = { "GL_EXT_framebuffer_object", NULL };
1.27 +
1.28 +/**
1.29 + * Test if a specific extension is supported. From opengl.org
1.30 + * @param extension extension name to check for
1.31 + * @return TRUE if supported, otherwise FALSE.
1.32 + */
1.33 +gboolean isGLExtensionSupported( const char *extension )
1.34 +{
1.35 + const GLubyte *extensions = NULL;
1.36 + const GLubyte *start;
1.37 + GLubyte *where, *terminator;
1.38 +
1.39 + /* Extension names should not have spaces. */
1.40 + where = (GLubyte *) strchr(extension, ' ');
1.41 + if (where || *extension == '\0')
1.42 + return 0;
1.43 + extensions = glGetString(GL_EXTENSIONS);
1.44 + /* It takes a bit of care to be fool-proof about parsing the
1.45 + OpenGL extensions string. Don't be fooled by sub-strings,
1.46 + etc. */
1.47 + start = extensions;
1.48 + for (;;) {
1.49 + where = (GLubyte *) strstr((const char *) start, extension);
1.50 + if (!where)
1.51 + break;
1.52 + terminator = where + strlen(extension);
1.53 + if (where == start || *(where - 1) == ' ')
1.54 + if (*terminator == ' ' || *terminator == '\0')
1.55 + return TRUE;
1.56 + start = terminator;
1.57 + }
1.58 + return FALSE;
1.59 +}
1.60 +
1.61 +gboolean hasRequiredGLExtensions( )
1.62 +{
1.63 + int i;
1.64 + gboolean isOK = TRUE;
1.65 + fprintf( stdout, "GL Extensions: %s\n", glGetString(GL_EXTENSIONS) );
1.66 +
1.67 +
1.68 + for( i=0; required_extensions[i] != NULL; i++ ) {
1.69 + if( !isGLExtensionSupported(required_extensions[i]) ) {
1.70 + ERROR( "Required OpenGL extension not supported: %s", required_extensions[i] );
1.71 + isOK = FALSE;
1.72 + }
1.73 + }
1.74 + return isOK;
1.75 +}
.