From 2f63f5a7fca80d46618c54683906ac1643d0aba4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 17 Jun 2003 16:54:54 +0000 Subject: [PATCH] added glutGetProcAddress() git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@65 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut-1.3/Makefile.am | 1 + freeglut-1.3/freeglut_ext.c | 194 +++++++++++++++++++++++++++++++++++++++++++ include/GL/freeglut_ext.h | 6 ++ 3 files changed, 201 insertions(+) create mode 100644 freeglut-1.3/freeglut_ext.c diff --git a/freeglut-1.3/Makefile.am b/freeglut-1.3/Makefile.am index 54d8dee..450880c 100644 --- a/freeglut-1.3/Makefile.am +++ b/freeglut-1.3/Makefile.am @@ -11,6 +11,7 @@ lib_LTLIBRARIES = libfreeglut-1.3.la libfreeglut_1_3_la_SOURCES = freeglut_callbacks.c \ freeglut_cursor.c \ freeglut_display.c \ + freeglut_ext.c \ freeglut_font.c \ freeglut_font_data.c \ freeglut_stroke_roman.c \ diff --git a/freeglut-1.3/freeglut_ext.c b/freeglut-1.3/freeglut_ext.c new file mode 100644 index 0000000..03a695e --- /dev/null +++ b/freeglut-1.3/freeglut_ext.c @@ -0,0 +1,194 @@ +/* + * freeglut_ext.c + * + * Functions related to OpenGL extensions. + * + * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. + * Written by Pawel W. Olszta, + * Creation date: Thu Dec 9 1999 + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define G_LOG_DOMAIN "freeglut-ext" + +#include "../include/GL/freeglut.h" +#include "freeglut_internal.h" + + +struct name_address_pair { + const char *name; + void *address; +}; + +static struct name_address_pair glut_functions[] = { + { "glutInit", (void *) glutInit }, + { "glutInitDisplayMode", (void *) glutInitDisplayMode }, + { "glutInitDisplayString", (void *) glutInitDisplayString }, + { "glutInitWindowPosition", (void *) glutInitWindowPosition }, + { "glutInitWindowSize", (void *) glutInitWindowSize }, + { "glutMainLoop", (void *) glutMainLoop }, + { "glutCreateWindow", (void *) glutCreateWindow }, + { "glutCreateSubWindow", (void *) glutCreateSubWindow }, + { "glutDestroyWindow", (void *) glutDestroyWindow }, + { "glutPostRedisplay", (void *) glutPostRedisplay }, + { "glutPostWindowRedisplay", (void *) glutPostWindowRedisplay }, + { "glutSwapBuffers", (void *) glutSwapBuffers }, + { "glutGetWindow", (void *) glutGetWindow }, + { "glutSetWindow", (void *) glutSetWindow }, + { "glutSetWindowTitle", (void *) glutSetWindowTitle }, + { "glutSetIconTitle", (void *) glutSetIconTitle }, + { "glutPositionWindow", (void *) glutPositionWindow }, + { "glutReshapeWindow", (void *) glutReshapeWindow }, + { "glutPopWindow", (void *) glutPopWindow }, + { "glutPushWindow", (void *) glutPushWindow }, + { "glutIconifyWindow", (void *) glutIconifyWindow }, + { "glutShowWindow", (void *) glutShowWindow }, + { "glutHideWindow", (void *) glutHideWindow }, + { "glutFullScreen", (void *) glutFullScreen }, + { "glutSetCursor", (void *) glutSetCursor }, + { "glutWarpPointer", (void *) glutWarpPointer }, + { "glutEstablishOverlay", (void *) glutEstablishOverlay }, + { "glutRemoveOverlay", (void *) glutRemoveOverlay }, + { "glutUseLayer", (void *) glutUseLayer }, + { "glutPostOverlayRedisplay", (void *) glutPostOverlayRedisplay }, + { "glutPostWindowOverlayRedisplay", (void *) glutPostWindowOverlayRedisplay }, + { "glutShowOverlay", (void *) glutShowOverlay }, + { "glutHideOverlay", (void *) glutHideOverlay }, + { "glutCreateMenu", (void *) glutCreateMenu }, + { "glutDestroyMenu", (void *) glutDestroyMenu }, + { "glutGetMenu", (void *) glutGetMenu }, + { "glutSetMenu", (void *) glutSetMenu }, + { "glutAddMenuEntry", (void *) glutAddMenuEntry }, + { "glutAddSubMenu", (void *) glutAddSubMenu }, + { "glutChangeToMenuEntry", (void *) glutChangeToMenuEntry }, + { "glutChangeToSubMenu", (void *) glutChangeToSubMenu }, + { "glutRemoveMenuItem", (void *) glutRemoveMenuItem }, + { "glutAttachMenu", (void *) glutAttachMenu }, + { "glutDetachMenu", (void *) glutDetachMenu }, + { "glutDisplayFunc", (void *) glutDisplayFunc }, + { "glutReshapeFunc", (void *) glutReshapeFunc }, + { "glutKeyboardFunc", (void *) glutKeyboardFunc }, + { "glutMouseFunc", (void *) glutMouseFunc }, + { "glutMotionFunc", (void *) glutMotionFunc }, + { "glutPassiveMotionFunc", (void *) glutPassiveMotionFunc }, + { "glutEntryFunc", (void *) glutEntryFunc }, + { "glutVisibilityFunc", (void *) glutVisibilityFunc }, + { "glutIdleFunc", (void *) glutIdleFunc }, + { "glutTimerFunc", (void *) glutTimerFunc }, + { "glutMenuStateFunc", (void *) glutMenuStateFunc }, + { "glutSpecialFunc", (void *) glutSpecialFunc }, + { "glutSpaceballMotionFunc", (void *) glutSpaceballMotionFunc }, + { "glutSpaceballRotateFunc", (void *) glutSpaceballRotateFunc }, + { "glutSpaceballButtonFunc", (void *) glutSpaceballButtonFunc }, + { "glutButtonBoxFunc", (void *) glutButtonBoxFunc }, + { "glutDialsFunc", (void *) glutDialsFunc }, + { "glutTabletMotionFunc", (void *) glutTabletMotionFunc }, + { "glutTabletButtonFunc", (void *) glutTabletButtonFunc }, + { "glutMenuStatusFunc", (void *) glutMenuStatusFunc }, + { "glutOverlayDisplayFunc", (void *) glutOverlayDisplayFunc }, + { "glutWindowStatusFunc", (void *) glutWindowStatusFunc }, + { "glutKeyboardUpFunc", (void *) glutKeyboardUpFunc }, + { "glutSpecialUpFunc", (void *) glutSpecialUpFunc }, + { "glutJoystickFunc", (void *) glutJoystickFunc }, + { "glutSetColor", (void *) glutSetColor }, + { "glutGetColor", (void *) glutGetColor }, + { "glutCopyColormap", (void *) glutCopyColormap }, + { "glutGet", (void *) glutGet }, + { "glutDeviceGet", (void *) glutDeviceGet }, + { "glutExtensionSupported", (void *) glutExtensionSupported }, + { "glutGetModifiers", (void *) glutGetModifiers }, + { "glutLayerGet", (void *) glutLayerGet }, + { "glutBitmapCharacter", (void *) glutBitmapCharacter }, + { "glutBitmapWidth", (void *) glutBitmapWidth }, + { "glutStrokeCharacter", (void *) glutStrokeCharacter }, + { "glutStrokeWidth", (void *) glutStrokeWidth }, + { "glutBitmapLength", (void *) glutBitmapLength }, + { "glutStrokeLength", (void *) glutStrokeLength }, + { "glutWireSphere", (void *) glutWireSphere }, + { "glutSolidSphere", (void *) glutSolidSphere }, + { "glutWireCone", (void *) glutWireCone }, + { "glutSolidCone", (void *) glutSolidCone }, + { "glutWireCube", (void *) glutWireCube }, + { "glutSolidCube", (void *) glutSolidCube }, + { "glutWireTorus", (void *) glutWireTorus }, + { "glutSolidTorus", (void *) glutSolidTorus }, + { "glutWireDodecahedron", (void *) glutWireDodecahedron }, + { "glutSolidDodecahedron", (void *) glutSolidDodecahedron }, + { "glutWireTeapot", (void *) glutWireTeapot }, + { "glutSolidTeapot", (void *) glutSolidTeapot }, + { "glutWireOctahedron", (void *) glutWireOctahedron }, + { "glutSolidOctahedron", (void *) glutSolidOctahedron }, + { "glutWireTetrahedron", (void *) glutWireTetrahedron }, + { "glutSolidTetrahedron", (void *) glutSolidTetrahedron }, + { "glutWireIcosahedron", (void *) glutWireIcosahedron }, + { "glutSolidIcosahedron", (void *) glutSolidIcosahedron }, + { "glutVideoResizeGet", (void *) glutVideoResizeGet }, + { "glutSetupVideoResizing", (void *) glutSetupVideoResizing }, + { "glutStopVideoResizing", (void *) glutStopVideoResizing }, + { "glutVideoResize", (void *) glutVideoResize }, + { "glutVideoPan", (void *) glutVideoPan }, + { "glutReportErrors", (void *) glutReportErrors }, + { "glutIgnoreKeyRepeat", (void *) glutIgnoreKeyRepeat }, + { "glutSetKeyRepeat", (void *) glutSetKeyRepeat }, + { "glutForceJoystickFunc", (void *) glutForceJoystickFunc }, + { "glutGameModeString", (void *) glutGameModeString }, + { "glutEnterGameMode", (void *) glutEnterGameMode }, + { "glutLeaveGameMode", (void *) glutLeaveGameMode }, + { "glutGameModeGet", (void *) glutGameModeGet }, + /* FreeGLUT extensions */ + { "glutMainLoopEvent", (void *) glutMainLoopEvent }, + { "glutLeaveMainLoop", (void *) glutLeaveMainLoop }, + { "glutCloseFunc", (void *) glutCloseFunc }, + { "glutWMCloseFunc", (void *) glutWMCloseFunc }, + { "glutSetOption ", (void *) glutSetOption }, + { "glutBitmapHeight", (void *) glutBitmapHeight }, + { "glutStrokeHeight", (void *) glutStrokeHeight }, + { "glutBitmapString", (void *) glutBitmapString }, + { "glutStrokeString", (void *) glutStrokeString }, + { "glutWireRhombicDodecahedron", (void *) glutWireRhombicDodecahedron }, + { "glutSolidRhombicDodecahedron", (void *) glutSolidRhombicDodecahedron }, + { "glutWireSierpinskiSponge ", (void *) glutWireSierpinskiSponge }, + { "glutSolidSierpinskiSponge ", (void *) glutSolidSierpinskiSponge }, + { "glutGetProcAddress", (void *) glutGetProcAddress }, + { NULL, NULL } +}; + + +void * FGAPIENTRY glutGetProcAddress(const char *procName) +{ + /* Try GLUT functions first */ + int i; + for (i = 0; glut_functions[i].name; i++) { + if (strcmp(glut_functions[i].name, procName) == 0) + return glut_functions[i].address; + } + + /* Try core GL functions */ +#if TARGET_HOST_WIN32 + return (void *) wglGetProcAddress((LPCSTR) procName); +#elif TARGET_HOST_UNIX_X11 && defined(GLX_ARB_get_proc_address) + return (void *) glXGetProcAddressARB((const GLubyte *) procName); +#else + return NULL; +#endif +} diff --git a/include/GL/freeglut_ext.h b/include/GL/freeglut_ext.h index de38965..9bef572 100644 --- a/include/GL/freeglut_ext.h +++ b/include/GL/freeglut_ext.h @@ -80,6 +80,12 @@ FGAPI void FGAPIENTRY glutSolidRhombicDodecahedron( void ); FGAPI void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLfloat offset[3], GLfloat scale ) ; FGAPI void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLfloat offset[3], GLfloat scale ) ; +/* + * Extension functions, see freeglut_ext.c + */ +FGAPI void * FGAPIENTRY glutGetProcAddress( const char *procName ); + + #ifdef __cplusplus } #endif -- 1.7.10.4