rev |
line source |
nuclear@0
|
1 #ifndef SGL_H_
|
nuclear@0
|
2 #define SGL_H_
|
nuclear@0
|
3
|
nuclear@0
|
4 #define SGL_DOUBLE 1
|
nuclear@0
|
5 #define SGL_DEPTH 2
|
nuclear@0
|
6 #define SGL_STENCIL 4
|
nuclear@0
|
7 #define SGL_STEREO 8
|
nuclear@4
|
8 #define SGL_MULTISAMPLE 16
|
nuclear@0
|
9
|
nuclear@34
|
10 /* --- callback types ---
|
nuclear@34
|
11 * All event callbacks are entered with the corresponding OpenGL context being current.
|
nuclear@34
|
12 * It is safe to issue OpenGL commands in all callbacks functions, unless explicitly
|
nuclear@34
|
13 * stated otherwise below.
|
nuclear@34
|
14 */
|
nuclear@34
|
15
|
nuclear@34
|
16 /* Create callback is called just after a window and its OpenGL context is created */
|
nuclear@34
|
17 typedef void (*sgl_create_callback_t)(int window);
|
nuclear@39
|
18
|
nuclear@34
|
19 /* Close callback is called before the window and its OpenGL context is destroyed */
|
nuclear@34
|
20 typedef void (*sgl_close_callback_t)(int window);
|
nuclear@39
|
21
|
nuclear@34
|
22 /* The display callback is called whenever the window needs repainting. This is
|
nuclear@34
|
23 * the only place you should perform drawing.
|
nuclear@34
|
24 */
|
nuclear@6
|
25 typedef void (*sgl_display_callback_t)(void);
|
nuclear@39
|
26
|
nuclear@34
|
27 /* Reshape is called whenever the window size changes, and at least once for
|
nuclear@34
|
28 * each newly created window, just after the call to the create callback. */
|
nuclear@34
|
29 typedef void (*sgl_reshape_callback_t)(int width, int height);
|
nuclear@39
|
30
|
nuclear@34
|
31 /* The keyboard callback is called whenever a key is pressed or released */
|
nuclear@34
|
32 typedef void (*sgl_keyboard_callback_t)(int key, int pressed);
|
nuclear@39
|
33
|
nuclear@34
|
34 /* The mouse callback is called whenever a mouse button is pressed or released
|
nuclear@34
|
35 * over the window. The first argument is the touch id for multitouch devices.
|
nuclear@34
|
36 * For regular mouse events it is always 0. */
|
nuclear@34
|
37 typedef void (*sgl_mouse_callback_t)(int id, int button, int pressed, int x, int y);
|
nuclear@39
|
38
|
nuclear@34
|
39 /* The motion callback is called when the user drags the mouse around with any
|
nuclear@34
|
40 * mouse buttons held down. The first argument is the touch id for multitouch
|
nuclear@34
|
41 * devices. */
|
nuclear@34
|
42 typedef void (*sgl_motion_callback_t)(int id, int x, int y);
|
nuclear@39
|
43
|
nuclear@34
|
44 /* Passive gets called whenever the mouse is moved without any button being
|
nuclear@34
|
45 * held. The first argument is the touch id for multitouch devices.
|
nuclear@34
|
46 *
|
nuclear@34
|
47 * Avoid setting this callback unless absolutely necessary, because it will
|
nuclear@34
|
48 * generate a huge volume of events whenever the mouse moves over the window. */
|
nuclear@34
|
49 typedef void (*sgl_passive_callback_t)(int id, int x, int y);
|
nuclear@39
|
50
|
nuclear@39
|
51 /* The space control callback gets called when we receive input from spatial
|
nuclear@39
|
52 * controllers such as spaceballs, accelerometers, and gyroscopes
|
nuclear@39
|
53 */
|
nuclear@39
|
54 typedef void (*sgl_space_callback_t)(int x, int y, int z, int rx, int ry, int rz);
|
nuclear@39
|
55
|
nuclear@39
|
56 /* The button callback gets called whenever we have button presses/releases
|
nuclear@39
|
57 * from special hardware buttons such as the home button on mobile devices,
|
nuclear@39
|
58 * buttons on spaceballs, etc.
|
nuclear@39
|
59 */
|
nuclear@39
|
60 typedef void (*sgl_button_callback_t)(int bn, int pressed);
|
nuclear@39
|
61
|
nuclear@34
|
62 /* Setting the idle callback will change the behaviour of the library. Instead
|
nuclear@34
|
63 * of blocking, to wait for events from the window system, it will poll for
|
nuclear@34
|
64 * events and after processing them will call this idle callback.
|
nuclear@34
|
65 *
|
nuclear@34
|
66 * Avoid setting this callback unless absolutely necessary, because it will
|
nuclear@34
|
67 * turn your program into busy-looping mode, consuming all possible CPU time
|
nuclear@34
|
68 * allocated to it by the system. */
|
nuclear@6
|
69 typedef void (*sgl_idle_callback_t)(void);
|
nuclear@6
|
70
|
nuclear@34
|
71 /* symbolic names for each callback */
|
nuclear@0
|
72 enum {
|
nuclear@0
|
73 SGL_CREATE,
|
nuclear@0
|
74 SGL_CLOSE,
|
nuclear@0
|
75 SGL_DISPLAY,
|
nuclear@0
|
76 SGL_RESHAPE,
|
nuclear@0
|
77 SGL_KEYBOARD,
|
nuclear@0
|
78 SGL_MOUSE,
|
nuclear@0
|
79 SGL_MOTION,
|
nuclear@0
|
80 SGL_PASSIVE,
|
nuclear@39
|
81 SGL_SPACE,
|
nuclear@39
|
82 SGL_BUTTON,
|
nuclear@0
|
83 SGL_IDLE,
|
nuclear@0
|
84
|
nuclear@0
|
85 SGL_NUM_CALLBACKS
|
nuclear@0
|
86 };
|
nuclear@0
|
87
|
nuclear@5
|
88 enum {
|
nuclear@5
|
89 SGL_LEFT_BUTTON,
|
nuclear@5
|
90 SGL_MIDDLE_BUTTON,
|
nuclear@5
|
91 SGL_RIGHT_BUTTON
|
nuclear@5
|
92 };
|
nuclear@5
|
93
|
nuclear@7
|
94 /* these values happen to coincide with X11 keysyms */
|
nuclear@7
|
95 #define SGL_KEY_LSHIFT 0xffe1
|
nuclear@7
|
96 #define SGL_KEY_RSHIFT 0xffe2
|
nuclear@7
|
97 #define SGL_KEY_LCONTROL 0xffe3
|
nuclear@7
|
98 #define SGL_KEY_RCONTROL 0xffe4
|
nuclear@7
|
99 #define SGL_KEY_LALT 0xffe9
|
nuclear@7
|
100 #define SGL_KEY_RALT 0xffea
|
nuclear@7
|
101
|
nuclear@7
|
102 /* for the sgl_modifiers bitmask */
|
nuclear@7
|
103 #define SGL_MOD_SHIFT 1
|
nuclear@7
|
104 #define SGL_MOD_CONTROL 2
|
nuclear@7
|
105 #define SGL_MOD_ALT 4
|
nuclear@7
|
106
|
nuclear@1
|
107 int sgl_init(void);
|
nuclear@5
|
108 void sgl_quit(void);
|
nuclear@1
|
109
|
nuclear@4
|
110 int sgl_set_video_mode(int xsz, int ysz);
|
nuclear@4
|
111 int sgl_get_video_mode(int *xsz, int *ysz);
|
nuclear@0
|
112
|
nuclear@4
|
113 int sgl_create_window(int xsz, int ysz, unsigned int mode);
|
nuclear@1
|
114 void sgl_close_window(int win);
|
nuclear@0
|
115
|
nuclear@4
|
116 int sgl_set_active(int id);
|
nuclear@4
|
117 int sgl_set_title(const char *str);
|
nuclear@4
|
118
|
nuclear@5
|
119 void sgl_redisplay(void);
|
nuclear@5
|
120 void sgl_swap_buffers(void);
|
nuclear@5
|
121
|
nuclear@7
|
122 int sgl_modifiers(void);
|
nuclear@7
|
123
|
nuclear@4
|
124 int sgl_process_events(void);
|
nuclear@5
|
125 void sgl_event_loop(void);
|
nuclear@4
|
126
|
nuclear@0
|
127 int sgl_push_callbacks(void);
|
nuclear@0
|
128 int sgl_pop_callbacks(void);
|
nuclear@0
|
129 void sgl_clear_callbacks(void);
|
nuclear@4
|
130 void sgl_set_callback(int idx, void (*func)());
|
nuclear@4
|
131 void (*sgl_get_callback(int idx))();
|
nuclear@0
|
132
|
nuclear@6
|
133 void sgl_create_callback(sgl_create_callback_t func);
|
nuclear@6
|
134 void sgl_close_callback(sgl_close_callback_t func);
|
nuclear@6
|
135 void sgl_display_callback(sgl_display_callback_t func);
|
nuclear@6
|
136 void sgl_reshape_callback(sgl_reshape_callback_t func);
|
nuclear@6
|
137 void sgl_keyboard_callback(sgl_keyboard_callback_t func);
|
nuclear@6
|
138 void sgl_mouse_callback(sgl_mouse_callback_t func);
|
nuclear@6
|
139 void sgl_motion_callback(sgl_motion_callback_t func);
|
nuclear@6
|
140 void sgl_passive_callback(sgl_passive_callback_t func);
|
nuclear@39
|
141 void sgl_space_callback(sgl_space_callback_t func);
|
nuclear@39
|
142 void sgl_button_callback(sgl_button_callback_t func);
|
nuclear@6
|
143 void sgl_idle_callback(sgl_idle_callback_t func);
|
nuclear@6
|
144
|
nuclear@0
|
145 #endif /* SGL_H_ */
|