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@34
|
18 /* Close callback is called before the window and its OpenGL context is destroyed */
|
nuclear@34
|
19 typedef void (*sgl_close_callback_t)(int window);
|
nuclear@34
|
20 /* The display callback is called whenever the window needs repainting. This is
|
nuclear@34
|
21 * the only place you should perform drawing.
|
nuclear@34
|
22 */
|
nuclear@6
|
23 typedef void (*sgl_display_callback_t)(void);
|
nuclear@34
|
24 /* Reshape is called whenever the window size changes, and at least once for
|
nuclear@34
|
25 * each newly created window, just after the call to the create callback. */
|
nuclear@34
|
26 typedef void (*sgl_reshape_callback_t)(int width, int height);
|
nuclear@34
|
27 /* The keyboard callback is called whenever a key is pressed or released */
|
nuclear@34
|
28 typedef void (*sgl_keyboard_callback_t)(int key, int pressed);
|
nuclear@34
|
29 /* The mouse callback is called whenever a mouse button is pressed or released
|
nuclear@34
|
30 * over the window. The first argument is the touch id for multitouch devices.
|
nuclear@34
|
31 * For regular mouse events it is always 0. */
|
nuclear@34
|
32 typedef void (*sgl_mouse_callback_t)(int id, int button, int pressed, int x, int y);
|
nuclear@34
|
33 /* The motion callback is called when the user drags the mouse around with any
|
nuclear@34
|
34 * mouse buttons held down. The first argument is the touch id for multitouch
|
nuclear@34
|
35 * devices. */
|
nuclear@34
|
36 typedef void (*sgl_motion_callback_t)(int id, int x, int y);
|
nuclear@34
|
37 /* Passive gets called whenever the mouse is moved without any button being
|
nuclear@34
|
38 * held. The first argument is the touch id for multitouch devices.
|
nuclear@34
|
39 *
|
nuclear@34
|
40 * Avoid setting this callback unless absolutely necessary, because it will
|
nuclear@34
|
41 * generate a huge volume of events whenever the mouse moves over the window. */
|
nuclear@34
|
42 typedef void (*sgl_passive_callback_t)(int id, int x, int y);
|
nuclear@34
|
43 /* Setting the idle callback will change the behaviour of the library. Instead
|
nuclear@34
|
44 * of blocking, to wait for events from the window system, it will poll for
|
nuclear@34
|
45 * events and after processing them will call this idle callback.
|
nuclear@34
|
46 *
|
nuclear@34
|
47 * Avoid setting this callback unless absolutely necessary, because it will
|
nuclear@34
|
48 * turn your program into busy-looping mode, consuming all possible CPU time
|
nuclear@34
|
49 * allocated to it by the system. */
|
nuclear@6
|
50 typedef void (*sgl_idle_callback_t)(void);
|
nuclear@6
|
51
|
nuclear@34
|
52 /* symbolic names for each callback */
|
nuclear@0
|
53 enum {
|
nuclear@0
|
54 SGL_CREATE,
|
nuclear@0
|
55 SGL_CLOSE,
|
nuclear@0
|
56 SGL_DISPLAY,
|
nuclear@0
|
57 SGL_RESHAPE,
|
nuclear@0
|
58 SGL_KEYBOARD,
|
nuclear@0
|
59 SGL_MOUSE,
|
nuclear@0
|
60 SGL_MOTION,
|
nuclear@0
|
61 SGL_PASSIVE,
|
nuclear@0
|
62 SGL_IDLE,
|
nuclear@0
|
63
|
nuclear@0
|
64 SGL_NUM_CALLBACKS
|
nuclear@0
|
65 };
|
nuclear@0
|
66
|
nuclear@5
|
67 enum {
|
nuclear@5
|
68 SGL_LEFT_BUTTON,
|
nuclear@5
|
69 SGL_MIDDLE_BUTTON,
|
nuclear@5
|
70 SGL_RIGHT_BUTTON
|
nuclear@5
|
71 };
|
nuclear@5
|
72
|
nuclear@7
|
73 /* these values happen to coincide with X11 keysyms */
|
nuclear@7
|
74 #define SGL_KEY_LSHIFT 0xffe1
|
nuclear@7
|
75 #define SGL_KEY_RSHIFT 0xffe2
|
nuclear@7
|
76 #define SGL_KEY_LCONTROL 0xffe3
|
nuclear@7
|
77 #define SGL_KEY_RCONTROL 0xffe4
|
nuclear@7
|
78 #define SGL_KEY_LALT 0xffe9
|
nuclear@7
|
79 #define SGL_KEY_RALT 0xffea
|
nuclear@7
|
80
|
nuclear@7
|
81 /* for the sgl_modifiers bitmask */
|
nuclear@7
|
82 #define SGL_MOD_SHIFT 1
|
nuclear@7
|
83 #define SGL_MOD_CONTROL 2
|
nuclear@7
|
84 #define SGL_MOD_ALT 4
|
nuclear@7
|
85
|
nuclear@1
|
86 int sgl_init(void);
|
nuclear@5
|
87 void sgl_quit(void);
|
nuclear@1
|
88
|
nuclear@4
|
89 int sgl_set_video_mode(int xsz, int ysz);
|
nuclear@4
|
90 int sgl_get_video_mode(int *xsz, int *ysz);
|
nuclear@0
|
91
|
nuclear@4
|
92 int sgl_create_window(int xsz, int ysz, unsigned int mode);
|
nuclear@1
|
93 void sgl_close_window(int win);
|
nuclear@0
|
94
|
nuclear@4
|
95 int sgl_set_active(int id);
|
nuclear@4
|
96 int sgl_set_title(const char *str);
|
nuclear@4
|
97
|
nuclear@5
|
98 void sgl_redisplay(void);
|
nuclear@5
|
99 void sgl_swap_buffers(void);
|
nuclear@5
|
100
|
nuclear@7
|
101 int sgl_modifiers(void);
|
nuclear@7
|
102
|
nuclear@4
|
103 int sgl_process_events(void);
|
nuclear@5
|
104 void sgl_event_loop(void);
|
nuclear@4
|
105
|
nuclear@0
|
106 int sgl_push_callbacks(void);
|
nuclear@0
|
107 int sgl_pop_callbacks(void);
|
nuclear@0
|
108 void sgl_clear_callbacks(void);
|
nuclear@4
|
109 void sgl_set_callback(int idx, void (*func)());
|
nuclear@4
|
110 void (*sgl_get_callback(int idx))();
|
nuclear@0
|
111
|
nuclear@6
|
112 void sgl_create_callback(sgl_create_callback_t func);
|
nuclear@6
|
113 void sgl_close_callback(sgl_close_callback_t func);
|
nuclear@6
|
114 void sgl_display_callback(sgl_display_callback_t func);
|
nuclear@6
|
115 void sgl_reshape_callback(sgl_reshape_callback_t func);
|
nuclear@6
|
116 void sgl_keyboard_callback(sgl_keyboard_callback_t func);
|
nuclear@6
|
117 void sgl_mouse_callback(sgl_mouse_callback_t func);
|
nuclear@6
|
118 void sgl_motion_callback(sgl_motion_callback_t func);
|
nuclear@6
|
119 void sgl_passive_callback(sgl_passive_callback_t func);
|
nuclear@6
|
120 void sgl_idle_callback(sgl_idle_callback_t func);
|
nuclear@6
|
121
|
nuclear@0
|
122 #endif /* SGL_H_ */
|