Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sf::View StateStack::updateView()
- {
- //calculate the correct view size / ratio for window size
- m_context.defaultView.setSize(1920.f, 1080.f);
- m_context.defaultView.setCenter(960.f, 540.f);
- auto vModeWidth = static_cast<float>(m_context.appInstance.getVideoSettings().VideoMode.width);
- auto vModeHeight = static_cast<float>(m_context.appInstance.getVideoSettings().VideoMode.height);
- auto winSize = sf::Vector2f(vModeWidth, vModeHeight);
- float windowRatio = winSize.x / winSize.y;
- float viewRatio = 16.f / 9.f;
- float sizeY = windowRatio / viewRatio;
- float top = (1.f - sizeY) / 2.f;
- m_context.defaultView.setViewport({ { 0.f, top }, { 1.f, sizeY } });
- for (auto& state : m_stack)
- state->setContext(m_context);
- return m_context.defaultView;
- }
Advertisement
Add Comment
Please, Sign In to add comment