sim_fb.h 943 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (C) 2023 Victor Suarez Rovere <suarezvictor@gmail.com>
  2. // SPDX-License-Identifier: AGPL-3.0-only
  3. #ifndef __SIM_FB_H__
  4. #define __SIM_FB_H__
  5. struct SDL_Window;
  6. struct SDL_Renderer;
  7. struct SDL_Texture;
  8. typedef struct
  9. {
  10. SDL_Window* win;
  11. SDL_Renderer* renderer;
  12. SDL_Texture* texture;
  13. } fb_handle_t;
  14. int fb_init(unsigned width, unsigned height, int vsync, fb_handle_t *handle);
  15. void fb_update(fb_handle_t *handle, const void *buf, size_t stride_bytes);
  16. void fb_deinit(fb_handle_t *handle);
  17. int fb_should_quit(void);
  18. #ifndef EXTERN_C
  19. #ifdef __cplusplus
  20. #define EXTERN_C extern "C"
  21. #else
  22. #define EXTERN_C
  23. #endif
  24. #endif
  25. EXTERN_C uint64_t SDL_GetPerformanceCounter(void);
  26. EXTERN_C uint64_t SDL_GetPerformanceFrequency(void);
  27. static inline uint64_t higres_ticks(void) { return SDL_GetPerformanceCounter(); }
  28. static inline uint64_t higres_ticks_freq(void) { return SDL_GetPerformanceFrequency(); }
  29. #endif //__SIM_FB_H__