added glutGetProcAddress() and GLUT_FPS env var option
[mesa.git] / src / glut / glx / glut_ext.c
1
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 */
14 int APIENTRY
15 glutExtensionSupported(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
54 /* XXX This isn't an official GLUT function, yet */
55 void * APIENTRY
56 glutGetProcAddress(const char *procName)
57 {
58 #if defined(_WIN32)
59 return (void *) wglGetProcAddress((LPCSTR) procName);
60 #elif defined(GLX_ARB_get_proc_address)
61 return (void *) glXGetProcAddressARB((const GLubyte *) procName);
62 #else
63 return NULL;
64 #endif
65 }
66
67
68 /* ENDCENTRY */