SdlWindowApi.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * author: Patrick-Christopher Mattulat
  3. * e-mail: webmaster@lynarstudios.com
  4. */
  5. #include <SDL3/SDL.h>
  6. #include <core/StatusCodeOk.hpp>
  7. #include <core/StatusCodeWindowApiLoadingFailed.hpp>
  8. #include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
  9. #include <window/SdlApi.hpp>
  10. #include <window/SdlWindowApi.hpp>
  11. using ls::atlantis::core::StatusCodeOk;
  12. using ls::atlantis::core::StatusCodeWindowApiLoadingFailed;
  13. using ls::atlantis::interfaces::AStatusCode;
  14. using ls::atlantis::interfaces::ISdlApi;
  15. using ls::std::core::NullPointerArgumentEvaluator;
  16. using ls::atlantis::window::SdlApi;
  17. using ls::atlantis::window::SdlWindowApi;
  18. using ::std::make_shared;
  19. using ::std::shared_ptr;
  20. SdlWindowApi::SdlWindowApi() : SdlWindowApi(make_shared<SdlApi>())
  21. {}
  22. SdlWindowApi::SdlWindowApi(const shared_ptr<ISdlApi> &_sdlApi) : sdlApi(_sdlApi)
  23. {
  24. NullPointerArgumentEvaluator(_sdlApi).evaluate();
  25. }
  26. SdlWindowApi::~SdlWindowApi()
  27. {
  28. sdlApi->Quit();
  29. }
  30. shared_ptr<AStatusCode> SdlWindowApi::init()
  31. {
  32. return SdlWindowApi::_initApi();
  33. }
  34. shared_ptr<AStatusCode> SdlWindowApi::_createWindow()
  35. {
  36. return make_shared<StatusCodeOk>();
  37. }
  38. shared_ptr<AStatusCode> SdlWindowApi::_initApi()
  39. {
  40. shared_ptr<AStatusCode> statusCode = make_shared<StatusCodeOk>();
  41. if (!sdlApi->Init(SDL_INIT_VIDEO))
  42. {
  43. statusCode = make_shared<StatusCodeWindowApiLoadingFailed>();
  44. }
  45. return statusCode;
  46. }