Use structured bindings

This commit is contained in:
Chris Thrasher 2023-03-01 22:50:45 -07:00
parent f371a99b39
commit f3aac01744
4 changed files with 8 additions and 12 deletions

View File

@ -432,8 +432,7 @@ int main()
}
// Update the current example
float x = static_cast<float>(sf::Mouse::getPosition(window).x) / static_cast<float>(window.getSize().x);
float y = static_cast<float>(sf::Mouse::getPosition(window).y) / static_cast<float>(window.getSize().y);
const auto [x, y] = sf::Vector2f(sf::Mouse::getPosition(window)).cwiseDiv(sf::Vector2f(window.getSize()));
effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
// Clear the window

View File

@ -190,8 +190,7 @@ const View& RenderTarget::getDefaultView() const
////////////////////////////////////////////////////////////
IntRect RenderTarget::getViewport(const View& view) const
{
float width = static_cast<float>(getSize().x);
float height = static_cast<float>(getSize().y);
const auto [width, height] = Vector2f(getSize());
const FloatRect& viewport = view.getViewport();
return IntRect({static_cast<int>(0.5f + width * viewport.left), static_cast<int>(0.5f + height * viewport.top)},

View File

@ -282,8 +282,7 @@ bool Texture::loadFromStream(InputStream& stream, const IntRect& area)
bool Texture::loadFromImage(const Image& image, const IntRect& area)
{
// Retrieve the image size
int width = static_cast<int>(image.getSize().x);
int height = static_cast<int>(image.getSize().y);
const auto [width, height] = Vector2i(image.getSize());
// Load the entire image if the source area is either empty or contains the whole image
if (area.width == 0 || (area.height == 0) ||

View File

@ -165,8 +165,7 @@ m_cursorGrabbed(m_fullscreen)
HDC screenDC = GetDC(nullptr);
int left = (GetDeviceCaps(screenDC, HORZRES) - static_cast<int>(mode.size.x)) / 2;
int top = (GetDeviceCaps(screenDC, VERTRES) - static_cast<int>(mode.size.y)) / 2;
int width = static_cast<int>(mode.size.x);
int height = static_cast<int>(mode.size.y);
auto [width, height] = Vector2i(mode.size);
ReleaseDC(nullptr, screenDC);
// Choose the window style according to the Style parameter