diff options
Diffstat (limited to 'src/platform.h')
| -rw-r--r-- | src/platform.h | 98 | 
1 files changed, 47 insertions, 51 deletions
diff --git a/src/platform.h b/src/platform.h index fe719d3..aff673f 100644 --- a/src/platform.h +++ b/src/platform.h @@ -3,66 +3,61 @@  #include "log.h"  #include <stdint.h> -#include <stdlib.h> +#include <stdlib.h> // IWYU pragma: keep -#define VGLTF_PANIC(...)                                                       \ +#define VGLTF_PANIC(...)                                                         \    do {                                                                         \ -    VGLTF_LOG_ERR("panic: " __VA_ARGS__);                                      \ +    VGLTF_LOG_ERR("PANIC " __VA_ARGS__);                                         \      exit(1);                                                                   \    } while (0) -enum vgltf_event_type { -  VGLTF_EVENT_QUIT, -  VGLTF_EVENT_KEY_DOWN, -  VGLTF_EVENT_WINDOW_RESIZED, -  VGLTF_EVENT_UNKNOWN, -}; +#define VGLTF_FOREACH_KEY(_M)                                                    \ +  _M(A)                                                                        \ +  _M(B)                                                                        \ +  _M(C)                                                                        \ +  _M(D)                                                                        \ +  _M(E)                                                                        \ +  _M(F)                                                                        \ +  _M(G)                                                                        \ +  _M(H)                                                                        \ +  _M(I)                                                                        \ +  _M(J)                                                                        \ +  _M(K)                                                                        \ +  _M(L)                                                                        \ +  _M(M)                                                                        \ +  _M(N)                                                                        \ +  _M(O)                                                                        \ +  _M(P)                                                                        \ +  _M(Q)                                                                        \ +  _M(R)                                                                        \ +  _M(S)                                                                        \ +  _M(T)                                                                        \ +  _M(U)                                                                        \ +  _M(V)                                                                        \ +  _M(W)                                                                        \ +  _M(X)                                                                        \ +  _M(Y)                                                                        \ +  _M(Z)                                                                        \ +  _M(ESCAPE) +#define VGLTF_GENERATE_KEY_ENUM(KEY) VGLTF_KEY_##KEY,  enum vgltf_key { -  VGLTF_KEY_A, -  VGLTF_KEY_B, -  VGLTF_KEY_C, -  VGLTF_KEY_D, -  VGLTF_KEY_E, -  VGLTF_KEY_F, -  VGLTF_KEY_G, -  VGLTF_KEY_H, -  VGLTF_KEY_I, -  VGLTF_KEY_J, -  VGLTF_KEY_K, -  VGLTF_KEY_L, -  VGLTF_KEY_M, -  VGLTF_KEY_N, -  VGLTF_KEY_O, -  VGLTF_KEY_P, -  VGLTF_KEY_Q, -  VGLTF_KEY_R, -  VGLTF_KEY_S, -  VGLTF_KEY_T, -  VGLTF_KEY_U, -  VGLTF_KEY_V, -  VGLTF_KEY_W, -  VGLTF_KEY_X, -  VGLTF_KEY_Y, -  VGLTF_KEY_Z, -  VGLTF_KEY_ESCAPE, +  VGLTF_FOREACH_KEY(VGLTF_GENERATE_KEY_ENUM) VGLTF_KEY_COUNT,    VGLTF_KEY_UNKNOWN  }; +#undef VGLTF_GENERATE_KEY_ENUM +extern const char *vgltf_key_str[]; + +enum vgltf_event_type { VGLTF_EVENT_QUIT, VGLTF_EVENT_KEY_DOWN, VGLTF_EVENT_UNKNOWN };  struct vgltf_key_event {    enum vgltf_key key;  }; -struct vgltf_window_resized_event { -  int32_t width; -  int32_t height; -}; -  struct vgltf_event {    enum vgltf_event_type type;    union {      struct vgltf_key_event key; -    struct vgltf_window_resized_event window_resized;    };  }; @@ -75,18 +70,19 @@ struct vgltf_platform;  bool vgltf_platform_init(struct vgltf_platform *platform);  void vgltf_platform_deinit(struct vgltf_platform *platform);  bool vgltf_platform_poll_event(struct vgltf_platform *platform, -                               struct vgltf_event *event); +                             struct vgltf_event *event);  bool vgltf_platform_get_window_size(struct vgltf_platform *platform, -                                    struct vgltf_window_size *window_size); - -// Vulkan specifics -#include "vulkan/vulkan_core.h" -char const *const * +                                  struct vgltf_window_size *window_size); +bool vgltf_platform_get_current_time_nanoseconds(long *time); +char *vgltf_platform_read_file_to_string(const char *filepath, size_t *out_size); +const char *const *  vgltf_platform_get_vulkan_instance_extensions(struct vgltf_platform *platform, -                                              uint32_t *count); +                                            uint32_t *count); + +#include <vulkan/vulkan.h>  bool vgltf_platform_create_vulkan_surface(struct vgltf_platform *platform, -                                          VkInstance instance, -                                          VkSurfaceKHR *surface); +                                        VkInstance instance, +                                        VkSurfaceKHR *surface);  #include "platform_sdl.h"  | 
