1
0

engine.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef SCUFENG_H_
  2. #define SCUFENG_H_
  3. #include <stdio.h>
  4. #include <stdbool.h>
  5. #include <stdint.h>
  6. #include "scufcont/DArray.h"
  7. #include "keys.h" // IWYU pragma: export
  8. #define SERESULT_X(X) \
  9. X(SE_SUCCESS) \
  10. X(SE_OUT_OF_MEMORY) \
  11. X(SE_FC_FAILURE) \
  12. X(SE_NOT_FOUND) \
  13. X(SE_FT_FAILURE) \
  14. X(SE_ERRNO) \
  15. X(SE_GAI) \
  16. X(SE_COULD_NOT_CONNECT_TO_HOST) \
  17. X(SE_COULD_NOT_FIND_ADDRESS)
  18. #define X(val) val,
  19. /**
  20. \enum SEResult
  21. \var SEResult::SE_ERRNO Error, errno was set.
  22. \var SEResult::SE_GAI Error, a function that returns this should also return an error generated by getaddrinfo as on out parameter.
  23. */
  24. typedef enum {
  25. SERESULT_X(X)
  26. } SEResult;
  27. #undef X
  28. typedef enum {
  29. SE_FILL,
  30. SE_LINE,
  31. SE_POINT
  32. } SEPolygonMode;
  33. typedef enum {
  34. SE_NONE,
  35. SE_FORWARD,
  36. SE_BACKWARD,
  37. SE_LEFT,
  38. SE_RIGHT,
  39. SE_UP,
  40. SE_DOWN
  41. } SEDirection;
  42. SCDARRAY_HEADER(uint8_t, uint8)
  43. typedef void (*SEKeyCb)(SEKey key, SEKeyAction action, SEKeyMod mods, void *data);
  44. typedef void (*SECharCb)(unsigned int codepoint);
  45. typedef void (*SEMouseButtonCb)(SEMouseButton button, SEKeyAction action, SEKeyMod mods, void *data);
  46. void se_init(const bool debug, FILE *log_out, FILE *log_err_out);
  47. void se_deinit(void);
  48. void se_window_create(
  49. const int w,
  50. const int h,
  51. const char* title,
  52. const int fullscreen_monitor_i
  53. );
  54. void se_window_close();
  55. void se_clear_color(
  56. const float r,
  57. const float g,
  58. const float b,
  59. const float a
  60. );
  61. void se_clear(void);
  62. void se_swap_buffers(void);
  63. bool se_window_should_close(void);
  64. void se_handle_events(void);
  65. double se_get_time(void);
  66. double se_delta_time(const double current_time);
  67. void se_set_polygon_mode(const SEPolygonMode mode);
  68. void se_set_key_callback(SEKeyCb cb, void *data);
  69. void se_set_mouse_button_callback(SEMouseButtonCb cb, void *data);
  70. SEKeyAction se_get_key(const SEKey key);
  71. SEKeyAction se_get_mouse_button(const SEMouseButton btn);
  72. void se_get_mouse_pos(double *x, double *y);
  73. void se_swap_interval(const int interval);
  74. void se_fps_lock_set_fps(const unsigned int fps);
  75. void se_fps_lock_frame_start_s(const double frame_start_s);
  76. void se_fps_lock_wait(void);
  77. const char* SEResult_to_str(const SEResult res);
  78. #endif // SCUFENG_H_