sgl

view include/sgl.h @ 39:e1a27aa24956

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