1 2/* Copyright (c) Mark J. Kilgard, 1998. */ 3 4/* This program is freely distributable without licensing fees 5 and is provided without guarantee or warrantee expressed or 6 implied. This program is -not- in the public domain. */ 7 8/* I appreciate the guidance from William Mitchell 9 (mitchell@cam.nist.gov) in developing this friend interface 10 for use by the f90gl package. See ../../README.fortran */ 11 12#include "glutint.h" 13 14/* FCB stands for Fortran CallBack. */ 15 16/* There is only one idleFunc, menuStateFunc, and menuStatusFunc, so they 17 can be saved in the wrappers for Fortran rather than the C structures. */ 18 19/* Set a Fortran callback function. */ 20 21void APIENTRY 22__glutSetFCB(int which, GLUTproc func) 23{ 24#ifdef SUPPORT_FORTRAN 25 switch (which) { 26 case GLUT_FCB_DISPLAY: 27 __glutCurrentWindow->fdisplay = (GLUTdisplayFCB) func; 28 break; 29 case GLUT_FCB_RESHAPE: 30 __glutCurrentWindow->freshape = (GLUTreshapeFCB) func; 31 break; 32 case GLUT_FCB_MOUSE: 33 __glutCurrentWindow->fmouse = (GLUTmouseFCB) func; 34 break; 35 case GLUT_FCB_MOTION: 36 __glutCurrentWindow->fmotion = (GLUTmotionFCB) func; 37 break; 38 case GLUT_FCB_PASSIVE: 39 __glutCurrentWindow->fpassive = (GLUTpassiveFCB) func; 40 break; 41 case GLUT_FCB_ENTRY: 42 __glutCurrentWindow->fentry = (GLUTentryFCB) func; 43 break; 44 case GLUT_FCB_KEYBOARD: 45 __glutCurrentWindow->fkeyboard = (GLUTkeyboardFCB) func; 46 break; 47 case GLUT_FCB_KEYBOARD_UP: 48 __glutCurrentWindow->fkeyboardUp = (GLUTkeyboardFCB) func; 49 break; 50 case GLUT_FCB_WINDOW_STATUS: 51 __glutCurrentWindow->fwindowStatus = (GLUTwindowStatusFCB) func; 52 break; 53 case GLUT_FCB_VISIBILITY: 54 __glutCurrentWindow->fvisibility = (GLUTvisibilityFCB) func; 55 break; 56 case GLUT_FCB_SPECIAL: 57 __glutCurrentWindow->fspecial = (GLUTspecialFCB) func; 58 break; 59 case GLUT_FCB_SPECIAL_UP: 60 __glutCurrentWindow->fspecialUp = (GLUTspecialFCB) func; 61 break; 62 case GLUT_FCB_BUTTON_BOX: 63 __glutCurrentWindow->fbuttonBox = (GLUTbuttonBoxFCB) func; 64 break; 65 case GLUT_FCB_DIALS: 66 __glutCurrentWindow->fdials = (GLUTdialsFCB) func; 67 break; 68 case GLUT_FCB_SPACE_MOTION: 69 __glutCurrentWindow->fspaceMotion = (GLUTspaceMotionFCB) func; 70 break; 71 case GLUT_FCB_SPACE_ROTATE: 72 __glutCurrentWindow->fspaceRotate = (GLUTspaceRotateFCB) func; 73 break; 74 case GLUT_FCB_SPACE_BUTTON: 75 __glutCurrentWindow->fspaceButton = (GLUTspaceButtonFCB) func; 76 break; 77 case GLUT_FCB_TABLET_MOTION: 78 __glutCurrentWindow->ftabletMotion = (GLUTtabletMotionFCB) func; 79 break; 80 case GLUT_FCB_TABLET_BUTTON: 81 __glutCurrentWindow->ftabletButton = (GLUTtabletButtonFCB) func; 82 break; 83#ifdef _WIN32 84 case GLUT_FCB_JOYSTICK: 85 __glutCurrentWindow->fjoystick = (GLUTjoystickFCB) func; 86 break; 87#endif 88 case GLUT_FCB_OVERLAY_DISPLAY: 89 __glutCurrentWindow->overlay->fdisplay = (GLUTdisplayFCB) func; 90 break; 91 case GLUT_FCB_SELECT: 92 __glutCurrentMenu->fselect = (GLUTselectFCB) func; 93 break; 94 case GLUT_FCB_TIMER: 95 __glutNewTimer->ffunc = (GLUTtimerFCB) func; 96 break; 97 } 98#endif 99} 100 101/* Get a Fortran callback function. */ 102 103GLUTproc APIENTRY 104__glutGetFCB(int which) 105{ 106#ifdef SUPPORT_FORTRAN 107 switch (which) { 108 case GLUT_FCB_DISPLAY: 109 return __glutCurrentWindow->fdisplay; 110 case GLUT_FCB_RESHAPE: 111 return __glutCurrentWindow->freshape; 112 case GLUT_FCB_MOUSE: 113 return __glutCurrentWindow->fmouse; 114 case GLUT_FCB_MOTION: 115 return __glutCurrentWindow->fmotion; 116 case GLUT_FCB_PASSIVE: 117 return __glutCurrentWindow->fpassive; 118 case GLUT_FCB_ENTRY: 119 return __glutCurrentWindow->fentry; 120 case GLUT_FCB_KEYBOARD: 121 return __glutCurrentWindow->fkeyboard; 122 case GLUT_FCB_KEYBOARD_UP: 123 return __glutCurrentWindow->fkeyboardUp; 124 case GLUT_FCB_WINDOW_STATUS: 125 return __glutCurrentWindow->fwindowStatus; 126 case GLUT_FCB_VISIBILITY: 127 return __glutCurrentWindow->fvisibility; 128 case GLUT_FCB_SPECIAL: 129 return __glutCurrentWindow->fspecial; 130 case GLUT_FCB_SPECIAL_UP: 131 return __glutCurrentWindow->fspecialUp; 132 case GLUT_FCB_BUTTON_BOX: 133 return __glutCurrentWindow->fbuttonBox; 134 case GLUT_FCB_DIALS: 135 return __glutCurrentWindow->fdials; 136 case GLUT_FCB_SPACE_MOTION: 137 return __glutCurrentWindow->fspaceMotion; 138 case GLUT_FCB_SPACE_ROTATE: 139 return __glutCurrentWindow->fspaceRotate; 140 case GLUT_FCB_SPACE_BUTTON: 141 return __glutCurrentWindow->fspaceButton; 142 case GLUT_FCB_TABLET_MOTION: 143 return __glutCurrentWindow->ftabletMotion; 144 case GLUT_FCB_TABLET_BUTTON: 145 return __glutCurrentWindow->ftabletButton; 146 case GLUT_FCB_JOYSTICK: 147#ifdef _WIN32 148 return __glutCurrentWindow->fjoystick; 149#else 150 return NULL; 151#endif 152 case GLUT_FCB_OVERLAY_DISPLAY: 153 return __glutCurrentWindow->overlay->fdisplay; 154 case GLUT_FCB_SELECT: 155 return __glutCurrentMenu->fselect; 156 case GLUT_FCB_TIMER: 157 return __glutTimerList ? __glutTimerList->ffunc : NULL; 158 default: 159 return NULL; 160 } 161#else 162 return NULL; 163#endif 164} 165