MCPcopy Create free account
hub / github.com/AbyssEngine/AbyssEngineOld / updateRenderRect

Method updateRenderRect

src/Abyss/AbyssEngine.cpp:195–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195void 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
217void AbyssEngine::processSceneChange() {
218 if (_nextScene == nullptr) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected