1/*
2 * fg_ext.c
3 *
4 * Functions related to OpenGL extensions.
5 *
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Creation date: Thu Dec 9 1999
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28#define GLX_GLXEXT_PROTOTYPES
29#include <GL/freeglut.h>
30#include "fg_internal.h"
31
32extern SFG_Proc fgPlatformGetProcAddress( const char *procName );
33extern GLUTproc fgPlatformGetGLUTProcAddress( const char *procName );
34
35static GLUTproc fghGetGLUTProcAddress( const char* procName )
36{
37 /* optimization: quick initial check */
38 if( strncmp( procName, "glut", 4 ) != 0 )
39 return NULL;
40
41#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
42 CHECK_NAME(glutInit);
43 CHECK_NAME(glutInitDisplayMode);
44 CHECK_NAME(glutInitDisplayString);
45 CHECK_NAME(glutInitWindowPosition);
46 CHECK_NAME(glutInitWindowSize);
47 CHECK_NAME(glutMainLoop);
48 CHECK_NAME(glutExit);
49 CHECK_NAME(glutCreateWindow);
50 CHECK_NAME(glutCreateSubWindow);
51 CHECK_NAME(glutDestroyWindow);
52 CHECK_NAME(glutPostRedisplay);
53 CHECK_NAME(glutPostWindowRedisplay);
54 CHECK_NAME(glutSwapBuffers);
55 CHECK_NAME(glutGetWindow);
56 CHECK_NAME(glutSetWindow);
57 CHECK_NAME(glutSetWindowTitle);
58 CHECK_NAME(glutSetIconTitle);
59 CHECK_NAME(glutPositionWindow);
60 CHECK_NAME(glutReshapeWindow);
61 CHECK_NAME(glutPopWindow);
62 CHECK_NAME(glutPushWindow);
63 CHECK_NAME(glutIconifyWindow);
64 CHECK_NAME(glutShowWindow);
65 CHECK_NAME(glutHideWindow);
66 CHECK_NAME(glutFullScreen);
67 CHECK_NAME(glutSetCursor);
68 CHECK_NAME(glutWarpPointer);
69 CHECK_NAME(glutEstablishOverlay);
70 CHECK_NAME(glutRemoveOverlay);
71 CHECK_NAME(glutUseLayer);
72 CHECK_NAME(glutPostOverlayRedisplay);
73 CHECK_NAME(glutPostWindowOverlayRedisplay);
74 CHECK_NAME(glutShowOverlay);
75 CHECK_NAME(glutHideOverlay);
76 CHECK_NAME(glutCreateMenu);
77 CHECK_NAME(glutDestroyMenu);
78 CHECK_NAME(glutGetMenu);
79 CHECK_NAME(glutSetMenu);
80 CHECK_NAME(glutAddMenuEntry);
81 CHECK_NAME(glutAddSubMenu);
82 CHECK_NAME(glutChangeToMenuEntry);
83 CHECK_NAME(glutChangeToSubMenu);
84 CHECK_NAME(glutRemoveMenuItem);
85 CHECK_NAME(glutAttachMenu);
86 CHECK_NAME(glutDetachMenu);
87 CHECK_NAME(glutDisplayFunc);
88 CHECK_NAME(glutReshapeFunc);
89 CHECK_NAME(glutPositionFunc);
90 CHECK_NAME(glutKeyboardFunc);
91 CHECK_NAME(glutMouseFunc);
92 CHECK_NAME(glutMultiEntryFunc);
93 CHECK_NAME(glutMultiMotionFunc);
94 CHECK_NAME(glutMultiButtonFunc);
95 CHECK_NAME(glutMultiPassiveFunc);
96 CHECK_NAME(glutMotionFunc);
97 CHECK_NAME(glutPassiveMotionFunc);
98 CHECK_NAME(glutEntryFunc);
99 CHECK_NAME(glutVisibilityFunc);
100 CHECK_NAME(glutIdleFunc);
101 CHECK_NAME(glutTimerFunc);
102 CHECK_NAME(glutMenuStateFunc);
103 CHECK_NAME(glutSpecialFunc);
104 CHECK_NAME(glutSpaceballMotionFunc);
105 CHECK_NAME(glutSpaceballRotateFunc);
106 CHECK_NAME(glutSpaceballButtonFunc);
107 CHECK_NAME(glutButtonBoxFunc);
108 CHECK_NAME(glutDialsFunc);
109 CHECK_NAME(glutTabletMotionFunc);
110 CHECK_NAME(glutTabletButtonFunc);
111 CHECK_NAME(glutMenuStatusFunc);
112 CHECK_NAME(glutOverlayDisplayFunc);
113 CHECK_NAME(glutWindowStatusFunc);
114 CHECK_NAME(glutKeyboardDownFunc);
115 CHECK_NAME(glutKeyboardUpFunc);
116 CHECK_NAME(glutSpecialUpFunc);
117 CHECK_NAME(glutSetColor);
118 CHECK_NAME(glutGetColor);
119 CHECK_NAME(glutCopyColormap);
120 CHECK_NAME(glutGet);
121 CHECK_NAME(glutDeviceGet);
122 CHECK_NAME(glutExtensionSupported);
123 CHECK_NAME(glutGetModifiers);
124 CHECK_NAME(glutLayerGet);
125 CHECK_NAME(glutBitmapCharacter);
126 CHECK_NAME(glutBitmapWidth);
127 CHECK_NAME(glutStrokeCharacter);
128 CHECK_NAME(glutStrokeWidth);
129 CHECK_NAME(glutStrokeWidthf);
130 CHECK_NAME(glutBitmapLength);
131 CHECK_NAME(glutStrokeLength);
132 CHECK_NAME(glutStrokeLengthf);
133 CHECK_NAME(glutWireSphere);
134 CHECK_NAME(glutSolidSphere);
135 CHECK_NAME(glutWireCone);
136 CHECK_NAME(glutSolidCone);
137 CHECK_NAME(glutWireTorus);
138 CHECK_NAME(glutSolidTorus);
139 CHECK_NAME(glutWireCylinder);
140 CHECK_NAME(glutSolidCylinder);
141 CHECK_NAME(glutWireTeapot);
142 CHECK_NAME(glutSolidTeapot);
143 CHECK_NAME(glutWireTeacup);
144 CHECK_NAME(glutSolidTeacup);
145 CHECK_NAME(glutWireTeaspoon);
146 CHECK_NAME(glutSolidTeaspoon);
147 CHECK_NAME(glutWireCube);
148 CHECK_NAME(glutSolidCube);
149 CHECK_NAME(glutWireDodecahedron);
150 CHECK_NAME(glutSolidDodecahedron);
151 CHECK_NAME(glutWireOctahedron);
152 CHECK_NAME(glutSolidOctahedron);
153 CHECK_NAME(glutWireTetrahedron);
154 CHECK_NAME(glutSolidTetrahedron);
155 CHECK_NAME(glutWireIcosahedron);
156 CHECK_NAME(glutSolidIcosahedron);
157 CHECK_NAME(glutWireRhombicDodecahedron);
158 CHECK_NAME(glutSolidRhombicDodecahedron);
159 CHECK_NAME(glutWireSierpinskiSponge);
160 CHECK_NAME(glutSolidSierpinskiSponge);
161 CHECK_NAME(glutVideoResizeGet);
162 CHECK_NAME(glutSetupVideoResizing);
163 CHECK_NAME(glutStopVideoResizing);
164 CHECK_NAME(glutVideoResize);
165 CHECK_NAME(glutVideoPan);
166 CHECK_NAME(glutReportErrors);
167 CHECK_NAME(glutIgnoreKeyRepeat);
168 CHECK_NAME(glutSetKeyRepeat);
169
170 /* freeglut extensions */
171 CHECK_NAME(glutMainLoopEvent);
172 CHECK_NAME(glutLeaveMainLoop);
173 CHECK_NAME(glutCloseFunc);
174 CHECK_NAME(glutWMCloseFunc);
175 CHECK_NAME(glutMenuDestroyFunc);
176 CHECK_NAME(glutFullScreenToggle);
177 CHECK_NAME(glutLeaveFullScreen);
178 CHECK_NAME(glutSetMenuFont);
179 CHECK_NAME(glutSetOption);
180 CHECK_NAME(glutGetModeValues);
181 CHECK_NAME(glutSetWindowData);
182 CHECK_NAME(glutGetWindowData);
183 CHECK_NAME(glutSetMenuData);
184 CHECK_NAME(glutGetMenuData);
185 CHECK_NAME(glutBitmapHeight);
186 CHECK_NAME(glutStrokeHeight);
187 CHECK_NAME(glutBitmapString);
188 CHECK_NAME(glutStrokeString);
189 CHECK_NAME(glutGetProcAddress);
190 CHECK_NAME(glutKeyboardExtFunc);
191 CHECK_NAME(glutMouseWheelFunc);
192 CHECK_NAME(glutGetClipboard);
193 CHECK_NAME(glutSetClipboard);
194 CHECK_NAME(glutJoystickGetNumAxes);
195 CHECK_NAME(glutJoystickGetNumButtons);
196 CHECK_NAME(glutJoystickNotWorking);
197 CHECK_NAME(glutJoystickGetDeadBand);
198 CHECK_NAME(glutJoystickSetDeadBand);
199 CHECK_NAME(glutJoystickGetSaturation);
200 CHECK_NAME(glutJoystickSetSaturation);
201 CHECK_NAME(glutJoystickSetMinRange);
202 CHECK_NAME(glutJoystickSetMaxRange);
203 CHECK_NAME(glutJoystickSetCenter);
204 CHECK_NAME(glutJoystickGetMinRange);
205 CHECK_NAME(glutJoystickGetMaxRange);
206 CHECK_NAME(glutJoystickGetCenter);
207 CHECK_NAME(glutInitContextVersion);
208 CHECK_NAME(glutInitContextFlags);
209 CHECK_NAME(glutInitContextProfile);
210 CHECK_NAME(glutInitErrorFunc);
211 CHECK_NAME(glutInitWarningFunc);
212 CHECK_NAME(glutInitContextFunc);
213 CHECK_NAME(glutAppStatusFunc);
214 CHECK_NAME(glutSetVertexAttribCoord3);
215 CHECK_NAME(glutSetVertexAttribNormal);
216 CHECK_NAME(glutSetVertexAttribTexCoord2);
217#undef CHECK_NAME
218
219 return NULL;
220}
221
222
223
224GLUTproc FGAPIENTRY
225glutGetProcAddress( const char *procName )
226{
227 GLUTproc p;
228 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetProcAddress" );
229
230 /* Try GLUT functions first, then core GL functions */
231 p = fghGetGLUTProcAddress( procName );
232
233 /* Some GLUT functions are platform-specific: */
234 if ( !p )
235 p = fgPlatformGetGLUTProcAddress( procName );
236
237 return ( p != NULL ) ? p : fgPlatformGetProcAddress( procName );
238}
239