03_surface_stretch.cpp 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <cstdio>
  2. #include <cerrno>
  3. #include "simple/graphical/initializer.h"
  4. #include "simple/graphical/software_window.h"
  5. #include "simple/graphical/algorithm/blit.h"
  6. #include "simple/support/misc.hpp"
  7. using namespace simple::graphical;
  8. using simple::support::ston;
  9. int main(int argc, char const* argv[]) try
  10. {
  11. switch(argc)
  12. {
  13. case 0: std::puts("What even is?");
  14. case 1: std::puts("Image not specified.");
  15. case 2: std::puts("Width not specified.");
  16. case 3: std::puts("Height not specified.");
  17. return -1;
  18. }
  19. int2 size { ston<int>(argv[2]), ston<int>(argv[3]) };
  20. initializer init;
  21. software_window win("Stretchy", size, window::flags::borderless);
  22. surface image(argv[1]);
  23. // blit will stretch if a destination rectangle is specified
  24. blit(image, win.surface(), rect{win.surface().size()});
  25. win.update();
  26. SDL_Delay(1313);
  27. return 0;
  28. }
  29. catch(...)
  30. {
  31. if(errno)
  32. std::perror("ERROR");
  33. const char* sdl_error = SDL_GetError();
  34. if(*sdl_error)
  35. std::puts(sdl_error);
  36. throw;
  37. }