1c041511dScube/*********************************************************** 2c041511dScube * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby. 3c041511dScube * 4c041511dScube * This program is freely distributable without licensing fees 5c041511dScube * and is provided without guarantee or warrantee expressed or 6c041511dScube * implied. This program is -not- in the public domain. 7c041511dScube * 8c041511dScube * 9c041511dScube * FILE: glutCallback.cpp 10c041511dScube * 11c041511dScube * DESCRIPTION: put all the callback setting routines in 12c041511dScube * one place 13c041511dScube ***********************************************************/ 14c041511dScube 15c041511dScube/*********************************************************** 16c041511dScube * Headers 17c041511dScube ***********************************************************/ 18c041511dScube#include <GL/glut.h> 19c041511dScube#include "glutint.h" 20c041511dScube#include "glutState.h" 21c041511dScube 22c041511dScube/*********************************************************** 23c041511dScube * Window related callbacks 24c041511dScube ***********************************************************/ 25c041511dScubevoid APIENTRY 26c041511dScubeglutDisplayFunc(GLUTdisplayCB displayFunc) 27c041511dScube{ 28c041511dScube /* XXX Remove the warning after GLUT 3.0. */ 29c041511dScube if (!displayFunc) 30c041511dScube __glutFatalError("NULL display callback not allowed in GLUT 3.0; update your code."); 31c041511dScube gState.currentWindow->display = displayFunc; 32c041511dScube} 33c041511dScube 34c041511dScubevoid APIENTRY 35c041511dScubeglutKeyboardFunc(GLUTkeyboardCB keyboardFunc) 36c041511dScube{ 37c041511dScube gState.currentWindow->keyboard = keyboardFunc; 38c041511dScube} 39c041511dScube 40c041511dScubevoid APIENTRY 41c041511dScubeglutSpecialFunc(GLUTspecialCB specialFunc) 42c041511dScube{ 43c041511dScube gState.currentWindow->special = specialFunc; 44c041511dScube} 45c041511dScube 46c041511dScubevoid APIENTRY 47c041511dScubeglutMouseFunc(GLUTmouseCB mouseFunc) 48c041511dScube{ 49c041511dScube gState.currentWindow->mouse = mouseFunc; 50c041511dScube} 51c041511dScube 52c041511dScubevoid APIENTRY 53c041511dScubeglutMotionFunc(GLUTmotionCB motionFunc) 54c041511dScube{ 55c041511dScube gState.currentWindow->motion = motionFunc; 56c041511dScube} 57c041511dScube 58c041511dScubevoid APIENTRY 59c041511dScubeglutPassiveMotionFunc(GLUTpassiveCB passiveMotionFunc) 60c041511dScube{ 61c041511dScube gState.currentWindow->passive = passiveMotionFunc; 62c041511dScube} 63c041511dScube 64c041511dScubevoid APIENTRY 65c041511dScubeglutEntryFunc(GLUTentryCB entryFunc) 66c041511dScube{ 67c041511dScube gState.currentWindow->entry = entryFunc; 68c041511dScube if (!entryFunc) { 69c041511dScube gState.currentWindow->entryState = -1; 70c041511dScube } 71c041511dScube} 72c041511dScube 73c041511dScubevoid APIENTRY 74c041511dScubeglutWindowStatusFunc(GLUTwindowStatusCB windowStatusFunc) 75c041511dScube{ 76c041511dScube gState.currentWindow->windowStatus = windowStatusFunc; 77c041511dScube} 78c041511dScube 79c041511dScubestatic void 80c041511dScubevisibilityHelper(int status) 81c041511dScube{ 82c041511dScube if (status == GLUT_HIDDEN || status == GLUT_FULLY_COVERED) 83c041511dScube gState.currentWindow->visibility(GLUT_NOT_VISIBLE); 84c041511dScube else 85c041511dScube gState.currentWindow->visibility(GLUT_VISIBLE); 86c041511dScube} 87c041511dScube 88c041511dScubevoid APIENTRY 89c041511dScubeglutVisibilityFunc(GLUTvisibilityCB visibilityFunc) 90c041511dScube{ 91c041511dScube gState.currentWindow->visibility = visibilityFunc; 92c041511dScube if (visibilityFunc) 93c041511dScube glutWindowStatusFunc(visibilityHelper); 94c041511dScube else 95c041511dScube glutWindowStatusFunc(NULL); 96c041511dScube} 97c041511dScube 98c041511dScubevoid APIENTRY 99c041511dScubeglutReshapeFunc(GLUTreshapeCB reshapeFunc) 100c041511dScube{ 101c041511dScube if (reshapeFunc) { 102c041511dScube gState.currentWindow->reshape = reshapeFunc; 103c041511dScube } else { 104c041511dScube gState.currentWindow->reshape = __glutDefaultReshape; 105c041511dScube } 106c041511dScube} 107c041511dScube 108c041511dScube/*********************************************************** 109c041511dScube * General callbacks (timer callback in glutEvent.cpp) 110c041511dScube ***********************************************************/ 111c041511dScube/* DEPRICATED, use glutMenuStatusFunc instead. */ 112c041511dScubevoid APIENTRY 113c041511dScubeglutMenuStateFunc(GLUTmenuStateCB menuStateFunc) 114c041511dScube{ 115c041511dScube gState.menuStatus = (GLUTmenuStatusCB) menuStateFunc; 116c041511dScube} 117c041511dScube 118c041511dScubevoid APIENTRY 119c041511dScubeglutMenuStatusFunc(GLUTmenuStatusCB menuStatusFunc) 120c041511dScube{ 121c041511dScube gState.menuStatus = menuStatusFunc; 122c041511dScube} 123c041511dScube 124c041511dScubevoid APIENTRY 125c041511dScubeglutIdleFunc(GLUTidleCB idleFunc) 126c041511dScube{ 127c041511dScube gState.idle = idleFunc; 128c041511dScube} 129c041511dScube 130c041511dScube/*********************************************************** 131c041511dScube * Unsupported callbacks 132c041511dScube ***********************************************************/ 133c041511dScubevoid APIENTRY 134c041511dScubeglutOverlayDisplayFunc(GLUTdisplayCB displayFunc) 135c041511dScube{ 136c041511dScube} 137c041511dScube 138c041511dScubevoid APIENTRY 139c041511dScubeglutSpaceballMotionFunc(GLUTspaceMotionCB spaceMotionFunc) 140c041511dScube{ 141c041511dScube} 142c041511dScube 143c041511dScubevoid APIENTRY 144c041511dScubeglutSpaceballRotateFunc(GLUTspaceRotateCB spaceRotateFunc) 145c041511dScube{ 146c041511dScube} 147c041511dScube 148c041511dScubevoid APIENTRY 149c041511dScubeglutSpaceballButtonFunc(GLUTspaceButtonCB spaceButtonFunc) 150c041511dScube{ 151c041511dScube} 152c041511dScube 153c041511dScubevoid APIENTRY 154c041511dScubeglutButtonBoxFunc(GLUTbuttonBoxCB buttonBoxFunc) 155c041511dScube{ 156c041511dScube} 157c041511dScube 158c041511dScubevoid APIENTRY 159c041511dScubeglutDialsFunc(GLUTdialsCB dialsFunc) 160c041511dScube{ 161c041511dScube} 162c041511dScube 163c041511dScubevoid APIENTRY 164c041511dScubeglutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc) 165c041511dScube{ 166c041511dScube} 167c041511dScube 168c041511dScubevoid APIENTRY 169c041511dScubeglutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc) 170c041511dScube{ 171c041511dScube} 172