2 /* Copyright (c) Mark J. Kilgard, 1994, 1997. */
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. */
15 glutExtensionSupported(const char *extension
)
17 static const GLubyte
*extensions
= NULL
;
19 GLubyte
*where
, *terminator
;
21 /* Extension names should not have spaces. */
22 where
= (GLubyte
*) strchr(extension
, ' ');
23 if (where
|| *extension
== '\0')
27 extensions
= glGetString(GL_EXTENSIONS
);
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,
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
);
42 terminator
= where
+ strlen(extension
);
43 if (where
== start
|| *(where
- 1) == ' ') {
44 if (*terminator
== ' ' || *terminator
== '\0') {
54 struct name_address_pair
{
59 static struct name_address_pair glut_functions
[] = {
60 { "glutInit", (const void *) glutInit
},
61 { "glutInitDisplayMode", (const void *) glutInitDisplayMode
},
62 { "glutInitDisplayString", (const void *) glutInitDisplayString
},
63 { "glutInitWindowPosition", (const void *) glutInitWindowPosition
},
64 { "glutInitWindowSize", (const void *) glutInitWindowSize
},
65 { "glutMainLoop", (const void *) glutMainLoop
},
66 { "glutCreateWindow", (const void *) glutCreateWindow
},
67 { "glutCreateSubWindow", (const void *) glutCreateSubWindow
},
68 { "glutDestroyWindow", (const void *) glutDestroyWindow
},
69 { "glutPostRedisplay", (const void *) glutPostRedisplay
},
70 { "glutPostWindowRedisplay", (const void *) glutPostWindowRedisplay
},
71 { "glutSwapBuffers", (const void *) glutSwapBuffers
},
72 { "glutGetWindow", (const void *) glutGetWindow
},
73 { "glutSetWindow", (const void *) glutSetWindow
},
74 { "glutSetWindowTitle", (const void *) glutSetWindowTitle
},
75 { "glutSetIconTitle", (const void *) glutSetIconTitle
},
76 { "glutPositionWindow", (const void *) glutPositionWindow
},
77 { "glutReshapeWindow", (const void *) glutReshapeWindow
},
78 { "glutPopWindow", (const void *) glutPopWindow
},
79 { "glutPushWindow", (const void *) glutPushWindow
},
80 { "glutIconifyWindow", (const void *) glutIconifyWindow
},
81 { "glutShowWindow", (const void *) glutShowWindow
},
82 { "glutHideWindow", (const void *) glutHideWindow
},
83 { "glutFullScreen", (const void *) glutFullScreen
},
84 { "glutSetCursor", (const void *) glutSetCursor
},
85 { "glutWarpPointer", (const void *) glutWarpPointer
},
86 { "glutEstablishOverlay", (const void *) glutEstablishOverlay
},
87 { "glutRemoveOverlay", (const void *) glutRemoveOverlay
},
88 { "glutUseLayer", (const void *) glutUseLayer
},
89 { "glutPostOverlayRedisplay", (const void *) glutPostOverlayRedisplay
},
90 { "glutPostWindowOverlayRedisplay", (const void *) glutPostWindowOverlayRedisplay
},
91 { "glutShowOverlay", (const void *) glutShowOverlay
},
92 { "glutHideOverlay", (const void *) glutHideOverlay
},
93 { "glutCreateMenu", (const void *) glutCreateMenu
},
94 { "glutDestroyMenu", (const void *) glutDestroyMenu
},
95 { "glutGetMenu", (const void *) glutGetMenu
},
96 { "glutSetMenu", (const void *) glutSetMenu
},
97 { "glutAddMenuEntry", (const void *) glutAddMenuEntry
},
98 { "glutAddSubMenu", (const void *) glutAddSubMenu
},
99 { "glutChangeToMenuEntry", (const void *) glutChangeToMenuEntry
},
100 { "glutChangeToSubMenu", (const void *) glutChangeToSubMenu
},
101 { "glutRemoveMenuItem", (const void *) glutRemoveMenuItem
},
102 { "glutAttachMenu", (const void *) glutAttachMenu
},
103 { "glutDetachMenu", (const void *) glutDetachMenu
},
104 { "glutDisplayFunc", (const void *) glutDisplayFunc
},
105 { "glutReshapeFunc", (const void *) glutReshapeFunc
},
106 { "glutKeyboardFunc", (const void *) glutKeyboardFunc
},
107 { "glutMouseFunc", (const void *) glutMouseFunc
},
108 { "glutMotionFunc", (const void *) glutMotionFunc
},
109 { "glutPassiveMotionFunc", (const void *) glutPassiveMotionFunc
},
110 { "glutEntryFunc", (const void *) glutEntryFunc
},
111 { "glutVisibilityFunc", (const void *) glutVisibilityFunc
},
112 { "glutIdleFunc", (const void *) glutIdleFunc
},
113 { "glutTimerFunc", (const void *) glutTimerFunc
},
114 { "glutMenuStateFunc", (const void *) glutMenuStateFunc
},
115 { "glutSpecialFunc", (const void *) glutSpecialFunc
},
116 { "glutSpaceballMotionFunc", (const void *) glutSpaceballMotionFunc
},
117 { "glutSpaceballRotateFunc", (const void *) glutSpaceballRotateFunc
},
118 { "glutSpaceballButtonFunc", (const void *) glutSpaceballButtonFunc
},
119 { "glutButtonBoxFunc", (const void *) glutButtonBoxFunc
},
120 { "glutDialsFunc", (const void *) glutDialsFunc
},
121 { "glutTabletMotionFunc", (const void *) glutTabletMotionFunc
},
122 { "glutTabletButtonFunc", (const void *) glutTabletButtonFunc
},
123 { "glutMenuStatusFunc", (const void *) glutMenuStatusFunc
},
124 { "glutOverlayDisplayFunc", (const void *) glutOverlayDisplayFunc
},
125 { "glutWindowStatusFunc", (const void *) glutWindowStatusFunc
},
126 { "glutKeyboardUpFunc", (const void *) glutKeyboardUpFunc
},
127 { "glutSpecialUpFunc", (const void *) glutSpecialUpFunc
},
128 { "glutJoystickFunc", (const void *) glutJoystickFunc
},
129 { "glutSetColor", (const void *) glutSetColor
},
130 { "glutGetColor", (const void *) glutGetColor
},
131 { "glutCopyColormap", (const void *) glutCopyColormap
},
132 { "glutGet", (const void *) glutGet
},
133 { "glutDeviceGet", (const void *) glutDeviceGet
},
134 { "glutExtensionSupported", (const void *) glutExtensionSupported
},
135 { "glutGetModifiers", (const void *) glutGetModifiers
},
136 { "glutLayerGet", (const void *) glutLayerGet
},
137 { "glutGetProcAddress", (const void *) glutGetProcAddress
},
138 { "glutBitmapCharacter", (const void *) glutBitmapCharacter
},
139 { "glutBitmapWidth", (const void *) glutBitmapWidth
},
140 { "glutStrokeCharacter", (const void *) glutStrokeCharacter
},
141 { "glutStrokeWidth", (const void *) glutStrokeWidth
},
142 { "glutBitmapLength", (const void *) glutBitmapLength
},
143 { "glutStrokeLength", (const void *) glutStrokeLength
},
144 { "glutWireSphere", (const void *) glutWireSphere
},
145 { "glutSolidSphere", (const void *) glutSolidSphere
},
146 { "glutWireCone", (const void *) glutWireCone
},
147 { "glutSolidCone", (const void *) glutSolidCone
},
148 { "glutWireCube", (const void *) glutWireCube
},
149 { "glutSolidCube", (const void *) glutSolidCube
},
150 { "glutWireTorus", (const void *) glutWireTorus
},
151 { "glutSolidTorus", (const void *) glutSolidTorus
},
152 { "glutWireDodecahedron", (const void *) glutWireDodecahedron
},
153 { "glutSolidDodecahedron", (const void *) glutSolidDodecahedron
},
154 { "glutWireTeapot", (const void *) glutWireTeapot
},
155 { "glutSolidTeapot", (const void *) glutSolidTeapot
},
156 { "glutWireOctahedron", (const void *) glutWireOctahedron
},
157 { "glutSolidOctahedron", (const void *) glutSolidOctahedron
},
158 { "glutWireTetrahedron", (const void *) glutWireTetrahedron
},
159 { "glutSolidTetrahedron", (const void *) glutSolidTetrahedron
},
160 { "glutWireIcosahedron", (const void *) glutWireIcosahedron
},
161 { "glutSolidIcosahedron", (const void *) glutSolidIcosahedron
},
162 { "glutVideoResizeGet", (const void *) glutVideoResizeGet
},
163 { "glutSetupVideoResizing", (const void *) glutSetupVideoResizing
},
164 { "glutStopVideoResizing", (const void *) glutStopVideoResizing
},
165 { "glutVideoResize", (const void *) glutVideoResize
},
166 { "glutVideoPan", (const void *) glutVideoPan
},
167 { "glutReportErrors", (const void *) glutReportErrors
},
168 { "glutIgnoreKeyRepeat", (const void *) glutIgnoreKeyRepeat
},
169 { "glutSetKeyRepeat", (const void *) glutSetKeyRepeat
},
170 { "glutForceJoystickFunc", (const void *) glutForceJoystickFunc
},
171 { "glutGameModeString", (const void *) glutGameModeString
},
172 { "glutEnterGameMode", (const void *) glutEnterGameMode
},
173 { "glutLeaveGameMode", (const void *) glutLeaveGameMode
},
174 { "glutGameModeGet", (const void *) glutGameModeGet
},
179 /* XXX This isn't an official GLUT function, yet */
181 glutGetProcAddress(const char *procName
)
183 /* Try GLUT functions first */
185 for (i
= 0; glut_functions
[i
].name
; i
++) {
186 if (strcmp(glut_functions
[i
].name
, procName
) == 0)
187 return (void *) glut_functions
[i
].address
;
190 /* Try core GL functions */
192 return (void *) wglGetProcAddress((LPCSTR
) procName
);
194 #elif defined(__OS2PM__)
195 return (void *) wglGetProcAddress((char *) procName
);
196 #elif defined(GLX_ARB_get_proc_address)
197 return (void *) glXGetProcAddressARB((const GLubyte
*) procName
);