xref: /haiku/src/libs/glut/glutCallback.cpp (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
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  ***********************************************************/
25 void APIENTRY
26 glutDisplayFunc(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 
34 void APIENTRY
35 glutKeyboardFunc(GLUTkeyboardCB keyboardFunc)
36 {
37   gState.currentWindow->keyboard = keyboardFunc;
38 }
39 
40 void APIENTRY
41 glutKeyboardUpFunc(GLUTkeyboardCB keyboardUpFunc)
42 {
43   gState.currentWindow->keyboardUp = keyboardUpFunc;
44 }
45 
46 void APIENTRY
47 glutSpecialFunc(GLUTspecialCB specialFunc)
48 {
49   gState.currentWindow->special = specialFunc;
50 }
51 
52 void APIENTRY
53 glutSpecialUpFunc(GLUTspecialCB specialUpFunc)
54 {
55   gState.currentWindow->specialUp = specialUpFunc;
56 }
57 
58 void APIENTRY
59 glutMouseFunc(GLUTmouseCB mouseFunc)
60 {
61   gState.currentWindow->mouse = mouseFunc;
62 }
63 
64 void APIENTRY
65 glutMotionFunc(GLUTmotionCB motionFunc)
66 {
67   gState.currentWindow->motion = motionFunc;
68 }
69 
70 void APIENTRY
71 glutPassiveMotionFunc(GLUTpassiveCB passiveMotionFunc)
72 {
73   gState.currentWindow->passive = passiveMotionFunc;
74 }
75 
76 void APIENTRY
77 glutEntryFunc(GLUTentryCB entryFunc)
78 {
79   gState.currentWindow->entry = entryFunc;
80   if (!entryFunc) {
81     gState.currentWindow->entryState = -1;
82   }
83 }
84 
85 void APIENTRY
86 glutWindowStatusFunc(GLUTwindowStatusCB windowStatusFunc)
87 {
88   gState.currentWindow->windowStatus = windowStatusFunc;
89 }
90 
91 static void
92 visibilityHelper(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 
100 void APIENTRY
101 glutVisibilityFunc(GLUTvisibilityCB visibilityFunc)
102 {
103   gState.currentWindow->visibility = visibilityFunc;
104   if (visibilityFunc)
105     glutWindowStatusFunc(visibilityHelper);
106   else
107     glutWindowStatusFunc(NULL);
108 }
109 
110 void APIENTRY
111 glutReshapeFunc(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. */
124 void APIENTRY
125 glutMenuStateFunc(GLUTmenuStateCB menuStateFunc)
126 {
127   gState.menuStatus = (GLUTmenuStatusCB) menuStateFunc;
128 }
129 
130 void APIENTRY
131 glutMenuStatusFunc(GLUTmenuStatusCB menuStatusFunc)
132 {
133   gState.menuStatus = menuStatusFunc;
134 }
135 
136 void APIENTRY
137 glutIdleFunc(GLUTidleCB idleFunc)
138 {
139   gState.idle = idleFunc;
140 }
141 
142 /***********************************************************
143  *	Unsupported callbacks
144  ***********************************************************/
145 void APIENTRY
146 glutOverlayDisplayFunc(GLUTdisplayCB displayFunc)
147 {
148 }
149 
150 void APIENTRY
151 glutJoystickFunc(GLUTjoystickCB joystickFunc, int pollInterval)
152 {
153 }
154 
155 void APIENTRY
156 glutSpaceballMotionFunc(GLUTspaceMotionCB spaceMotionFunc)
157 {
158 }
159 
160 void APIENTRY
161 glutSpaceballRotateFunc(GLUTspaceRotateCB spaceRotateFunc)
162 {
163 }
164 
165 void APIENTRY
166 glutSpaceballButtonFunc(GLUTspaceButtonCB spaceButtonFunc)
167 {
168 }
169 
170 void APIENTRY
171 glutButtonBoxFunc(GLUTbuttonBoxCB buttonBoxFunc)
172 {
173 }
174 
175 void APIENTRY
176 glutDialsFunc(GLUTdialsCB dialsFunc)
177 {
178 }
179 
180 void APIENTRY
181 glutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc)
182 {
183 }
184 
185 void APIENTRY
186 glutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc)
187 {
188 }
189