From 9ca1c6666e6f5fcd071d36c590b768ec880a58c6 Mon Sep 17 00:00:00 2001 From: ehofman Date: Wed, 18 Jun 2003 09:06:54 +0000 Subject: [PATCH] Add our own function to check whether a certain OpenGL extension is supported --- simgear/screen/Makefile.am | 1 + simgear/screen/extensions.cxx | 66 +++++++++++++++++++++++++++++++++++ simgear/screen/extensions.hxx | 47 +++++++++++++++++++++++-- 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 simgear/screen/extensions.cxx diff --git a/simgear/screen/Makefile.am b/simgear/screen/Makefile.am index 86a547c5..cec32d80 100644 --- a/simgear/screen/Makefile.am +++ b/simgear/screen/Makefile.am @@ -28,6 +28,7 @@ libsgscreen_a_SOURCES = \ $(IMAGE_SERVER_SRCS) \ screen-dump.cxx \ tr.cxx \ + extensions.cxx \ win32-printer.h INCLUDES = -I$(top_srcdir) diff --git a/simgear/screen/extensions.cxx b/simgear/screen/extensions.cxx new file mode 100644 index 00000000..aeab8998 --- /dev/null +++ b/simgear/screen/extensions.cxx @@ -0,0 +1,66 @@ +/* + * + * Copyright (c) 2001 César Blecua Udías All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * CESAR BLECUA UDIAS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include + +#ifndef WIN32 +#include +#endif + +#include + +bool SGSearchExtensionsString(char *extString, char *extName) { + // Returns GL_TRUE if the *extName string appears in the *extString string, + // surrounded by white spaces, or GL_FALSE otherwise. + + char *p, *end; + int n, extNameLen; + + extNameLen = strlen(extName); + + p=extString; + end = p + strlen(p); + + while (p < end) { + n = strcspn(p, " "); + if ((extNameLen == n) && (strncmp(extName, p, n) == 0)) + return GL_TRUE; + + p += (n + 1); + } + + return GL_FALSE; +} + +bool SGIsOpenGLExtensionSupported(char *extName) { + // Returns GL_TRUE if the OpenGL Extension whose name is *extName + // is supported by the system, or GL_FALSE otherwise. + // + // The *extName string must follow the OpenGL extensions naming scheme + // (ie: "GL_type_extension", like GL_EXT_convolution) + + return SGSearchExtensionsString((char *)glGetString(GL_EXTENSIONS), +extName); +} + diff --git a/simgear/screen/extensions.hxx b/simgear/screen/extensions.hxx index 949345a8..77efd3c3 100644 --- a/simgear/screen/extensions.hxx +++ b/simgear/screen/extensions.hxx @@ -1,10 +1,42 @@ +/* + * + * Copyright (c) 2001 César Blecua Udías All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * CESAR BLECUA UDIAS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ #ifndef __SG_EXTENSIONS_HXX #define __SG_EXTENSIONS_HXX 1 -#ifndef WIN32 -#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +#ifndef APIENTRY +#define APIENTRY #endif +static bool SGSearchExtensionsString(char *extString, char *extName); +bool SGIsOpenGLExtensionSupported(char *extName); + inline void (*SGLookupFunction(const char *func))() { #if defined( WIN32 ) @@ -28,4 +60,15 @@ inline void (*SGLookupFunction(const char *func))() { #endif } + + +/* OpenGL extension declarations */ +typedef void (APIENTRY * glPointParameterfProc)(GLenum pname, GLfloat param); +typedef void (APIENTRY * glPointParameterfvProc)(GLenum pname, const GLfloat *params); + +#if defined(__cplusplus) +} #endif + +#endif // !__SG_EXTENSIONS_HXX + -- 2.39.5