filename | src/drivers/video_gl.c |
changeset | 280:715202395e0f |
next | 290:4d11ef6766be |
author | nkeynes |
date | Mon Jan 15 08:32:09 2007 +0000 (17 years ago) |
permissions | -rw-r--r-- |
last change | Break vram routines out into pvr2mem.c Initial (untested) implementation of stride textures Hookup YUV converter code in pvr2.c |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/src/drivers/video_gl.c Mon Jan 15 08:32:09 2007 +00001.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 implementation1.8 + *1.9 + * Copyright (c) 2005 Nathan Keynes.1.10 + *1.11 + * This program is free software; you can redistribute it and/or modify1.12 + * it under the terms of the GNU General Public License as published by1.13 + * the Free Software Foundation; either version 2 of the License, or1.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 of1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1.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.org1.30 + * @param extension extension name to check for1.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 the1.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 +}
.