some meshgen and map rendering updates
[voxelands-alt.git] / inc / wm.h
blob6e98eca751a62e4e4abf9cc6f5678799080ef80e
1 #ifndef _WM_H_
2 #define _WM_H_
4 #include "common.h"
6 #ifdef _WM_EXPOSE_ALL
8 #define GL_GLEXT_PROTOTYPES
9 #include <GL/gl.h>
10 #include <GL/glext.h>
12 #ifndef WIN32
13 #include <X11/Xlib.h>
14 #include <GL/glx.h>
15 #include <X11/extensions/xf86vmode.h>
16 #else
17 #include <windows.h>
18 #endif
20 #define SYM_TYPE_NONE 0x00
21 #define SYM_TYPE_MOUSE 0x01
22 #define SYM_TYPE_KEY 0x02
23 #define SYM_TYPE_SKEY 0x03
24 #define SYM_TYPE_MOD 0x04
26 #define EVENT_NONE 0x00
27 #define EVENT_BUTTON_DOWN 0x01
28 #define EVENT_BUTTON_UP 0x02
29 #define EVENT_KEY_DOWN 0x03
30 #define EVENT_KEY_UP 0x04
31 #define EVENT_MOUSE_MOTION 0x05
33 #define MOUSE_BUTTON_LEFT 0x00
34 #define MOUSE_BUTTON_RIGHT 0x01
35 #define MOUSE_BUTTON_CENTRE 0x02
36 #define MOUSE_BUTTON_UP 0x03
37 #define MOUSE_BUTTON_DOWN 0x04
38 #define MOUSE_MOTION 0x05
40 #define SYM_MOD_CTRL 0x01
41 #define SYM_MOD_ALT 0x02
42 #define SYM_MOD_SHIFT 0x04
43 #define SYM_MOD_SUPER 0x08
45 #define SYM_KEY_SPACE 0x01
46 #define SYM_KEY_ESCAPE 0x02
47 #define SYM_KEY_TAB 0x03
48 #define SYM_KEY_KP0 0x04
49 #define SYM_KEY_KP1 0x05
50 #define SYM_KEY_KP2 0x06
51 #define SYM_KEY_KP3 0x07
52 #define SYM_KEY_KP4 0x08
53 #define SYM_KEY_KP5 0x09
54 #define SYM_KEY_KP6 0x0A
55 #define SYM_KEY_KP7 0x0B
56 #define SYM_KEY_KP8 0x0C
57 #define SYM_KEY_KP9 0x0D
58 #define SYM_KEY_UP 0x0E
59 #define SYM_KEY_DOWN 0x0F
60 #define SYM_KEY_LEFT 0x10
61 #define SYM_KEY_RIGHT 0x11
62 #define SYM_KEY_F1 0x12
63 #define SYM_KEY_F2 0x13
64 #define SYM_KEY_F3 0x14
65 #define SYM_KEY_F4 0x15
66 #define SYM_KEY_F5 0x16
67 #define SYM_KEY_F6 0x17
68 #define SYM_KEY_F7 0x18
69 #define SYM_KEY_F8 0x19
70 #define SYM_KEY_F9 0x1A
71 #define SYM_KEY_F10 0x1B
72 #define SYM_KEY_F11 0x1C
73 #define SYM_KEY_F12 0x1D
74 #define SYM_KEY_BCKSPC 0x1E
75 #define SYM_KEY_DELETE 0x1F
76 #define SYM_KEY_ENTER 0x20
77 #define SYM_KEY_RETURN SYM_KEY_ENTER
78 #define SYM_KEY_KPEQ 0x21
79 #define SYM_KEY_KPMUL 0x22
80 #define SYM_KEY_KPADD 0x23
81 #define SYM_KEY_KPSUB 0x24
82 #define SYM_KEY_KPDOT 0x25
83 #define SYM_KEY_KPDIV 0x26
85 #ifndef _HAVE_CURSOR_TYPE
86 #define _HAVE_CURSOR_TYPE
87 struct material_s;
88 typedef struct cursor_s {
89 struct material_s *mat;
90 int w;
91 int h;
92 int x;
93 int y;
94 } cursor_t;
95 #endif
97 #ifndef _HAVE_WM_TYPE
98 #define _HAVE_WM_TYPE
99 typedef struct wm_s {
100 struct {
101 int height;
102 int width;
103 int max_height;
104 int max_width;
105 } size;
107 int fullscreen;
108 int frame_cap;
109 int lfps[4];
110 int lfps_i;
111 int fps;
112 char* title;
113 GLfloat distance;
114 int isinit;
115 cursor_t cursor;
117 #ifndef WIN32
118 Display *dpy;
119 int screen;
120 Window win;
121 GLXWindow glxwin;
122 GLXContext ctx;
123 GLXFBConfig fb_cfg;
124 XSetWindowAttributes attr;
125 int dblbuff;
126 XF86VidModeModeInfo deskMode;
127 XF86VidModeModeInfo **modes;
128 XVisualInfo *vi;
129 int mode;
130 int mode_count;
131 XIM im;
132 XIC ic;
133 XIMStyle style;
134 #else
135 HDC hDC;
136 HGLRC hRC;
137 HWND hWnd;
138 HINSTANCE hInstance;
139 #endif
140 } wm_t;
141 #endif
143 #ifndef _HAVE_CAMERA_TYPE
144 #define _HAVE_CAMERA_TYPE
145 typedef struct camera_s {
146 float x;
147 float y;
148 float z;
149 float yaw;
150 float pitch;
151 } camera_t;
152 #endif
154 #ifndef _HAVE_SYM_TYPE
155 #define _HAVE_SYM_TYPE
156 typedef struct sym_s {
157 uint8_t type;
158 uint32_t sym;
159 uint32_t ch;
160 } sym_t;
161 #endif
163 #ifndef _HAVE_BIND_TYPE
164 #define _HAVE_BIND_TYPE
165 typedef struct bind_s {
166 char str[256];
167 sym_t sym;
168 uint8_t mods;
169 } bind_t;
170 #endif
172 #ifndef _HAVE_EVENT_TYPE
173 #define _HAVE_EVENT_TYPE
174 typedef struct event_s {
175 uint8_t type;
176 sym_t sym;
177 int x;
178 int y;
179 int rx;
180 int ry;
181 } event_t;
182 #endif
184 #ifndef _HAVE_ACTION_TYPE
185 #define _HAVE_ACTION_TYPE
186 typedef struct action_s {
187 struct action_s *prev;
188 struct action_s *next;
189 char name[256];
190 uint32_t h;
191 bind_t bind;
192 void (*func)(event_t *e);
193 void (*r_func)(event_t *e);
194 void (*a_func)(event_t *e);
195 char* com;
196 } action_t;
197 #endif
199 /* defined in wm.c */
200 extern wm_t wm_data;
202 /* defined in wm.c */
203 void wm_capture(char* file);
205 /* defined in wm_x11.c and wm_w32.c */
206 int wm_init(void);
207 void wm_exit(void);
208 int wm_create(void);
209 int wm_resize(void);
210 int wm_update(void);
211 void wm_destroy(void);
212 void wm_toggle_fullscreen(int fs);
213 void wm_cursor(char* file, int width, int height, int offset_x, int offset_y);
214 void wm_grab(void);
215 void wm_ungrab(void);
216 void wm_title(char* title);
218 /* defined in camera.c */
219 void camera_view_matrix(matrix_t *mat, camera_t *cam);
220 camera_t *camera_get(void);
221 void camera_set_pos(v3_t *p);
222 void camera_set_yaw(GLfloat yaw);
223 void camera_set_pitch(GLfloat pitch);
225 /* defined in kmap.c */
226 int kmap_strtobind(bind_t *bind, char* str);
227 int kmap_bindtostr(char* str, int size, bind_t *bind);
228 int kmap_equal(bind_t *b1, bind_t *b2);
229 int kmap_triggers(bind_t *eb, bind_t *ab);
231 /* defined in events.c */
232 int events_init(void);
233 void events_exit(void);
234 void events_set_mousegrab(uint8_t g);
235 uint8_t events_get_mousegrab(void);
236 void events_get_mouse(int p[2]);
237 void events_set_mouse(int x, int y);
238 void event_remove(char* name);
239 void event_create(char* name, char* bind, char* com, void (*func)(event_t *e), void (*r_func)(event_t *e), void (*a_func)(event_t *e));
240 void events_trigger_active(void);
241 void events_handle(event_t *e);
243 /* defined in wm_x11.c and wm_w32.c */
244 void events_main(void);
246 #endif
248 /* defined in wm.c and dummy.c */
249 int wm_width_setter(char* value);
250 int wm_height_setter(char* value);
251 int wm_cap_setter(char* value);
252 int wm_fullscreen_setter(char* value);
254 /* defined in opengl.c and dummy.c */
255 int opengl_anisotropic_setter(char* value);
256 int opengl_bilinear_setter(char* value);
257 int opengl_trilinear_setter(char* value);
258 int opengl_mipmap_setter(char* value);
259 int opengl_particles_setter(char* value);
260 int opengl_particles_max_setter(char* value);
261 int opengl_bumpmap_setter(char* value);
262 int opengl_psdf_setter(char* value);
263 int opengl_shadowpass_setter(char* value);
264 int opengl_shadowsize_setter(char* value);
266 /* defined in events.c and dummy.c */
267 void events_save(file_t *f);
268 int event_bind(array_t *a);
270 /* defined in ui.c and dummy.c */
271 int ui_scale_setter(char* value);
272 int ui_autoscale_setter(char* value);
274 #endif