Add our own function to check whether a certain OpenGL extension is supported
This commit is contained in:
@@ -28,6 +28,7 @@ libsgscreen_a_SOURCES = \
|
||||
$(IMAGE_SERVER_SRCS) \
|
||||
screen-dump.cxx \
|
||||
tr.cxx \
|
||||
extensions.cxx \
|
||||
win32-printer.h
|
||||
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
|
||||
66
simgear/screen/extensions.cxx
Normal file
66
simgear/screen/extensions.cxx
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2001 C<>sar Blecua Ud<55>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 <string.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include <extensions.hxx>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,42 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2001 C<>sar Blecua Ud<55>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 <dlfcn.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
#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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user