Fix object/function pointer inconsistencies which are a problem for gcc 3.4.2.

Added GLUTproc type, returned by glutGetProcAddress().


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@566 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
brianp 2005-02-11 15:18:04 +00:00
parent 3506d4ac40
commit e9be78b6fc
3 changed files with 153 additions and 143 deletions

View File

@ -112,7 +112,8 @@ FGAPI void FGAPIENTRY glutSolidCylinder( GLdouble radius, GLdouble height, GL
/*
* Extension functions, see freeglut_ext.c
*/
FGAPI void * FGAPIENTRY glutGetProcAddress( const char *procName );
typedef void (*GLUTproc)();
FGAPI GLUTproc FGAPIENTRY glutGetProcAddress( const char *procName );
#ifdef __cplusplus

View File

@ -32,157 +32,158 @@
struct name_address_pair
{
const char *name;
void *address;
GLUTproc 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 },
{ "glutInit", (GLUTproc) glutInit },
{ "glutInitDisplayMode", (GLUTproc) glutInitDisplayMode },
{ "glutInitDisplayString", (GLUTproc) glutInitDisplayString },
{ "glutInitWindowPosition", (GLUTproc) glutInitWindowPosition },
{ "glutInitWindowSize", (GLUTproc) glutInitWindowSize },
{ "glutMainLoop", (GLUTproc) glutMainLoop },
{ "glutCreateWindow", (GLUTproc) glutCreateWindow },
{ "glutCreateSubWindow", (GLUTproc) glutCreateSubWindow },
{ "glutDestroyWindow", (GLUTproc) glutDestroyWindow },
{ "glutPostRedisplay", (GLUTproc) glutPostRedisplay },
{ "glutPostWindowRedisplay", (GLUTproc) glutPostWindowRedisplay },
{ "glutSwapBuffers", (GLUTproc) glutSwapBuffers },
{ "glutGetWindow", (GLUTproc) glutGetWindow },
{ "glutSetWindow", (GLUTproc) glutSetWindow },
{ "glutSetWindowTitle", (GLUTproc) glutSetWindowTitle },
{ "glutSetIconTitle", (GLUTproc) glutSetIconTitle },
{ "glutPositionWindow", (GLUTproc) glutPositionWindow },
{ "glutReshapeWindow", (GLUTproc) glutReshapeWindow },
{ "glutPopWindow", (GLUTproc) glutPopWindow },
{ "glutPushWindow", (GLUTproc) glutPushWindow },
{ "glutIconifyWindow", (GLUTproc) glutIconifyWindow },
{ "glutShowWindow", (GLUTproc) glutShowWindow },
{ "glutHideWindow", (GLUTproc) glutHideWindow },
{ "glutFullScreen", (GLUTproc) glutFullScreen },
{ "glutSetCursor", (GLUTproc) glutSetCursor },
{ "glutWarpPointer", (GLUTproc) glutWarpPointer },
{ "glutEstablishOverlay", (GLUTproc) glutEstablishOverlay },
{ "glutRemoveOverlay", (GLUTproc) glutRemoveOverlay },
{ "glutUseLayer", (GLUTproc) glutUseLayer },
{ "glutPostOverlayRedisplay", (GLUTproc) glutPostOverlayRedisplay },
{ "glutPostWindowOverlayRedisplay", (GLUTproc) glutPostWindowOverlayRedisplay },
{ "glutShowOverlay", (GLUTproc) glutShowOverlay },
{ "glutHideOverlay", (GLUTproc) glutHideOverlay },
{ "glutCreateMenu", (GLUTproc) glutCreateMenu },
{ "glutDestroyMenu", (GLUTproc) glutDestroyMenu },
{ "glutGetMenu", (GLUTproc) glutGetMenu },
{ "glutSetMenu", (GLUTproc) glutSetMenu },
{ "glutAddMenuEntry", (GLUTproc) glutAddMenuEntry },
{ "glutAddSubMenu", (GLUTproc) glutAddSubMenu },
{ "glutChangeToMenuEntry", (GLUTproc) glutChangeToMenuEntry },
{ "glutChangeToSubMenu", (GLUTproc) glutChangeToSubMenu },
{ "glutRemoveMenuItem", (GLUTproc) glutRemoveMenuItem },
{ "glutAttachMenu", (GLUTproc) glutAttachMenu },
{ "glutDetachMenu", (GLUTproc) glutDetachMenu },
{ "glutDisplayFunc", (GLUTproc) glutDisplayFunc },
{ "glutReshapeFunc", (GLUTproc) glutReshapeFunc },
{ "glutKeyboardFunc", (GLUTproc) glutKeyboardFunc },
{ "glutMouseFunc", (GLUTproc) glutMouseFunc },
{ "glutMotionFunc", (GLUTproc) glutMotionFunc },
{ "glutPassiveMotionFunc", (GLUTproc) glutPassiveMotionFunc },
{ "glutEntryFunc", (GLUTproc) glutEntryFunc },
{ "glutVisibilityFunc", (GLUTproc) glutVisibilityFunc },
{ "glutIdleFunc", (GLUTproc) glutIdleFunc },
{ "glutTimerFunc", (GLUTproc) glutTimerFunc },
{ "glutMenuStateFunc", (GLUTproc) glutMenuStateFunc },
{ "glutSpecialFunc", (GLUTproc) glutSpecialFunc },
{ "glutSpaceballMotionFunc", (GLUTproc) glutSpaceballMotionFunc },
{ "glutSpaceballRotateFunc", (GLUTproc) glutSpaceballRotateFunc },
{ "glutSpaceballButtonFunc", (GLUTproc) glutSpaceballButtonFunc },
{ "glutButtonBoxFunc", (GLUTproc) glutButtonBoxFunc },
{ "glutDialsFunc", (GLUTproc) glutDialsFunc },
{ "glutTabletMotionFunc", (GLUTproc) glutTabletMotionFunc },
{ "glutTabletButtonFunc", (GLUTproc) glutTabletButtonFunc },
{ "glutMenuStatusFunc", (GLUTproc) glutMenuStatusFunc },
{ "glutOverlayDisplayFunc", (GLUTproc) glutOverlayDisplayFunc },
{ "glutWindowStatusFunc", (GLUTproc) glutWindowStatusFunc },
{ "glutKeyboardUpFunc", (GLUTproc) glutKeyboardUpFunc },
{ "glutSpecialUpFunc", (GLUTproc) glutSpecialUpFunc },
#if !TARGET_HOST_WINCE
{ "glutJoystickFunc", (void *) glutJoystickFunc },
{ "glutJoystickFunc", (GLUTproc) glutJoystickFunc },
#endif /* !TARGET_HOST_WINCE */
{ "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 },
{ "glutSetColor", (GLUTproc) glutSetColor },
{ "glutGetColor", (GLUTproc) glutGetColor },
{ "glutCopyColormap", (GLUTproc) glutCopyColormap },
{ "glutGet", (GLUTproc) glutGet },
{ "glutDeviceGet", (GLUTproc) glutDeviceGet },
{ "glutExtensionSupported", (GLUTproc) glutExtensionSupported },
{ "glutGetModifiers", (GLUTproc) glutGetModifiers },
{ "glutLayerGet", (GLUTproc) glutLayerGet },
{ "glutBitmapCharacter", (GLUTproc) glutBitmapCharacter },
{ "glutBitmapWidth", (GLUTproc) glutBitmapWidth },
{ "glutStrokeCharacter", (GLUTproc) glutStrokeCharacter },
{ "glutStrokeWidth", (GLUTproc) glutStrokeWidth },
{ "glutBitmapLength", (GLUTproc) glutBitmapLength },
{ "glutStrokeLength", (GLUTproc) glutStrokeLength },
{ "glutWireSphere", (GLUTproc) glutWireSphere },
{ "glutSolidSphere", (GLUTproc) glutSolidSphere },
{ "glutWireCone", (GLUTproc) glutWireCone },
{ "glutSolidCone", (GLUTproc) glutSolidCone },
{ "glutWireCube", (GLUTproc) glutWireCube },
{ "glutSolidCube", (GLUTproc) glutSolidCube },
{ "glutWireTorus", (GLUTproc) glutWireTorus },
{ "glutSolidTorus", (GLUTproc) glutSolidTorus },
{ "glutWireDodecahedron", (GLUTproc) glutWireDodecahedron },
{ "glutSolidDodecahedron", (GLUTproc) glutSolidDodecahedron },
{ "glutWireTeapot", (GLUTproc) glutWireTeapot },
{ "glutSolidTeapot", (GLUTproc) glutSolidTeapot },
{ "glutWireOctahedron", (GLUTproc) glutWireOctahedron },
{ "glutSolidOctahedron", (GLUTproc) glutSolidOctahedron },
{ "glutWireTetrahedron", (GLUTproc) glutWireTetrahedron },
{ "glutSolidTetrahedron", (GLUTproc) glutSolidTetrahedron },
{ "glutWireIcosahedron", (GLUTproc) glutWireIcosahedron },
{ "glutSolidIcosahedron", (GLUTproc) glutSolidIcosahedron },
{ "glutVideoResizeGet", (GLUTproc) glutVideoResizeGet },
{ "glutSetupVideoResizing", (GLUTproc) glutSetupVideoResizing },
{ "glutStopVideoResizing", (GLUTproc) glutStopVideoResizing },
{ "glutVideoResize", (GLUTproc) glutVideoResize },
{ "glutVideoPan", (GLUTproc) glutVideoPan },
{ "glutReportErrors", (GLUTproc) glutReportErrors },
{ "glutIgnoreKeyRepeat", (GLUTproc) glutIgnoreKeyRepeat },
{ "glutSetKeyRepeat", (GLUTproc) glutSetKeyRepeat },
#if !TARGET_HOST_WINCE
{ "glutForceJoystickFunc", (void *) glutForceJoystickFunc },
{ "glutGameModeString", (void *) glutGameModeString },
{ "glutEnterGameMode", (void *) glutEnterGameMode },
{ "glutLeaveGameMode", (void *) glutLeaveGameMode },
{ "glutGameModeGet", (void *) glutGameModeGet },
{ "glutForceJoystickFunc", (GLUTproc) glutForceJoystickFunc },
{ "glutGameModeString", (GLUTproc) glutGameModeString },
{ "glutEnterGameMode", (GLUTproc) glutEnterGameMode },
{ "glutLeaveGameMode", (GLUTproc) glutLeaveGameMode },
{ "glutGameModeGet", (GLUTproc) glutGameModeGet },
#endif /* !TARGET_HOST_WINCE */
/* freeglut extensions */
{ "glutMainLoopEvent", (void *) glutMainLoopEvent },
{ "glutLeaveMainLoop", (void *) glutLeaveMainLoop },
{ "glutCloseFunc", (void *) glutCloseFunc },
{ "glutWMCloseFunc", (void *) glutWMCloseFunc },
{ "glutMenuDestroyFunc", (void *) glutMenuDestroyFunc },
{ "glutSetOption", (void *) glutSetOption },
{ "glutSetWindowData", (void *) glutSetWindowData },
{ "glutGetWindowData", (void *) glutGetWindowData },
{ "glutSetMenuData", (void *) glutSetMenuData },
{ "glutGetMenuData", (void *) glutGetMenuData },
{ "glutBitmapHeight", (void *) glutBitmapHeight },
{ "glutStrokeHeight", (void *) glutStrokeHeight },
{ "glutBitmapString", (void *) glutBitmapString },
{ "glutStrokeString", (void *) glutStrokeString },
{ "glutWireRhombicDodecahedron", (void *) glutWireRhombicDodecahedron },
{ "glutSolidRhombicDodecahedron", (void *) glutSolidRhombicDodecahedron },
{ "glutWireSierpinskiSponge", (void *) glutWireSierpinskiSponge },
{ "glutSolidSierpinskiSponge", (void *) glutSolidSierpinskiSponge },
{ "glutWireCylinder", (void *) glutWireCylinder },
{ "glutSolidCylinder", (void *) glutSolidCylinder },
{ "glutGetProcAddress", (void *) glutGetProcAddress },
{ "glutMouseWheelFunc", (void *) glutMouseWheelFunc },
{ "glutMainLoopEvent", (GLUTproc) glutMainLoopEvent },
{ "glutLeaveMainLoop", (GLUTproc) glutLeaveMainLoop },
{ "glutCloseFunc", (GLUTproc) glutCloseFunc },
{ "glutWMCloseFunc", (GLUTproc) glutWMCloseFunc },
{ "glutMenuDestroyFunc", (GLUTproc) glutMenuDestroyFunc },
{ "glutSetOption", (GLUTproc) glutSetOption },
{ "glutSetWindowData", (GLUTproc) glutSetWindowData },
{ "glutGetWindowData", (GLUTproc) glutGetWindowData },
{ "glutSetMenuData", (GLUTproc) glutSetMenuData },
{ "glutGetMenuData", (GLUTproc) glutGetMenuData },
{ "glutBitmapHeight", (GLUTproc) glutBitmapHeight },
{ "glutStrokeHeight", (GLUTproc) glutStrokeHeight },
{ "glutBitmapString", (GLUTproc) glutBitmapString },
{ "glutStrokeString", (GLUTproc) glutStrokeString },
{ "glutWireRhombicDodecahedron", (GLUTproc) glutWireRhombicDodecahedron },
{ "glutSolidRhombicDodecahedron", (GLUTproc) glutSolidRhombicDodecahedron },
{ "glutWireSierpinskiSponge", (GLUTproc) glutWireSierpinskiSponge },
{ "glutSolidSierpinskiSponge", (GLUTproc) glutSolidSierpinskiSponge },
{ "glutWireCylinder", (GLUTproc) glutWireCylinder },
{ "glutSolidCylinder", (GLUTproc) glutSolidCylinder },
{ "glutGetProcAddress", (GLUTproc) glutGetProcAddress },
{ "glutMouseWheelFunc", (GLUTproc) glutMouseWheelFunc },
{ NULL, NULL }
};
void *FGAPIENTRY glutGetProcAddress( const char *procName )
GLUTproc FGAPIENTRY
glutGetProcAddress( const char *procName )
{
/* Try GLUT functions first */
int i;
@ -193,9 +194,9 @@ void *FGAPIENTRY glutGetProcAddress( const char *procName )
/* Try core GL functions */
#if TARGET_HOST_WIN32 || TARGET_HOST_WINCE
return( void * )wglGetProcAddress( ( LPCSTR )procName );
return(GLUTproc)wglGetProcAddress( ( LPCSTR )procName );
#elif TARGET_HOST_UNIX_X11 && defined( GLX_ARB_get_proc_address )
return(void * )glXGetProcAddressARB( ( const GLubyte * )procName );
return(GLUTproc)glXGetProcAddressARB( ( const GLubyte * )procName );
#else
return NULL;
#endif

View File

@ -359,6 +359,14 @@ struct tagSFG_WindowState
};
/*
* A generic function pointer. We should really use the GLUTproc type
* defined in freeglut_ext.h, but if we include that header in this file
* a bunch of other stuff (font-related) blows up!
*/
typedef void (*SFG_Proc)();
/*
* SET_WCB() is used as:
*
@ -380,7 +388,7 @@ struct tagSFG_WindowState
do \
{ \
if( FETCH_WCB( window, cbname ) != func ) \
(((window).CallBacks[CB_ ## cbname]) = (void *) func); \
(((window).CallBacks[CB_ ## cbname]) = (SFG_Proc) func); \
} while( 0 )
/*
@ -532,7 +540,7 @@ struct tagSFG_Window
SFG_Context Window; /* Window and OpenGL context */
SFG_WindowState State; /* The window state */
void *CallBacks[ TOTAL_CALLBACKS ]; /* Array of window callbacks */
SFG_Proc CallBacks[ TOTAL_CALLBACKS ]; /* Array of window callbacks */
void *UserData ; /* For use by user */
SFG_Menu* Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window */