mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Use structured bindings
This commit is contained in:
parent
f371a99b39
commit
f3aac01744
@ -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
|
||||
|
@ -190,9 +190,8 @@ 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 FloatRect& viewport = view.getViewport();
|
||||
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)},
|
||||
{static_cast<int>(0.5f + width * viewport.width), static_cast<int>(0.5f + height * viewport.height)});
|
||||
|
@ -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) ||
|
||||
|
@ -162,11 +162,10 @@ m_cursorGrabbed(m_fullscreen)
|
||||
registerWindowClass();
|
||||
|
||||
// Compute position and size
|
||||
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);
|
||||
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;
|
||||
auto [width, height] = Vector2i(mode.size);
|
||||
ReleaseDC(nullptr, screenDC);
|
||||
|
||||
// Choose the window style according to the Style parameter
|
||||
|
Loading…
Reference in New Issue
Block a user