#include /* TODO: REMOVE THIS INCLUSION */ #include #include #include #define ENGINE_RENDERING_WINDOW_H_EXCLUDE_EXTERNS #include #undef ENGINE_RENDERING_WINDOW_H_EXCLUDE_EXTERNS #include #undef GLFW_INCLUDE_NONE #include #include extern Instance* GLOBAL_PLATFORM; static inline u64 platform_get_time_usec(void) { struct timespec t; int res = clock_gettime(CLOCK_MONOTONIC, &t); if (res != 0) { // TODO: Check errno WARN("Failed to get system time"); } return (u64)(t.tv_sec * 1000000 + t.tv_nsec / 1000); } /* wrapper to get time in ms */ u64 (*get_time)(void) = platform_get_time_usec; #define DAW_WINDOW_VSYNC (1 << 0) #define DAW_WINDOW_FULLSCREEN (1 << 1) #define DAW_WINDOW_RESIZEABLE (1 << 2) // Wrapper to get a specific window and set up related structures. // What the fuck is this doing here. Window* Window_new(const struct Platform* p, const char *restrict title, Window_framework framework, Window_renderer renderer, ivec2 size, u32 flags) { Window* w = NULL; switch (framework) { case WINDOW_FRAMEWORK_GLFW: switch (renderer) { case WINDOW_RENDERER_OPENGL: /* For now, pass instance as NULL, fix it once all the necessary bs is * out of struct Instance */ w = p->window_init(title, size, flags); w->bindings = NULL; w->bindings_sz = 0; w->bindings_len = 0; /// TODO //w->cam = &default_camera; return w; break; default: ERROR("Unsupported renderer."); } break; default: ERROR("Unsupported framework."); } return NULL; } void get_mousepos(double *x, double *y) { Window* w = GLOBAL_PLATFORM->window; switch(w->framework) { case WINDOW_FRAMEWORK_GLFW: glfwGetCursorPos(GLOBAL_PLATFORM->window->window, x, y); break; default: ERROR("get_mouse_pos not implemented for chosen framework."); } }