mesa: include mtypes.h
[mesa.git] / src / glut / directfb / ext.c
1 /*
2 * Copyright (C) 2006 Claudio Ciccani <klan@users.sf.net>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23
24 #include "internal.h"
25
26
27 static const struct {
28 const char *name;
29 const GLUTproc address;
30 } glut_functions[] = {
31 { "glutInit", (const GLUTproc) glutInit },
32 { "glutInitDisplayMode", (const GLUTproc) glutInitDisplayMode },
33 { "glutInitDisplayString", (const GLUTproc) glutInitDisplayString },
34 { "glutInitWindowPosition", (const GLUTproc) glutInitWindowPosition },
35 { "glutInitWindowSize", (const GLUTproc) glutInitWindowSize },
36 { "glutMainLoop", (const GLUTproc) glutMainLoop },
37 { "glutCreateWindow", (const GLUTproc) glutCreateWindow },
38 { "glutCreateSubWindow", (const GLUTproc) glutCreateSubWindow },
39 { "glutDestroyWindow", (const GLUTproc) glutDestroyWindow },
40 { "glutPostRedisplay", (const GLUTproc) glutPostRedisplay },
41 { "glutPostWindowRedisplay", (const GLUTproc) glutPostWindowRedisplay },
42 { "glutSwapBuffers", (const GLUTproc) glutSwapBuffers },
43 { "glutGetWindow", (const GLUTproc) glutGetWindow },
44 { "glutSetWindow", (const GLUTproc) glutSetWindow },
45 { "glutSetWindowTitle", (const GLUTproc) glutSetWindowTitle },
46 { "glutSetIconTitle", (const GLUTproc) glutSetIconTitle },
47 { "glutPositionWindow", (const GLUTproc) glutPositionWindow },
48 { "glutReshapeWindow", (const GLUTproc) glutReshapeWindow },
49 { "glutPopWindow", (const GLUTproc) glutPopWindow },
50 { "glutPushWindow", (const GLUTproc) glutPushWindow },
51 { "glutIconifyWindow", (const GLUTproc) glutIconifyWindow },
52 { "glutShowWindow", (const GLUTproc) glutShowWindow },
53 { "glutHideWindow", (const GLUTproc) glutHideWindow },
54 { "glutFullScreen", (const GLUTproc) glutFullScreen },
55 { "glutSetCursor", (const GLUTproc) glutSetCursor },
56 { "glutWarpPointer", (const GLUTproc) glutWarpPointer },
57 { "glutEstablishOverlay", (const GLUTproc) glutEstablishOverlay },
58 { "glutRemoveOverlay", (const GLUTproc) glutRemoveOverlay },
59 { "glutUseLayer", (const GLUTproc) glutUseLayer },
60 { "glutPostOverlayRedisplay", (const GLUTproc) glutPostOverlayRedisplay },
61 { "glutPostWindowOverlayRedisplay", (const GLUTproc) glutPostWindowOverlayRedisplay },
62 { "glutShowOverlay", (const GLUTproc) glutShowOverlay },
63 { "glutHideOverlay", (const GLUTproc) glutHideOverlay },
64 { "glutCreateMenu", (const GLUTproc) glutCreateMenu },
65 { "glutDestroyMenu", (const GLUTproc) glutDestroyMenu },
66 { "glutGetMenu", (const GLUTproc) glutGetMenu },
67 { "glutSetMenu", (const GLUTproc) glutSetMenu },
68 { "glutAddMenuEntry", (const GLUTproc) glutAddMenuEntry },
69 { "glutAddSubMenu", (const GLUTproc) glutAddSubMenu },
70 { "glutChangeToMenuEntry", (const GLUTproc) glutChangeToMenuEntry },
71 { "glutChangeToSubMenu", (const GLUTproc) glutChangeToSubMenu },
72 { "glutRemoveMenuItem", (const GLUTproc) glutRemoveMenuItem },
73 { "glutAttachMenu", (const GLUTproc) glutAttachMenu },
74 { "glutDetachMenu", (const GLUTproc) glutDetachMenu },
75 { "glutDisplayFunc", (const GLUTproc) glutDisplayFunc },
76 { "glutReshapeFunc", (const GLUTproc) glutReshapeFunc },
77 { "glutKeyboardFunc", (const GLUTproc) glutKeyboardFunc },
78 { "glutMouseFunc", (const GLUTproc) glutMouseFunc },
79 { "glutMotionFunc", (const GLUTproc) glutMotionFunc },
80 { "glutPassiveMotionFunc", (const GLUTproc) glutPassiveMotionFunc },
81 { "glutEntryFunc", (const GLUTproc) glutEntryFunc },
82 { "glutVisibilityFunc", (const GLUTproc) glutVisibilityFunc },
83 { "glutIdleFunc", (const GLUTproc) glutIdleFunc },
84 { "glutTimerFunc", (const GLUTproc) glutTimerFunc },
85 { "glutMenuStateFunc", (const GLUTproc) glutMenuStateFunc },
86 { "glutSpecialFunc", (const GLUTproc) glutSpecialFunc },
87 { "glutSpaceballMotionFunc", (const GLUTproc) glutSpaceballMotionFunc },
88 { "glutSpaceballRotateFunc", (const GLUTproc) glutSpaceballRotateFunc },
89 { "glutSpaceballButtonFunc", (const GLUTproc) glutSpaceballButtonFunc },
90 { "glutButtonBoxFunc", (const GLUTproc) glutButtonBoxFunc },
91 { "glutDialsFunc", (const GLUTproc) glutDialsFunc },
92 { "glutTabletMotionFunc", (const GLUTproc) glutTabletMotionFunc },
93 { "glutTabletButtonFunc", (const GLUTproc) glutTabletButtonFunc },
94 { "glutMenuStatusFunc", (const GLUTproc) glutMenuStatusFunc },
95 { "glutOverlayDisplayFunc", (const GLUTproc) glutOverlayDisplayFunc },
96 { "glutWindowStatusFunc", (const GLUTproc) glutWindowStatusFunc },
97 { "glutKeyboardUpFunc", (const GLUTproc) glutKeyboardUpFunc },
98 { "glutSpecialUpFunc", (const GLUTproc) glutSpecialUpFunc },
99 { "glutJoystickFunc", (const GLUTproc) glutJoystickFunc },
100 { "glutSetColor", (const GLUTproc) glutSetColor },
101 { "glutGetColor", (const GLUTproc) glutGetColor },
102 { "glutCopyColormap", (const GLUTproc) glutCopyColormap },
103 { "glutGet", (const GLUTproc) glutGet },
104 { "glutDeviceGet", (const GLUTproc) glutDeviceGet },
105 { "glutExtensionSupported", (const GLUTproc) glutExtensionSupported },
106 { "glutGetModifiers", (const GLUTproc) glutGetModifiers },
107 { "glutLayerGet", (const GLUTproc) glutLayerGet },
108 { "glutGetProcAddress", (const GLUTproc) glutGetProcAddress },
109 { "glutBitmapCharacter", (const GLUTproc) glutBitmapCharacter },
110 { "glutBitmapWidth", (const GLUTproc) glutBitmapWidth },
111 { "glutStrokeCharacter", (const GLUTproc) glutStrokeCharacter },
112 { "glutStrokeWidth", (const GLUTproc) glutStrokeWidth },
113 { "glutBitmapLength", (const GLUTproc) glutBitmapLength },
114 { "glutStrokeLength", (const GLUTproc) glutStrokeLength },
115 { "glutWireSphere", (const GLUTproc) glutWireSphere },
116 { "glutSolidSphere", (const GLUTproc) glutSolidSphere },
117 { "glutWireCone", (const GLUTproc) glutWireCone },
118 { "glutSolidCone", (const GLUTproc) glutSolidCone },
119 { "glutWireCube", (const GLUTproc) glutWireCube },
120 { "glutSolidCube", (const GLUTproc) glutSolidCube },
121 { "glutWireTorus", (const GLUTproc) glutWireTorus },
122 { "glutSolidTorus", (const GLUTproc) glutSolidTorus },
123 { "glutWireDodecahedron", (const GLUTproc) glutWireDodecahedron },
124 { "glutSolidDodecahedron", (const GLUTproc) glutSolidDodecahedron },
125 { "glutWireTeapot", (const GLUTproc) glutWireTeapot },
126 { "glutSolidTeapot", (const GLUTproc) glutSolidTeapot },
127 { "glutWireOctahedron", (const GLUTproc) glutWireOctahedron },
128 { "glutSolidOctahedron", (const GLUTproc) glutSolidOctahedron },
129 { "glutWireTetrahedron", (const GLUTproc) glutWireTetrahedron },
130 { "glutSolidTetrahedron", (const GLUTproc) glutSolidTetrahedron },
131 { "glutWireIcosahedron", (const GLUTproc) glutWireIcosahedron },
132 { "glutSolidIcosahedron", (const GLUTproc) glutSolidIcosahedron },
133 // { "glutVideoResizeGet", (const GLUTproc) glutVideoResizeGet },
134 // { "glutSetupVideoResizing", (const GLUTproc) glutSetupVideoResizing },
135 // { "glutStopVideoResizing", (const GLUTproc) glutStopVideoResizing },
136 // { "glutVideoResize", (const GLUTproc) glutVideoResize },
137 // { "glutVideoPan", (const GLUTproc) glutVideoPan },
138 { "glutReportErrors", (const GLUTproc) glutReportErrors },
139 { "glutIgnoreKeyRepeat", (const GLUTproc) glutIgnoreKeyRepeat },
140 { "glutSetKeyRepeat", (const GLUTproc) glutSetKeyRepeat },
141 { "glutForceJoystickFunc", (const GLUTproc) glutForceJoystickFunc },
142 { "glutGameModeString", (const GLUTproc) glutGameModeString },
143 { "glutEnterGameMode", (const GLUTproc) glutEnterGameMode },
144 { "glutLeaveGameMode", (const GLUTproc) glutLeaveGameMode },
145 { "glutGameModeGet", (const GLUTproc) glutGameModeGet },
146 };
147
148
149 GLUTproc GLUTAPIENTRY
150 glutGetProcAddress( const char *name )
151 {
152 int i;
153
154 for (i = 0; i < sizeof(glut_functions)/sizeof(glut_functions[0]); i++) {
155 if (!strcmp( name, glut_functions[i].name ))
156 return glut_functions[i].address;
157 }
158
159 #if DIRECTFBGL_INTERFACE_VERSION >= 1
160 if (g_current) {
161 void *address = NULL;
162 g_current->gl->GetProcAddress( g_current->gl, name, &address );
163 return address;
164 }
165 #endif
166 return NULL;
167 }
168
169
170 int GLUTAPIENTRY
171 glutExtensionSupported( const char *name )
172 {
173 GLubyte *extensions;
174 int length;
175
176 if (!name || !*name)
177 return 0;
178
179 length = strlen( name );
180 extensions = (GLubyte*) glGetString( GL_EXTENSIONS );
181
182 while (extensions && *extensions) {
183 GLubyte *next;
184
185 next = strchr( extensions, ' ' );
186 if (next) {
187 if (length == (int)(next - extensions)) {
188 if (!strncmp( extensions, name, length ))
189 return 1;
190 }
191 extensions = next+1;
192 }
193 else {
194 if (!strcmp( extensions, name ))
195 return 1;
196 break;
197 }
198 }
199
200 return 0;
201 }
202