engine.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef SCUFENG_H_
  2. #define SCUFENG_H_
  3. #include <stdio.h>
  4. #include <stdbool.h>
  5. #include "keys.h" // IWYU pragma: export
  6. #define SERESULT_X(X) \
  7. X(SE_SUCCESS) \
  8. X(SE_OUT_OF_MEMORY) \
  9. X(SE_FC_FAILURE) \
  10. X(SE_NOT_FOUND) \
  11. X(SE_FT_FAILURE)
  12. #define X(val) val,
  13. typedef enum {
  14. SERESULT_X(X)
  15. } SEResult;
  16. #undef X
  17. typedef enum {
  18. SE_FILL,
  19. SE_LINE,
  20. SE_POINT
  21. } SEPolygonMode;
  22. typedef enum {
  23. SE_NONE,
  24. SE_FORWARD,
  25. SE_BACKWARD,
  26. SE_LEFT,
  27. SE_RIGHT,
  28. SE_UP,
  29. SE_DOWN
  30. } SEDirection;
  31. typedef void (*SEKeyCb)(SEKey key, SEKeyAction action, SEKeyMod mods);
  32. typedef void (*SECharCb)(unsigned int codepoint);
  33. void se_init(const bool debug, FILE *log_out, FILE *log_err_out);
  34. void se_deinit(void);
  35. void se_window_create(
  36. const int w,
  37. const int h,
  38. const char* title,
  39. const int fullscreen_monitor_i
  40. );
  41. void se_window_close();
  42. void se_clear_color(
  43. const float r,
  44. const float g,
  45. const float b,
  46. const float a
  47. );
  48. void se_clear(void);
  49. void se_swap_buffers(void);
  50. bool se_window_should_close(void);
  51. void se_handle_events(void);
  52. double se_get_time(void);
  53. double se_delta_time(const double current_time);
  54. void se_set_polygon_mode(const SEPolygonMode mode);
  55. void se_set_key_callback(SEKeyCb cb);
  56. SEKeyAction se_get_key(const SEKey key);
  57. SEKeyAction se_get_mouse_button(const SEMouseButton btn);
  58. void se_get_mouse_pos(double *x, double *y);
  59. void se_swap_interval(const int interval);
  60. void se_fps_lock_set_fps(const unsigned int fps);
  61. void se_fps_lock_frame_start_s(const double frame_start_s);
  62. void se_fps_lock_wait(void);
  63. const char* SEResult_to_str(const SEResult res);
  64. #endif // SCUFENG_H_