1/***********************************************************
2 *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
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 *
9 *  FILE:	glutCallback.cpp
10 *
11 *	DESCRIPTION:	put all the callback setting routines in
12 *		one place
13 ***********************************************************/
14
15/***********************************************************
16 *	Headers
17 ***********************************************************/
18#include <GL/glut.h>
19#include "glutint.h"
20#include "glutState.h"
21
22/***********************************************************
23 *	Window related callbacks
24 ***********************************************************/
25void APIENTRY
26glutDisplayFunc(GLUTdisplayCB displayFunc)
27{
28  /* XXX Remove the warning after GLUT 3.0. */
29  if (!displayFunc)
30    __glutFatalError("NULL display callback not allowed in GLUT 3.0; update your code.");
31  gState.currentWindow->display = displayFunc;
32}
33
34void APIENTRY
35glutKeyboardFunc(GLUTkeyboardCB keyboardFunc)
36{
37  gState.currentWindow->keyboard = keyboardFunc;
38}
39
40void APIENTRY
41glutKeyboardUpFunc(GLUTkeyboardCB keyboardUpFunc)
42{
43  gState.currentWindow->keyboardUp = keyboardUpFunc;
44}
45
46void APIENTRY
47glutSpecialFunc(GLUTspecialCB specialFunc)
48{
49  gState.currentWindow->special = specialFunc;
50}
51
52void APIENTRY
53glutSpecialUpFunc(GLUTspecialCB specialUpFunc)
54{
55  gState.currentWindow->specialUp = specialUpFunc;
56}
57
58void APIENTRY
59glutMouseFunc(GLUTmouseCB mouseFunc)
60{
61  gState.currentWindow->mouse = mouseFunc;
62}
63
64void APIENTRY
65glutMotionFunc(GLUTmotionCB motionFunc)
66{
67  gState.currentWindow->motion = motionFunc;
68}
69
70void APIENTRY
71glutPassiveMotionFunc(GLUTpassiveCB passiveMotionFunc)
72{
73  gState.currentWindow->passive = passiveMotionFunc;
74}
75
76void APIENTRY
77glutEntryFunc(GLUTentryCB entryFunc)
78{
79  gState.currentWindow->entry = entryFunc;
80  if (!entryFunc) {
81    gState.currentWindow->entryState = -1;
82  }
83}
84
85void APIENTRY
86glutWindowStatusFunc(GLUTwindowStatusCB windowStatusFunc)
87{
88  gState.currentWindow->windowStatus = windowStatusFunc;
89}
90
91static void
92visibilityHelper(int status)
93{
94  if (status == GLUT_HIDDEN || status == GLUT_FULLY_COVERED)
95    gState.currentWindow->visibility(GLUT_NOT_VISIBLE);
96  else
97    gState.currentWindow->visibility(GLUT_VISIBLE);
98}
99
100void APIENTRY
101glutVisibilityFunc(GLUTvisibilityCB visibilityFunc)
102{
103  gState.currentWindow->visibility = visibilityFunc;
104  if (visibilityFunc)
105    glutWindowStatusFunc(visibilityHelper);
106  else
107    glutWindowStatusFunc(NULL);
108}
109
110void APIENTRY
111glutReshapeFunc(GLUTreshapeCB reshapeFunc)
112{
113  if (reshapeFunc) {
114    gState.currentWindow->reshape = reshapeFunc;
115  } else {
116    gState.currentWindow->reshape = __glutDefaultReshape;
117  }
118}
119
120/***********************************************************
121 *	General callbacks (timer callback in glutEvent.cpp)
122 ***********************************************************/
123/* DEPRICATED, use glutMenuStatusFunc instead. */
124void APIENTRY
125glutMenuStateFunc(GLUTmenuStateCB menuStateFunc)
126{
127  gState.menuStatus = (GLUTmenuStatusCB) menuStateFunc;
128}
129
130void APIENTRY
131glutMenuStatusFunc(GLUTmenuStatusCB menuStatusFunc)
132{
133  gState.menuStatus = menuStatusFunc;
134}
135
136void APIENTRY
137glutIdleFunc(GLUTidleCB idleFunc)
138{
139  gState.idle = idleFunc;
140}
141
142/***********************************************************
143 *	Unsupported callbacks
144 ***********************************************************/
145void APIENTRY
146glutOverlayDisplayFunc(GLUTdisplayCB displayFunc)
147{
148}
149
150void APIENTRY
151glutJoystickFunc(GLUTjoystickCB joystickFunc, int pollInterval)
152{
153}
154
155void APIENTRY
156glutSpaceballMotionFunc(GLUTspaceMotionCB spaceMotionFunc)
157{
158}
159
160void APIENTRY
161glutSpaceballRotateFunc(GLUTspaceRotateCB spaceRotateFunc)
162{
163}
164
165void APIENTRY
166glutSpaceballButtonFunc(GLUTspaceButtonCB spaceButtonFunc)
167{
168}
169
170void APIENTRY
171glutButtonBoxFunc(GLUTbuttonBoxCB buttonBoxFunc)
172{
173}
174
175void APIENTRY
176glutDialsFunc(GLUTdialsCB dialsFunc)
177{
178}
179
180void APIENTRY
181glutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc)
182{
183}
184
185void APIENTRY
186glutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc)
187{
188}
189