4a3c185a16dc2b1d6ff569e817dcbede067529ca
[mesa.git] / src / glut / fbdev / ext.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 * Copyright (C) 1995-2006 Brian Paul
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 /*
22 * Library for glut using mesa fbdev driver
23 *
24 * Written by Sean D'Epagnier (c) 2006
25 */
26
27 #include <GL/gl.h>
28 #include <GL/glut.h>
29
30 #include "internal.h"
31
32 void glutReportErrors(void)
33 {
34 GLenum error;
35
36 while ((error = glGetError()) != GL_NO_ERROR)
37 sprintf(exiterror, "GL error: %s", gluErrorString(error));
38 }
39
40 static struct {
41 const char *name;
42 const GLUTproc address;
43 } glut_functions[] = {
44 { "glutInit", (const GLUTproc) glutInit },
45 { "glutInitDisplayMode", (const GLUTproc) glutInitDisplayMode },
46 { "glutInitWindowPosition", (const GLUTproc) glutInitWindowPosition },
47 { "glutInitWindowSize", (const GLUTproc) glutInitWindowSize },
48 { "glutMainLoop", (const GLUTproc) glutMainLoop },
49 { "glutCreateWindow", (const GLUTproc) glutCreateWindow },
50 { "glutCreateSubWindow", (const GLUTproc) glutCreateSubWindow },
51 { "glutDestroyWindow", (const GLUTproc) glutDestroyWindow },
52 { "glutPostRedisplay", (const GLUTproc) glutPostRedisplay },
53 { "glutSwapBuffers", (const GLUTproc) glutSwapBuffers },
54 { "glutGetWindow", (const GLUTproc) glutGetWindow },
55 { "glutSetWindow", (const GLUTproc) glutSetWindow },
56 { "glutSetWindowTitle", (const GLUTproc) glutSetWindowTitle },
57 { "glutSetIconTitle", (const GLUTproc) glutSetIconTitle },
58 { "glutPositionWindow", (const GLUTproc) glutPositionWindow },
59 { "glutReshapeWindow", (const GLUTproc) glutReshapeWindow },
60 { "glutPopWindow", (const GLUTproc) glutPopWindow },
61 { "glutPushWindow", (const GLUTproc) glutPushWindow },
62 { "glutIconifyWindow", (const GLUTproc) glutIconifyWindow },
63 { "glutShowWindow", (const GLUTproc) glutShowWindow },
64 { "glutHideWindow", (const GLUTproc) glutHideWindow },
65 { "glutFullScreen", (const GLUTproc) glutFullScreen },
66 { "glutSetCursor", (const GLUTproc) glutSetCursor },
67 { "glutWarpPointer", (const GLUTproc) glutWarpPointer },
68 { "glutEstablishOverlay", (const GLUTproc) glutEstablishOverlay },
69 { "glutRemoveOverlay", (const GLUTproc) glutRemoveOverlay },
70 { "glutUseLayer", (const GLUTproc) glutUseLayer },
71 { "glutPostOverlayRedisplay", (const GLUTproc) glutPostOverlayRedisplay },
72 { "glutShowOverlay", (const GLUTproc) glutShowOverlay },
73 { "glutHideOverlay", (const GLUTproc) glutHideOverlay },
74 { "glutCreateMenu", (const GLUTproc) glutCreateMenu },
75 { "glutDestroyMenu", (const GLUTproc) glutDestroyMenu },
76 { "glutGetMenu", (const GLUTproc) glutGetMenu },
77 { "glutSetMenu", (const GLUTproc) glutSetMenu },
78 { "glutAddMenuEntry", (const GLUTproc) glutAddMenuEntry },
79 { "glutAddSubMenu", (const GLUTproc) glutAddSubMenu },
80 { "glutChangeToMenuEntry", (const GLUTproc) glutChangeToMenuEntry },
81 { "glutChangeToSubMenu", (const GLUTproc) glutChangeToSubMenu },
82 { "glutRemoveMenuItem", (const GLUTproc) glutRemoveMenuItem },
83 { "glutAttachMenu", (const GLUTproc) glutAttachMenu },
84 { "glutDetachMenu", (const GLUTproc) glutDetachMenu },
85 { "glutDisplayFunc", (const GLUTproc) glutDisplayFunc },
86 { "glutReshapeFunc", (const GLUTproc) glutReshapeFunc },
87 { "glutKeyboardFunc", (const GLUTproc) glutKeyboardFunc },
88 { "glutMouseFunc", (const GLUTproc) glutMouseFunc },
89 { "glutMotionFunc", (const GLUTproc) glutMotionFunc },
90 { "glutPassiveMotionFunc", (const GLUTproc) glutPassiveMotionFunc },
91 { "glutEntryFunc", (const GLUTproc) glutEntryFunc },
92 { "glutVisibilityFunc", (const GLUTproc) glutVisibilityFunc },
93 { "glutIdleFunc", (const GLUTproc) glutIdleFunc },
94 { "glutTimerFunc", (const GLUTproc) glutTimerFunc },
95 { "glutMenuStateFunc", (const GLUTproc) glutMenuStateFunc },
96 { "glutSpecialFunc", (const GLUTproc) glutSpecialFunc },
97 { "glutSpaceballRotateFunc", (const GLUTproc) glutSpaceballRotateFunc },
98 { "glutButtonBoxFunc", (const GLUTproc) glutButtonBoxFunc },
99 { "glutDialsFunc", (const GLUTproc) glutDialsFunc },
100 { "glutTabletMotionFunc", (const GLUTproc) glutTabletMotionFunc },
101 { "glutTabletButtonFunc", (const GLUTproc) glutTabletButtonFunc },
102 { "glutMenuStatusFunc", (const GLUTproc) glutMenuStatusFunc },
103 { "glutOverlayDisplayFunc", (const GLUTproc) glutOverlayDisplayFunc },
104 { "glutSetColor", (const GLUTproc) glutSetColor },
105 { "glutGetColor", (const GLUTproc) glutGetColor },
106 { "glutCopyColormap", (const GLUTproc) glutCopyColormap },
107 { "glutGet", (const GLUTproc) glutGet },
108 { "glutDeviceGet", (const GLUTproc) glutDeviceGet },
109 { "glutExtensionSupported", (const GLUTproc) glutExtensionSupported },
110 { "glutGetModifiers", (const GLUTproc) glutGetModifiers },
111 { "glutLayerGet", (const GLUTproc) glutLayerGet },
112 { "glutGetProcAddress", (const GLUTproc) glutGetProcAddress },
113 { "glutBitmapCharacter", (const GLUTproc) glutBitmapCharacter },
114 { "glutBitmapWidth", (const GLUTproc) glutBitmapWidth },
115 { "glutStrokeCharacter", (const GLUTproc) glutStrokeCharacter },
116 { "glutStrokeWidth", (const GLUTproc) glutStrokeWidth },
117 { "glutBitmapLength", (const GLUTproc) glutBitmapLength },
118 { "glutStrokeLength", (const GLUTproc) glutStrokeLength },
119 { "glutWireSphere", (const GLUTproc) glutWireSphere },
120 { "glutSolidSphere", (const GLUTproc) glutSolidSphere },
121 { "glutWireCone", (const GLUTproc) glutWireCone },
122 { "glutSolidCone", (const GLUTproc) glutSolidCone },
123 { "glutWireCube", (const GLUTproc) glutWireCube },
124 { "glutSolidCube", (const GLUTproc) glutSolidCube },
125 { "glutWireTorus", (const GLUTproc) glutWireTorus },
126 { "glutSolidTorus", (const GLUTproc) glutSolidTorus },
127 { "glutWireDodecahedron", (const GLUTproc) glutWireDodecahedron },
128 { "glutSolidDodecahedron", (const GLUTproc) glutSolidDodecahedron },
129 { "glutWireTeapot", (const GLUTproc) glutWireTeapot },
130 { "glutSolidTeapot", (const GLUTproc) glutSolidTeapot },
131 { "glutWireOctahedron", (const GLUTproc) glutWireOctahedron },
132 { "glutSolidOctahedron", (const GLUTproc) glutSolidOctahedron },
133 { "glutWireTetrahedron", (const GLUTproc) glutWireTetrahedron },
134 { "glutSolidTetrahedron", (const GLUTproc) glutSolidTetrahedron },
135 { "glutWireIcosahedron", (const GLUTproc) glutWireIcosahedron },
136 { "glutSolidIcosahedron", (const GLUTproc) glutSolidIcosahedron },
137 { "glutReportErrors", (const GLUTproc) glutReportErrors },
138 { NULL, NULL }
139 };
140
141 GLUTproc glutGetProcAddress(const char *procName)
142 {
143 /* Try GLUT functions first */
144 int i;
145 for (i = 0; glut_functions[i].name; i++) {
146 if (strcmp(glut_functions[i].name, procName) == 0)
147 return glut_functions[i].address;
148 }
149
150 /* Try core GL functions */
151 return (GLUTproc) glFBDevGetProcAddress(procName);
152 }