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
41glutSpecialFunc(GLUTspecialCB specialFunc)
42{
43  gState.currentWindow->special = specialFunc;
44}
45
46void APIENTRY
47glutMouseFunc(GLUTmouseCB mouseFunc)
48{
49  gState.currentWindow->mouse = mouseFunc;
50}
51
52void APIENTRY
53glutMotionFunc(GLUTmotionCB motionFunc)
54{
55  gState.currentWindow->motion = motionFunc;
56}
57
58void APIENTRY
59glutPassiveMotionFunc(GLUTpassiveCB passiveMotionFunc)
60{
61  gState.currentWindow->passive = passiveMotionFunc;
62}
63
64void APIENTRY
65glutEntryFunc(GLUTentryCB entryFunc)
66{
67  gState.currentWindow->entry = entryFunc;
68  if (!entryFunc) {
69    gState.currentWindow->entryState = -1;
70  }
71}
72
73void APIENTRY
74glutWindowStatusFunc(GLUTwindowStatusCB windowStatusFunc)
75{
76  gState.currentWindow->windowStatus = windowStatusFunc;
77}
78
79static void
80visibilityHelper(int status)
81{
82  if (status == GLUT_HIDDEN || status == GLUT_FULLY_COVERED)
83    gState.currentWindow->visibility(GLUT_NOT_VISIBLE);
84  else
85    gState.currentWindow->visibility(GLUT_VISIBLE);
86}
87
88void APIENTRY
89glutVisibilityFunc(GLUTvisibilityCB visibilityFunc)
90{
91  gState.currentWindow->visibility = visibilityFunc;
92  if (visibilityFunc)
93    glutWindowStatusFunc(visibilityHelper);
94  else
95    glutWindowStatusFunc(NULL);
96}
97
98void APIENTRY
99glutReshapeFunc(GLUTreshapeCB reshapeFunc)
100{
101  if (reshapeFunc) {
102    gState.currentWindow->reshape = reshapeFunc;
103  } else {
104    gState.currentWindow->reshape = __glutDefaultReshape;
105  }
106}
107
108/***********************************************************
109 *	General callbacks (timer callback in glutEvent.cpp)
110 ***********************************************************/
111/* DEPRICATED, use glutMenuStatusFunc instead. */
112void APIENTRY
113glutMenuStateFunc(GLUTmenuStateCB menuStateFunc)
114{
115  gState.menuStatus = (GLUTmenuStatusCB) menuStateFunc;
116}
117
118void APIENTRY
119glutMenuStatusFunc(GLUTmenuStatusCB menuStatusFunc)
120{
121  gState.menuStatus = menuStatusFunc;
122}
123
124void APIENTRY
125glutIdleFunc(GLUTidleCB idleFunc)
126{
127  gState.idle = idleFunc;
128}
129
130/***********************************************************
131 *	Unsupported callbacks
132 ***********************************************************/
133void APIENTRY
134glutOverlayDisplayFunc(GLUTdisplayCB displayFunc)
135{
136}
137
138void APIENTRY
139glutSpaceballMotionFunc(GLUTspaceMotionCB spaceMotionFunc)
140{
141}
142
143void APIENTRY
144glutSpaceballRotateFunc(GLUTspaceRotateCB spaceRotateFunc)
145{
146}
147
148void APIENTRY
149glutSpaceballButtonFunc(GLUTspaceButtonCB spaceButtonFunc)
150{
151}
152
153void APIENTRY
154glutButtonBoxFunc(GLUTbuttonBoxCB buttonBoxFunc)
155{
156}
157
158void APIENTRY
159glutDialsFunc(GLUTdialsCB dialsFunc)
160{
161}
162
163void APIENTRY
164glutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc)
165{
166}
167
168void APIENTRY
169glutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc)
170{
171}
172