source: trunk/src/opengl/glut/glut_ext.c

Last change on this file was 2689, checked in by jeroen, 26 years ago

* empty log message *

File size: 1.5 KB
Line 
1/* $Id: glut_ext.c,v 1.2 2000-02-09 08:46:11 jeroen Exp $ */
2/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
3
4/* This program is freely distributable without licensing fees
5 and is provided without guarantee or warrantee expressed or
6 implied. This program is -not- in the public domain. */
7
8#include <stdlib.h>
9#include <string.h>
10
11#include "glutint.h"
12
13/* CENTRY */
14int APIENTRY
15glutExtensionSupported(const char *extension)
16{
17 static const GLubyte *extensions = NULL;
18 const GLubyte *start;
19 GLubyte *where, *terminator;
20
21 /* Extension names should not have spaces. */
22 where = (GLubyte *) strchr(extension, ' ');
23 if (where || *extension == '\0')
24 return 0;
25
26 if (!extensions) {
27 extensions = glGetString(GL_EXTENSIONS);
28 }
29 /* It takes a bit of care to be fool-proof about parsing the
30 OpenGL extensions string. Don't be fooled by sub-strings,
31 etc. */
32 start = extensions;
33 for (;;) {
34 /* If your application crashes in the strstr routine below,
35 you are probably calling glutExtensionSupported without
36 having a current window. Calling glGetString without
37 a current OpenGL context has unpredictable results.
38 Please fix your program. */
39 where = (GLubyte *) strstr((const char *) start, extension);
40 if (!where)
41 break;
42 terminator = where + strlen(extension);
43 if (where == start || *(where - 1) == ' ') {
44 if (*terminator == ' ' || *terminator == '\0') {
45 return 1;
46 }
47 }
48 start = terminator;
49 }
50 return 0;
51}
52
53/* ENDCENTRY */
Note: See TracBrowser for help on using the repository browser.