#ifndef VOXULA_WINDOW_H #define VOXULA_WINDOW_H #include #include #include #include typedef struct vx_input_controller vx_input_controller_s; typedef struct vx_window vx_window_s; typedef struct vx_window_event vx_window_event_s; typedef enum { VX_WINDOW_EVENT_INVALID = 0, VX_WINDOW_EVENT_KEY_PRESS, VX_WINDOW_EVENT_KEY_RELEASE, VX_WINDOW_EVENT_MOUSE_PRESS, VX_WINDOW_EVENT_MOUSE_RELEASE, VX_WINDOW_EVENT_MOUSE_MOVE, VX_WINDOW_EVENT_MOUSE_SCROLL, VX_WINDOW_EVENT_CLOSE = 254, VX_WINDOW_EVENT_QUIT = 255 } vx_window_event_e; typedef enum { VX_KEY_MODIFIER_NONE = 0, VX_KEY_MODIFIER_LEFT_CONTROL = 1, VX_KEY_MODIFIER_RIGHT_CONTROL = 1 << 1, VX_KEY_MODIFIER_CONTROL = 1 | (1 << 1), VX_KEY_MODIFIER_LEFT_SHIFT = 1 << 2, VX_KEY_MODIFIER_RIGHT_SHIFT = 1 << 3, VX_KEY_MODIFIER_SHIFT = (1 << 2) | (1 << 3) } vx_key_modifier_e; struct vx_window_event { vx_window_event_e type; vx_window_s *association; union vx_window_event_union { struct vx_key_press { uint16_t modifiers; uint32_t character; } key_press; struct vx_key_release { uint16_t modifiers; uint32_t character; } key_release; struct vx_mouse_press { vx_vec2f_s position_change; } mouse_press; struct vx_mouse_release { vx_vec2f_s position; } mouse_release; struct vx_mouse_move { vx_vec2f_s position; } mouse_move; struct vx_mouse_scroll { float amount; } mouse_scroll; } specifics; }; struct vx_window { vx_input_controller_s *controller; SDL_Window *window; SDL_GLContext gl_context; void (*fn_handle_input)(vx_window_s *window, vx_window_event_s event); void *userdata; }; struct vx_input_controller { uint32_t window_list_capacity; uint32_t num_windows; vx_window_s **windows; bool running; thrd_t thread; }; vx_input_controller_s * vx_new_input_controller(); void vx_free_input_controller(vx_input_controller_s *controller); void vx_start_input_controller(vx_input_controller_s *controller); void vx_stop_input_controller(vx_input_controller_s *controller); vx_window_s * vx_new_window(vx_input_controller_s *controller); void vx_free_window(vx_window_s *window); void vx_win_set_title(vx_window_s *window, const char *title); void vx_win_resize(vx_window_s *window, vx_vec2u_s size); void vx_win_move(vx_window_s *window, vx_vec2i_s position); void vx_win_show(vx_window_s *window); void vx_win_hide(vx_window_s *window); void vx_win_present(vx_window_s *window); #endif // VOXULA_WINDOW_H