Search
lxdream.org :: lxdream :: r280:715202395e0f
lxdream 0.9.1
released Jun 29
Download Now
changeset280:715202395e0f
parent279:7bb759c23271
child281:2019e605cb27
authornkeynes
dateSun Jan 14 02:55:06 2007 +0000 (17 years ago)
Add GL common file
src/Makefile.am
src/drivers/video_gl.c
src/drivers/video_gl.h
src/drivers/video_x11.c
1.1 --- a/src/Makefile.am Sun Jan 14 02:54:40 2007 +0000
1.2 +++ b/src/Makefile.am Sun Jan 14 02:55:06 2007 +0000
1.3 @@ -35,7 +35,8 @@
1.4 display.c display.h \
1.5 drivers/audio_null.c drivers/audio_esd.c \
1.6 drivers/video_null.c drivers/video_gtk.c drivers/video_gtk.h \
1.7 - drivers/video_x11.c drivers/video_x11.h
1.8 + drivers/video_x11.c drivers/video_x11.h \
1.9 + drivers/video_gl.c drivers/video_gl.h
1.10
1.11 lxdream_LDADD = @PACKAGE_LIBS@ $(INTLLIBS) -lesd
1.12
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/drivers/video_gl.c Sun Jan 14 02:55:06 2007 +0000
2.3 @@ -0,0 +1,72 @@
2.4 +/**
2.5 + * $Id: video_gl.c,v 1.1 2007-01-14 02:55:06 nkeynes Exp $
2.6 + *
2.7 + * Common GL code that doesn't depend on a specific implementation
2.8 + *
2.9 + * Copyright (c) 2005 Nathan Keynes.
2.10 + *
2.11 + * This program is free software; you can redistribute it and/or modify
2.12 + * it under the terms of the GNU General Public License as published by
2.13 + * the Free Software Foundation; either version 2 of the License, or
2.14 + * (at your option) any later version.
2.15 + *
2.16 + * This program is distributed in the hope that it will be useful,
2.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.19 + * GNU General Public License for more details.
2.20 + */
2.21 +
2.22 +#include "dream.h"
2.23 +#include "drivers/video_gl.h"
2.24 +#include <GL/gl.h>
2.25 +
2.26 +char *required_extensions[] = { "GL_EXT_framebuffer_object", NULL };
2.27 +
2.28 +/**
2.29 + * Test if a specific extension is supported. From opengl.org
2.30 + * @param extension extension name to check for
2.31 + * @return TRUE if supported, otherwise FALSE.
2.32 + */
2.33 +gboolean isGLExtensionSupported( const char *extension )
2.34 +{
2.35 + const GLubyte *extensions = NULL;
2.36 + const GLubyte *start;
2.37 + GLubyte *where, *terminator;
2.38 +
2.39 + /* Extension names should not have spaces. */
2.40 + where = (GLubyte *) strchr(extension, ' ');
2.41 + if (where || *extension == '\0')
2.42 + return 0;
2.43 + extensions = glGetString(GL_EXTENSIONS);
2.44 + /* It takes a bit of care to be fool-proof about parsing the
2.45 + OpenGL extensions string. Don't be fooled by sub-strings,
2.46 + etc. */
2.47 + start = extensions;
2.48 + for (;;) {
2.49 + where = (GLubyte *) strstr((const char *) start, extension);
2.50 + if (!where)
2.51 + break;
2.52 + terminator = where + strlen(extension);
2.53 + if (where == start || *(where - 1) == ' ')
2.54 + if (*terminator == ' ' || *terminator == '\0')
2.55 + return TRUE;
2.56 + start = terminator;
2.57 + }
2.58 + return FALSE;
2.59 +}
2.60 +
2.61 +gboolean hasRequiredGLExtensions( )
2.62 +{
2.63 + int i;
2.64 + gboolean isOK = TRUE;
2.65 + fprintf( stdout, "GL Extensions: %s\n", glGetString(GL_EXTENSIONS) );
2.66 +
2.67 +
2.68 + for( i=0; required_extensions[i] != NULL; i++ ) {
2.69 + if( !isGLExtensionSupported(required_extensions[i]) ) {
2.70 + ERROR( "Required OpenGL extension not supported: %s", required_extensions[i] );
2.71 + isOK = FALSE;
2.72 + }
2.73 + }
2.74 + return isOK;
2.75 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/src/drivers/video_gl.h Sun Jan 14 02:55:06 2007 +0000
3.3 @@ -0,0 +1,32 @@
3.4 +/**
3.5 + * $Id: video_gl.h,v 1.1 2007-01-14 02:55:06 nkeynes Exp $
3.6 + *
3.7 + * Parent for all X11 display drivers.
3.8 + *
3.9 + * Copyright (c) 2005 Nathan Keynes.
3.10 + *
3.11 + * This program is free software; you can redistribute it and/or modify
3.12 + * it under the terms of the GNU General Public License as published by
3.13 + * the Free Software Foundation; either version 2 of the License, or
3.14 + * (at your option) any later version.
3.15 + *
3.16 + * This program is distributed in the hope that it will be useful,
3.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.19 + * GNU General Public License for more details.
3.20 + */
3.21 +
3.22 +#ifndef video_gl_common_H
3.23 +#define video_gl_common_H
3.24 +
3.25 +
3.26 +/**
3.27 + * Test if a specific extension is supported. From opengl.org
3.28 + * @param extension extension name to check for
3.29 + * @return TRUE if supported, otherwise FALSE.
3.30 + */
3.31 +gboolean isGLExtensionSupported( const char *extension );
3.32 +
3.33 +gboolean hasRequiredGLExtensions();
3.34 +
3.35 +#endif /* !video_gl_common_H */
4.1 --- a/src/drivers/video_x11.c Sun Jan 14 02:54:40 2007 +0000
4.2 +++ b/src/drivers/video_x11.c Sun Jan 14 02:55:06 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: video_x11.c,v 1.6 2006-06-18 11:55:25 nkeynes Exp $
4.6 + * $Id: video_x11.c,v 1.7 2007-01-14 02:55:06 nkeynes Exp $
4.7 *
4.8 * Shared functions for all X11-based display drivers.
4.9 *
4.10 @@ -123,7 +123,9 @@
4.11 glXDestroyContext( video_x11_display, glx_context );
4.12 return FALSE;
4.13 }
4.14 -
4.15 +
4.16 + hasRequiredGLExtensions();
4.17 + fprintf(stderr, "GLX extensions: %s\n", glxExts );
4.18 glx_open = TRUE;
4.19 return TRUE;
4.20 }
.