window.h 637 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef WINDOW_H
  2. #define WINDOW_H
  3. #include <SDL2/SDL.h>
  4. struct window {
  5. SDL_Window *ptr;
  6. int32_t h;
  7. int32_t w;
  8. };
  9. #define WINDOW_UP_SIZE(win) SDL_GetWindowSize(win.ptr, &win.w, &win.h)
  10. struct window window_create(const char *win_title);
  11. #if defined(WINDOW_IMP) || defined(IMP)
  12. #include "sc.h"
  13. struct window
  14. window_create(const char *win_title)
  15. {
  16. struct window win = {
  17. .ptr = SDL_CreateWindow(win_title,
  18. SDL_WINDOWPOS_UNDEFINED,
  19. SDL_WINDOWPOS_UNDEFINED,
  20. 600, 800,
  21. SDL_WINDOW_RESIZABLE),
  22. };
  23. SCP(win.ptr);
  24. WINDOW_UP_SIZE(win);
  25. return win;
  26. }
  27. #endif /* defined(WINDOW_IMP) || defined(IMP) */
  28. #endif