aboutsummaryrefslogtreecommitdiff
path: root/tests/box2d/glui/glui_internal_control.h
blob: ef0db159deffefe87789ccd1aaf56b367fcda06d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 Header file for use by GLUI controls.  
 Everything you need is right here.


*/
#ifndef __GLUI_INTERNAL_CONTROL_H
#define __GLUI_INTERNAL_CONTROL_H

/* This is the main GLUI external header */
#include "glui.h"

/* Here's some utility routines */
#include "glui_internal.h"


/**
  A GLUI_Control-drawing sentinal object.
  On creation, saves the current draw buffer and window.
  On destruction, restores draw buffer and window.
  This is way nicer than calling save/restore manually.
*/
class GLUI_DrawingSentinal {
	int orig_buf, orig_win;
	GLUI_Control *c;
public:
	/** The constructor sets up the drawing system */
	GLUI_DrawingSentinal(GLUI_Control *c_);
	/** The destructor cleans up drawing back how it was */
	~GLUI_DrawingSentinal();
	
	// Do-nothing routine to avoid compiler warning about unused variable
	inline void avoid_warning(void) {}
};
/** Just drop a GLUI_DRAWINGSENTINAL_IDIOM at the start of your draw methods,
and they'll return if we can't be drawn, and 
automatically save and restore all needed state. 
*/
#define GLUI_DRAWINGSENTINAL_IDIOM  if (NOT can_draw()) return; GLUI_DrawingSentinal drawSentinal(this); drawSentinal.avoid_warning();


/** Return the time, in seconds. */
inline double GLUI_Time(void) {return 0.001*glutGet(GLUT_ELAPSED_TIME);}

#endif