1 /*
2  Header file for use by GLUI controls.
3  Everything you need is right here.
4 
5 
6 */
7 #ifndef __GLUI_INTERNAL_CONTROL_H
8 #define __GLUI_INTERNAL_CONTROL_H
9 
10 /* This is the main GLUI external header */
11 #include "GL/glui.h"
12 
13 /* Here's some utility routines */
14 #include "glui_internal.h"
15 
16 
17 /**
18   A GLUI_Control-drawing sentinal object.
19   On creation, saves the current draw buffer and window.
20   On destruction, restores draw buffer and window.
21   This is way nicer than calling save/restore manually.
22 */
23 class GLUI_DrawingSentinal {
24 	int orig_buf, orig_win;
25 	GLUI_Control *c;
26 public:
27 	/** The constructor sets up the drawing system */
28 	GLUI_DrawingSentinal(GLUI_Control *c_);
29 	/** The destructor cleans up drawing back how it was */
30 	~GLUI_DrawingSentinal();
31 
32 	// Do-nothing routine to avoid compiler warning about unused variable
avoid_warning(void)33 	inline void avoid_warning(void) {}
34 };
35 /** Just drop a GLUI_DRAWINGSENTINAL_IDIOM at the start of your draw methods,
36 and they'll return if we can't be drawn, and
37 automatically save and restore all needed state.
38 */
39 #define GLUI_DRAWINGSENTINAL_IDIOM  if (NOT can_draw()) return; GLUI_DrawingSentinal drawSentinal(this); drawSentinal.avoid_warning();
40 
41 
42 /** Return the time, in seconds. */
GLUI_Time(void)43 inline double GLUI_Time(void) {return 0.001*glutGet(GLUT_ELAPSED_TIME);}
44 
45 #endif
46