| 193 | } |
| 194 | |
| 195 | void AbyssEngine::updateRenderRect() { |
| 196 | // update the game's render rect so that it scales up to fit the window, using vertical or horizontal letterboxing |
| 197 | int w, h; |
| 198 | SDL_GetWindowSize(_window.get(), &w, &h); |
| 199 | |
| 200 | const auto windowAspectRatio = static_cast<float>(w) / static_cast<float>(h); |
| 201 | constexpr float gameAspectRatio = 800.0f / 600.0f; |
| 202 | |
| 203 | if (windowAspectRatio > gameAspectRatio) { |
| 204 | _renderRect.w = static_cast<int>(static_cast<float>(h) * gameAspectRatio); |
| 205 | _renderRect.h = h; |
| 206 | _renderRect.x = (w - _renderRect.w) / 2; |
| 207 | _renderRect.y = 0; |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | _renderRect.w = w; |
| 212 | _renderRect.h = static_cast<int>(static_cast<float>(w) / gameAspectRatio); |
| 213 | _renderRect.x = 0; |
| 214 | _renderRect.y = (h - _renderRect.h) / 2; |
| 215 | } |
| 216 | |
| 217 | void AbyssEngine::processSceneChange() { |
| 218 | if (_nextScene == nullptr) { |
nothing calls this directly
no outgoing calls
no test coverage detected