From 479b3d074589b1582e85aec90e53b82154ebcc2d Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Mon, 16 Aug 2004 08:46:38 +0000 Subject: Add glutGetProcAddress(). Not all GLUT version 5 APIs are supported yet, thought. -> #define GLUT_API_VERSION 4.5 ? ;-) --- src/glut/beos/Makefile | 7 +- src/glut/beos/glutGet.cpp | 36 --------- src/glut/beos/glut_ext.c | 201 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 40 deletions(-) create mode 100644 src/glut/beos/glut_ext.c (limited to 'src/glut/beos') diff --git a/src/glut/beos/Makefile b/src/glut/beos/Makefile index 9104fd8edf..effd3749a4 100644 --- a/src/glut/beos/Makefile +++ b/src/glut/beos/Makefile @@ -52,7 +52,8 @@ C_SOURCES = \ glut_shapes.c \ glut_teapot.c \ glut_vidresize.c \ - glut_util.c + glut_util.c \ + glut_ext.c OBJECTS = \ $(CPP_SOURCES:.cpp=.o) \ @@ -63,8 +64,6 @@ INCLUDES = \ -I- \ -I$(TOP)/include -DEFINES += -DGLUT_API_VERSION=4 - # Rules .cpp.o: @@ -84,7 +83,7 @@ $(LIB_DIR): # Make the library $(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) - $(TOP)/bin/mklib -o $(GLUT_LIB) -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \ + @$(TOP)/bin/mklib -o $(GLUT_LIB) -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \ -install $(LIB_DIR) $(MKLIB_OPTIONS) $(GLUT_LIB_DEPS) \ $(OBJECTS) diff --git a/src/glut/beos/glutGet.cpp b/src/glut/beos/glutGet.cpp index 45d07f7e46..04a8479b98 100644 --- a/src/glut/beos/glutGet.cpp +++ b/src/glut/beos/glutGet.cpp @@ -209,39 +209,3 @@ int glutGetModifiers() { return gState.modifierKeys; } -/*********************************************************** - * FUNCTION: glutExtensionSupported (9.5) - * - * DESCRIPTION: is an OpenGL extension supported (from glut_ext.c) - ***********************************************************/ -int glutExtensionSupported(const char *extension) { - static const GLubyte *extensions = NULL; - const GLubyte *start; - GLubyte *where, *terminator; - - /* Extension names should not have spaces. */ - where = (GLubyte *) strchr(extension, ' '); - if (where || *extension == '\0') - return 0; - - if (!extensions) - extensions = glGetString(GL_EXTENSIONS); - /* It takes a bit of care to be fool-proof about parsing the - OpenGL extensions string. Don't be fooled by sub-strings, - - etc. */ - start = extensions; - for (;;) { - where = (GLubyte *) strstr((const char *) start, extension); - if (!where) - break; - terminator = where + strlen(extension); - if (where == start || *(where - 1) == ' ') { - if (*terminator == ' ' || *terminator == '\0') { - return 1; - } - } - start = terminator; - } - return 0; -} diff --git a/src/glut/beos/glut_ext.c b/src/glut/beos/glut_ext.c new file mode 100644 index 0000000000..eca3625938 --- /dev/null +++ b/src/glut/beos/glut_ext.c @@ -0,0 +1,201 @@ + +/* Copyright (c) Mark J. Kilgard, 1994, 1997. */ + +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or + implied. This program is -not- in the public domain. */ + +#include +#include + +#include "glutint.h" + +/* CENTRY */ +int GLUTAPIENTRY +glutExtensionSupported(const char *extension) +{ + static const GLubyte *extensions = NULL; + const GLubyte *start; + GLubyte *where, *terminator; + + /* Extension names should not have spaces. */ + where = (GLubyte *) strchr(extension, ' '); + if (where || *extension == '\0') + return 0; + + if (!extensions) { + extensions = glGetString(GL_EXTENSIONS); + } + /* It takes a bit of care to be fool-proof about parsing the + OpenGL extensions string. Don't be fooled by sub-strings, + etc. */ + start = extensions; + for (;;) { + /* If your application crashes in the strstr routine below, + you are probably calling glutExtensionSupported without + having a current window. Calling glGetString without + a current OpenGL context has unpredictable results. + Please fix your program. */ + where = (GLubyte *) strstr((const char *) start, extension); + if (!where) + break; + terminator = where + strlen(extension); + if (where == start || *(where - 1) == ' ') { + if (*terminator == ' ' || *terminator == '\0') { + return 1; + } + } + start = terminator; + } + return 0; +} + + +struct name_address_pair { + const char *name; + const void *address; +}; + +static struct name_address_pair glut_functions[] = { + { "glutInit", (const void *) glutInit }, + { "glutInitDisplayMode", (const void *) glutInitDisplayMode }, + { "glutInitDisplayString", (const void *) glutInitDisplayString }, + { "glutInitWindowPosition", (const void *) glutInitWindowPosition }, + { "glutInitWindowSize", (const void *) glutInitWindowSize }, + { "glutMainLoop", (const void *) glutMainLoop }, + { "glutCreateWindow", (const void *) glutCreateWindow }, + { "glutCreateSubWindow", (const void *) glutCreateSubWindow }, + { "glutDestroyWindow", (const void *) glutDestroyWindow }, + { "glutPostRedisplay", (const void *) glutPostRedisplay }, + { "glutPostWindowRedisplay", (const void *) glutPostWindowRedisplay }, + { "glutSwapBuffers", (const void *) glutSwapBuffers }, + { "glutGetWindow", (const void *) glutGetWindow }, + { "glutSetWindow", (const void *) glutSetWindow }, + { "glutSetWindowTitle", (const void *) glutSetWindowTitle }, + { "glutSetIconTitle", (const void *) glutSetIconTitle }, + { "glutPositionWindow", (const void *) glutPositionWindow }, + { "glutReshapeWindow", (const void *) glutReshapeWindow }, + { "glutPopWindow", (const void *) glutPopWindow }, + { "glutPushWindow", (const void *) glutPushWindow }, + { "glutIconifyWindow", (const void *) glutIconifyWindow }, + { "glutShowWindow", (const void *) glutShowWindow }, + { "glutHideWindow", (const void *) glutHideWindow }, + { "glutFullScreen", (const void *) glutFullScreen }, + { "glutSetCursor", (const void *) glutSetCursor }, + { "glutWarpPointer", (const void *) glutWarpPointer }, + { "glutEstablishOverlay", (const void *) glutEstablishOverlay }, + { "glutRemoveOverlay", (const void *) glutRemoveOverlay }, + { "glutUseLayer", (const void *) glutUseLayer }, + { "glutPostOverlayRedisplay", (const void *) glutPostOverlayRedisplay }, + { "glutPostWindowOverlayRedisplay", (const void *) glutPostWindowOverlayRedisplay }, + { "glutShowOverlay", (const void *) glutShowOverlay }, + { "glutHideOverlay", (const void *) glutHideOverlay }, + { "glutCreateMenu", (const void *) glutCreateMenu }, + { "glutDestroyMenu", (const void *) glutDestroyMenu }, + { "glutGetMenu", (const void *) glutGetMenu }, + { "glutSetMenu", (const void *) glutSetMenu }, + { "glutAddMenuEntry", (const void *) glutAddMenuEntry }, + { "glutAddSubMenu", (const void *) glutAddSubMenu }, + { "glutChangeToMenuEntry", (const void *) glutChangeToMenuEntry }, + { "glutChangeToSubMenu", (const void *) glutChangeToSubMenu }, + { "glutRemoveMenuItem", (const void *) glutRemoveMenuItem }, + { "glutAttachMenu", (const void *) glutAttachMenu }, + { "glutDetachMenu", (const void *) glutDetachMenu }, + { "glutDisplayFunc", (const void *) glutDisplayFunc }, + { "glutReshapeFunc", (const void *) glutReshapeFunc }, + { "glutKeyboardFunc", (const void *) glutKeyboardFunc }, + { "glutMouseFunc", (const void *) glutMouseFunc }, + { "glutMotionFunc", (const void *) glutMotionFunc }, + { "glutPassiveMotionFunc", (const void *) glutPassiveMotionFunc }, + { "glutEntryFunc", (const void *) glutEntryFunc }, + { "glutVisibilityFunc", (const void *) glutVisibilityFunc }, + { "glutIdleFunc", (const void *) glutIdleFunc }, + { "glutTimerFunc", (const void *) glutTimerFunc }, + { "glutMenuStateFunc", (const void *) glutMenuStateFunc }, + { "glutSpecialFunc", (const void *) glutSpecialFunc }, + { "glutSpaceballMotionFunc", (const void *) glutSpaceballMotionFunc }, + { "glutSpaceballRotateFunc", (const void *) glutSpaceballRotateFunc }, + { "glutSpaceballButtonFunc", (const void *) glutSpaceballButtonFunc }, + { "glutButtonBoxFunc", (const void *) glutButtonBoxFunc }, + { "glutDialsFunc", (const void *) glutDialsFunc }, + { "glutTabletMotionFunc", (const void *) glutTabletMotionFunc }, + { "glutTabletButtonFunc", (const void *) glutTabletButtonFunc }, + { "glutMenuStatusFunc", (const void *) glutMenuStatusFunc }, + { "glutOverlayDisplayFunc", (const void *) glutOverlayDisplayFunc }, + { "glutWindowStatusFunc", (const void *) glutWindowStatusFunc }, +// { "glutKeyboardUpFunc", (const void *) glutKeyboardUpFunc }, +// { "glutSpecialUpFunc", (const void *) glutSpecialUpFunc }, +// { "glutJoystickFunc", (const void *) glutJoystickFunc }, + { "glutSetColor", (const void *) glutSetColor }, + { "glutGetColor", (const void *) glutGetColor }, + { "glutCopyColormap", (const void *) glutCopyColormap }, + { "glutGet", (const void *) glutGet }, + { "glutDeviceGet", (const void *) glutDeviceGet }, + { "glutExtensionSupported", (const void *) glutExtensionSupported }, + { "glutGetModifiers", (const void *) glutGetModifiers }, + { "glutLayerGet", (const void *) glutLayerGet }, + { "glutGetProcAddress", (const void *) glutGetProcAddress }, + { "glutBitmapCharacter", (const void *) glutBitmapCharacter }, + { "glutBitmapWidth", (const void *) glutBitmapWidth }, + { "glutStrokeCharacter", (const void *) glutStrokeCharacter }, + { "glutStrokeWidth", (const void *) glutStrokeWidth }, + { "glutBitmapLength", (const void *) glutBitmapLength }, + { "glutStrokeLength", (const void *) glutStrokeLength }, + { "glutWireSphere", (const void *) glutWireSphere }, + { "glutSolidSphere", (const void *) glutSolidSphere }, + { "glutWireCone", (const void *) glutWireCone }, + { "glutSolidCone", (const void *) glutSolidCone }, + { "glutWireCube", (const void *) glutWireCube }, + { "glutSolidCube", (const void *) glutSolidCube }, + { "glutWireTorus", (const void *) glutWireTorus }, + { "glutSolidTorus", (const void *) glutSolidTorus }, + { "glutWireDodecahedron", (const void *) glutWireDodecahedron }, + { "glutSolidDodecahedron", (const void *) glutSolidDodecahedron }, + { "glutWireTeapot", (const void *) glutWireTeapot }, + { "glutSolidTeapot", (const void *) glutSolidTeapot }, + { "glutWireOctahedron", (const void *) glutWireOctahedron }, + { "glutSolidOctahedron", (const void *) glutSolidOctahedron }, + { "glutWireTetrahedron", (const void *) glutWireTetrahedron }, + { "glutSolidTetrahedron", (const void *) glutSolidTetrahedron }, + { "glutWireIcosahedron", (const void *) glutWireIcosahedron }, + { "glutSolidIcosahedron", (const void *) glutSolidIcosahedron }, + { "glutVideoResizeGet", (const void *) glutVideoResizeGet }, + { "glutSetupVideoResizing", (const void *) glutSetupVideoResizing }, + { "glutStopVideoResizing", (const void *) glutStopVideoResizing }, + { "glutVideoResize", (const void *) glutVideoResize }, + { "glutVideoPan", (const void *) glutVideoPan }, + { "glutReportErrors", (const void *) glutReportErrors }, +// { "glutIgnoreKeyRepeat", (const void *) glutIgnoreKeyRepeat }, +// { "glutSetKeyRepeat", (const void *) glutSetKeyRepeat }, +// { "glutForceJoystickFunc", (const void *) glutForceJoystickFunc }, +// { "glutGameModeString", (const void *) glutGameModeString }, +// { "glutEnterGameMode", (const void *) glutEnterGameMode }, +// { "glutLeaveGameMode", (const void *) glutLeaveGameMode }, +// { "glutGameModeGet", (const void *) glutGameModeGet }, + { NULL, NULL } +}; + + +/* XXX This isn't an official GLUT function, yet */ +void * GLUTAPIENTRY +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 (void *) glut_functions[i].address; + } + + /* Try core GL functions */ +#if defined(_WIN32) + return (void *) wglGetProcAddress((LPCSTR) procName); +#elif defined(GLX_ARB_get_proc_address) + return (void *) glXGetProcAddressARB((const GLubyte *) procName); +#else + return NULL; +#endif +} + + +/* ENDCENTRY */ -- cgit v1.2.3