From 642267b2d8c9848c5c1a11ba2b598dc313a2737a Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 12 Sep 2007 13:37:10 -0600 Subject: Rename. "fcb" = fortran call back --- src/glut/glx/glut_fcb.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 src/glut/glx/glut_fcb.c (limited to 'src/glut/glx/glut_fcb.c') diff --git a/src/glut/glx/glut_fcb.c b/src/glut/glx/glut_fcb.c new file mode 100644 index 00000000000..e93188b8622 --- /dev/null +++ b/src/glut/glx/glut_fcb.c @@ -0,0 +1,164 @@ + +/* Copyright (c) Mark J. Kilgard, 1998. */ + +/* 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. */ + +/* I appreciate the guidance from William Mitchell + (mitchell@cam.nist.gov) in developing this friend interface + for use by the f90gl package. See ../../README.fortran */ + +#include "glutint.h" + +/* FCB stands for Fortran CallBack. */ + +/* There is only one idleFunc, menuStateFunc, and menuStatusFunc, so they + can be saved in the wrappers for Fortran rather than the C structures. */ + +/* Set a Fortran callback function. */ + +void APIENTRY +__glutSetFCB(int which, void *func) +{ +#ifdef SUPPORT_FORTRAN + switch (which) { + case GLUT_FCB_DISPLAY: + __glutCurrentWindow->fdisplay = (GLUTdisplayFCB) func; + break; + case GLUT_FCB_RESHAPE: + __glutCurrentWindow->freshape = (GLUTreshapeFCB) func; + break; + case GLUT_FCB_MOUSE: + __glutCurrentWindow->fmouse = (GLUTmouseFCB) func; + break; + case GLUT_FCB_MOTION: + __glutCurrentWindow->fmotion = (GLUTmotionFCB) func; + break; + case GLUT_FCB_PASSIVE: + __glutCurrentWindow->fpassive = (GLUTpassiveFCB) func; + break; + case GLUT_FCB_ENTRY: + __glutCurrentWindow->fentry = (GLUTentryFCB) func; + break; + case GLUT_FCB_KEYBOARD: + __glutCurrentWindow->fkeyboard = (GLUTkeyboardFCB) func; + break; + case GLUT_FCB_KEYBOARD_UP: + __glutCurrentWindow->fkeyboardUp = (GLUTkeyboardFCB) func; + break; + case GLUT_FCB_WINDOW_STATUS: + __glutCurrentWindow->fwindowStatus = (GLUTwindowStatusFCB) func; + break; + case GLUT_FCB_VISIBILITY: + __glutCurrentWindow->fvisibility = (GLUTvisibilityFCB) func; + break; + case GLUT_FCB_SPECIAL: + __glutCurrentWindow->fspecial = (GLUTspecialFCB) func; + break; + case GLUT_FCB_SPECIAL_UP: + __glutCurrentWindow->fspecialUp = (GLUTspecialFCB) func; + break; + case GLUT_FCB_BUTTON_BOX: + __glutCurrentWindow->fbuttonBox = (GLUTbuttonBoxFCB) func; + break; + case GLUT_FCB_DIALS: + __glutCurrentWindow->fdials = (GLUTdialsFCB) func; + break; + case GLUT_FCB_SPACE_MOTION: + __glutCurrentWindow->fspaceMotion = (GLUTspaceMotionFCB) func; + break; + case GLUT_FCB_SPACE_ROTATE: + __glutCurrentWindow->fspaceRotate = (GLUTspaceRotateFCB) func; + break; + case GLUT_FCB_SPACE_BUTTON: + __glutCurrentWindow->fspaceButton = (GLUTspaceButtonFCB) func; + break; + case GLUT_FCB_TABLET_MOTION: + __glutCurrentWindow->ftabletMotion = (GLUTtabletMotionFCB) func; + break; + case GLUT_FCB_TABLET_BUTTON: + __glutCurrentWindow->ftabletButton = (GLUTtabletButtonFCB) func; + break; +#ifdef _WIN32 + case GLUT_FCB_JOYSTICK: + __glutCurrentWindow->fjoystick = (GLUTjoystickFCB) func; + break; +#endif + case GLUT_FCB_OVERLAY_DISPLAY: + __glutCurrentWindow->overlay->fdisplay = (GLUTdisplayFCB) func; + break; + case GLUT_FCB_SELECT: + __glutCurrentMenu->fselect = (GLUTselectFCB) func; + break; + case GLUT_FCB_TIMER: + __glutNewTimer->ffunc = (GLUTtimerFCB) func; + break; + } +#endif +} + +/* Get a Fortran callback function. */ + +void* APIENTRY +__glutGetFCB(int which) +{ +#ifdef SUPPORT_FORTRAN + switch (which) { + case GLUT_FCB_DISPLAY: + return (void *) __glutCurrentWindow->fdisplay; + case GLUT_FCB_RESHAPE: + return (void *) __glutCurrentWindow->freshape; + case GLUT_FCB_MOUSE: + return (void *) __glutCurrentWindow->fmouse; + case GLUT_FCB_MOTION: + return (void *) __glutCurrentWindow->fmotion; + case GLUT_FCB_PASSIVE: + return (void *) __glutCurrentWindow->fpassive; + case GLUT_FCB_ENTRY: + return (void *) __glutCurrentWindow->fentry; + case GLUT_FCB_KEYBOARD: + return (void *) __glutCurrentWindow->fkeyboard; + case GLUT_FCB_KEYBOARD_UP: + return (void *) __glutCurrentWindow->fkeyboardUp; + case GLUT_FCB_WINDOW_STATUS: + return (void *) __glutCurrentWindow->fwindowStatus; + case GLUT_FCB_VISIBILITY: + return (void *) __glutCurrentWindow->fvisibility; + case GLUT_FCB_SPECIAL: + return (void *) __glutCurrentWindow->fspecial; + case GLUT_FCB_SPECIAL_UP: + return (void *) __glutCurrentWindow->fspecialUp; + case GLUT_FCB_BUTTON_BOX: + return (void *) __glutCurrentWindow->fbuttonBox; + case GLUT_FCB_DIALS: + return (void *) __glutCurrentWindow->fdials; + case GLUT_FCB_SPACE_MOTION: + return (void *) __glutCurrentWindow->fspaceMotion; + case GLUT_FCB_SPACE_ROTATE: + return (void *) __glutCurrentWindow->fspaceRotate; + case GLUT_FCB_SPACE_BUTTON: + return (void *) __glutCurrentWindow->fspaceButton; + case GLUT_FCB_TABLET_MOTION: + return (void *) __glutCurrentWindow->ftabletMotion; + case GLUT_FCB_TABLET_BUTTON: + return (void *) __glutCurrentWindow->ftabletButton; + case GLUT_FCB_JOYSTICK: +#ifdef _WIN32 + return (void *) __glutCurrentWindow->fjoystick; +#else + return NULL; +#endif + case GLUT_FCB_OVERLAY_DISPLAY: + return (void *) __glutCurrentWindow->overlay->fdisplay; + case GLUT_FCB_SELECT: + return (void *) __glutCurrentMenu->fselect; + case GLUT_FCB_TIMER: + return (void *) __glutTimerList->ffunc; + default: + return NULL; + } +#else + return NULL; +#endif +} -- cgit v1.2.3 From ae0dd620fec580b77b0901ed1376e6a6b2569c7e Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 12 Sep 2007 13:40:15 -0600 Subject: Add glut_fcb.c to the build and update to fix warnings (see bug 12405) --- include/GL/glutf90.h | 4 ++-- src/glut/glx/Makefile | 1 + src/glut/glx/glut_fcb.c | 50 ++++++++++++++++++++++++------------------------- 3 files changed, 28 insertions(+), 27 deletions(-) (limited to 'src/glut/glx/glut_fcb.c') diff --git a/include/GL/glutf90.h b/include/GL/glutf90.h index 7ba3e19ef9e..8a3a86727cf 100644 --- a/include/GL/glutf90.h +++ b/include/GL/glutf90.h @@ -75,7 +75,7 @@ typedef void (GLUTCALLBACK *GLUTmenuStatusFCB) (int *, int *, int *); typedef void (GLUTCALLBACK *GLUTidleFCB) (void); /* Functions that set and return Fortran callback functions. */ -GLUTAPI void* APIENTRY __glutGetFCB(int which); -GLUTAPI void APIENTRY __glutSetFCB(int which, void *func); +GLUTAPI GLUTproc APIENTRY __glutGetFCB(int which); +GLUTAPI void APIENTRY __glutSetFCB(int which, GLUTproc func); #endif /* __glutf90_h__ */ diff --git a/src/glut/glx/Makefile b/src/glut/glx/Makefile index 5a224c9af59..f73158ad385 100644 --- a/src/glut/glx/Makefile +++ b/src/glut/glx/Makefile @@ -36,6 +36,7 @@ SOURCES = \ glut_dstr.c \ glut_event.c \ glut_ext.c \ + glut_fcb.c \ glut_fullscrn.c \ glut_gamemode.c \ glut_get.c \ diff --git a/src/glut/glx/glut_fcb.c b/src/glut/glx/glut_fcb.c index e93188b8622..b272d0e2278 100644 --- a/src/glut/glx/glut_fcb.c +++ b/src/glut/glx/glut_fcb.c @@ -19,7 +19,7 @@ /* Set a Fortran callback function. */ void APIENTRY -__glutSetFCB(int which, void *func) +__glutSetFCB(int which, GLUTproc func) { #ifdef SUPPORT_FORTRAN switch (which) { @@ -100,61 +100,61 @@ __glutSetFCB(int which, void *func) /* Get a Fortran callback function. */ -void* APIENTRY +GLUTproc APIENTRY __glutGetFCB(int which) { #ifdef SUPPORT_FORTRAN switch (which) { case GLUT_FCB_DISPLAY: - return (void *) __glutCurrentWindow->fdisplay; + return __glutCurrentWindow->fdisplay; case GLUT_FCB_RESHAPE: - return (void *) __glutCurrentWindow->freshape; + return __glutCurrentWindow->freshape; case GLUT_FCB_MOUSE: - return (void *) __glutCurrentWindow->fmouse; + return __glutCurrentWindow->fmouse; case GLUT_FCB_MOTION: - return (void *) __glutCurrentWindow->fmotion; + return __glutCurrentWindow->fmotion; case GLUT_FCB_PASSIVE: - return (void *) __glutCurrentWindow->fpassive; + return __glutCurrentWindow->fpassive; case GLUT_FCB_ENTRY: - return (void *) __glutCurrentWindow->fentry; + return __glutCurrentWindow->fentry; case GLUT_FCB_KEYBOARD: - return (void *) __glutCurrentWindow->fkeyboard; + return __glutCurrentWindow->fkeyboard; case GLUT_FCB_KEYBOARD_UP: - return (void *) __glutCurrentWindow->fkeyboardUp; + return __glutCurrentWindow->fkeyboardUp; case GLUT_FCB_WINDOW_STATUS: - return (void *) __glutCurrentWindow->fwindowStatus; + return __glutCurrentWindow->fwindowStatus; case GLUT_FCB_VISIBILITY: - return (void *) __glutCurrentWindow->fvisibility; + return __glutCurrentWindow->fvisibility; case GLUT_FCB_SPECIAL: - return (void *) __glutCurrentWindow->fspecial; + return __glutCurrentWindow->fspecial; case GLUT_FCB_SPECIAL_UP: - return (void *) __glutCurrentWindow->fspecialUp; + return __glutCurrentWindow->fspecialUp; case GLUT_FCB_BUTTON_BOX: - return (void *) __glutCurrentWindow->fbuttonBox; + return __glutCurrentWindow->fbuttonBox; case GLUT_FCB_DIALS: - return (void *) __glutCurrentWindow->fdials; + return __glutCurrentWindow->fdials; case GLUT_FCB_SPACE_MOTION: - return (void *) __glutCurrentWindow->fspaceMotion; + return __glutCurrentWindow->fspaceMotion; case GLUT_FCB_SPACE_ROTATE: - return (void *) __glutCurrentWindow->fspaceRotate; + return __glutCurrentWindow->fspaceRotate; case GLUT_FCB_SPACE_BUTTON: - return (void *) __glutCurrentWindow->fspaceButton; + return __glutCurrentWindow->fspaceButton; case GLUT_FCB_TABLET_MOTION: - return (void *) __glutCurrentWindow->ftabletMotion; + return __glutCurrentWindow->ftabletMotion; case GLUT_FCB_TABLET_BUTTON: - return (void *) __glutCurrentWindow->ftabletButton; + return __glutCurrentWindow->ftabletButton; case GLUT_FCB_JOYSTICK: #ifdef _WIN32 - return (void *) __glutCurrentWindow->fjoystick; + return __glutCurrentWindow->fjoystick; #else return NULL; #endif case GLUT_FCB_OVERLAY_DISPLAY: - return (void *) __glutCurrentWindow->overlay->fdisplay; + return __glutCurrentWindow->overlay->fdisplay; case GLUT_FCB_SELECT: - return (void *) __glutCurrentMenu->fselect; + return __glutCurrentMenu->fselect; case GLUT_FCB_TIMER: - return (void *) __glutTimerList->ffunc; + return __glutTimerList->ffunc; default: return NULL; } -- cgit v1.2.3 From 20b331c2f6fa4e16f0c473f27914644e2bcd2b39 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 13 Sep 2007 09:26:27 -0600 Subject: added null ptr check --- src/glut/glx/glut_fcb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/glut/glx/glut_fcb.c') diff --git a/src/glut/glx/glut_fcb.c b/src/glut/glx/glut_fcb.c index b272d0e2278..c8a3422b360 100644 --- a/src/glut/glx/glut_fcb.c +++ b/src/glut/glx/glut_fcb.c @@ -154,7 +154,7 @@ __glutGetFCB(int which) case GLUT_FCB_SELECT: return __glutCurrentMenu->fselect; case GLUT_FCB_TIMER: - return __glutTimerList->ffunc; + return __glutTimerList ? __glutTimerList->ffunc : NULL; default: return NULL; } -- cgit v1.2.3