summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordok666 <dok666>2003-05-09 18:33:26 +0000
committerdok666 <dok666>2003-05-09 18:33:26 +0000
commit289373820cc2a30be5cd8c7af2c37790b2630ce0 (patch)
treec9e149f7443b971da04a97200720fdf82f0260a4
parentbf1fc30cf9632313025fed5704e7c13b0e7a9ace (diff)
Added glutExtensionSupported().
-rw-r--r--src/glut/mini/state.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/glut/mini/state.c b/src/glut/mini/state.c
index 81aefc53bda..91fcc5bcd83 100644
--- a/src/glut/mini/state.c
+++ b/src/glut/mini/state.c
@@ -26,6 +26,7 @@
* Web : http://www.geocities.com/dborca
*/
+#include <string.h>
#include "GL/glut.h"
#include <sys/time.h>
@@ -68,3 +69,44 @@ int APIENTRY glutDeviceGet (GLenum type)
{
return 0;
}
+
+/* CENTRY */
+int APIENTRY
+glutExtensionSupported(const char *extension)
+{
+ static const GLubyte *extensions = NULL;
+ const GLubyte *start;
+ GLubyte *where, *terminator;
+
+ /* Extension names should not have spaces. */
+ where = (GLubyte *) strchr(extension, ' ');
+ if (where || *extension == '\0')
+ return 0;
+
+ if (!extensions) {
+ extensions = glGetString(GL_EXTENSIONS);
+ }
+ /* It takes a bit of care to be fool-proof about parsing the
+ OpenGL extensions string. Don't be fooled by sub-strings,
+ etc. */
+ start = extensions;
+ for (;;) {
+ /* If your application crashes in the strstr routine below,
+ you are probably calling glutExtensionSupported without
+ having a current window. Calling glGetString without
+ a current OpenGL context has unpredictable results.
+ Please fix your program. */
+ where = (GLubyte *) strstr((const char *) start, extension);
+ if (!where)
+ break;
+ terminator = where + strlen(extension);
+ if (where == start || *(where - 1) == ' ') {
+ if (*terminator == ' ' || *terminator == '\0') {
+ return 1;
+ }
+ }
+ start = terminator;
+ }
+ return 0;
+}
+