/* * author: Patrick-Christopher Mattulat * e-mail: webmaster@lynarstudios.com */ #include #include #include #include #include #include #include using ls::atlantis::core::StatusCodeOk; using ls::atlantis::core::StatusCodeWindowApiLoadingFailed; using ls::atlantis::core::StatusCodeWindowCreationFailed; using ls::atlantis::interfaces::AStatusCode; using ls::atlantis::interfaces::ISdlApi; using ls::std::core::NullPointerArgumentEvaluator; using ls::atlantis::window::SdlApi; using ls::atlantis::window::SdlWindowApi; using ::std::make_shared; using ::std::shared_ptr; SdlWindowApi::SdlWindowApi() : SdlWindowApi(make_shared()) {} SdlWindowApi::SdlWindowApi(const shared_ptr &_sdlApi) : sdlApi(_sdlApi), window(nullptr, [this](SDL_Window *_window) { this->sdlApi->DestroyWindow(_window); }) { NullPointerArgumentEvaluator(_sdlApi).evaluate(); } SdlWindowApi::~SdlWindowApi() { sdlApi->Quit(); } shared_ptr SdlWindowApi::init() { shared_ptr statusCode = this->_initApi(); if (statusCode->getId() == StatusCodeOk{}.getId()) { statusCode = this->_createWindow(); } return statusCode; } shared_ptr SdlWindowApi::_createWindow() { shared_ptr statusCode = make_shared(); window.reset(sdlApi->CreateWindow("", 0, 0, SDL_WINDOW_FULLSCREEN)); if (window == nullptr) { statusCode = make_shared(); statusCode->addHint(sdlApi->GetError()); } return statusCode; } shared_ptr SdlWindowApi::_initApi() const { shared_ptr statusCode = make_shared(); if (!sdlApi->Init(SDL_INIT_VIDEO)) { statusCode = make_shared(); statusCode->addHint(sdlApi->GetError()); } return statusCode; }