window.h 884 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef IC_EXPLORER_WINDOW_H
  2. #define IC_EXPLORER_WINDOW_H
  3. #include <SDL.h>
  4. #define AUTOMATIC_SCALE 0.0f
  5. #define MAX_ZOOM 2.0f
  6. #define ZOOM_TIME 750
  7. #define WINDOW_STATE_NORMAL 0
  8. #define WINDOW_STATE_ZOOMING_IN 1
  9. #define WINDOW_STATE_ZOOMING_OUT 2
  10. #define WINDOW_STATE_ZOOMED 3
  11. typedef struct {
  12. float x;
  13. float y;
  14. } Point;
  15. typedef struct {
  16. SDL_Window *obj;
  17. SDL_Renderer *render;
  18. SDL_Texture *background;
  19. Point focus;
  20. Point targetFocus;
  21. Point startFocus;
  22. float zoom;
  23. int state;
  24. double nowTime;
  25. double lastTime;
  26. double delta;
  27. } Window;
  28. Window *windowNew(const char *title, int width, int height);
  29. void windowDelete(Window *window);
  30. void windowDraw(Window *window);
  31. void windowUpdate(Window *window);
  32. void windowZoomTo(Window *window, float x, float y);
  33. void windowZoomOut(Window *window);
  34. #endif /* IC_EXPLORER_WINDOW_H */