mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Use structured bindings
This commit is contained in:
parent
f371a99b39
commit
f3aac01744
@ -432,8 +432,7 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the current example
|
// Update the current example
|
||||||
float x = static_cast<float>(sf::Mouse::getPosition(window).x) / static_cast<float>(window.getSize().x);
|
const auto [x, y] = sf::Vector2f(sf::Mouse::getPosition(window)).cwiseDiv(sf::Vector2f(window.getSize()));
|
||||||
float y = static_cast<float>(sf::Mouse::getPosition(window).y) / static_cast<float>(window.getSize().y);
|
|
||||||
effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
|
effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
|
||||||
|
|
||||||
// Clear the window
|
// Clear the window
|
||||||
|
@ -190,8 +190,7 @@ const View& RenderTarget::getDefaultView() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
IntRect RenderTarget::getViewport(const View& view) const
|
IntRect RenderTarget::getViewport(const View& view) const
|
||||||
{
|
{
|
||||||
float width = static_cast<float>(getSize().x);
|
const auto [width, height] = Vector2f(getSize());
|
||||||
float height = static_cast<float>(getSize().y);
|
|
||||||
const FloatRect& viewport = view.getViewport();
|
const FloatRect& viewport = view.getViewport();
|
||||||
|
|
||||||
return IntRect({static_cast<int>(0.5f + width * viewport.left), static_cast<int>(0.5f + height * viewport.top)},
|
return IntRect({static_cast<int>(0.5f + width * viewport.left), static_cast<int>(0.5f + height * viewport.top)},
|
||||||
|
@ -282,8 +282,7 @@ bool Texture::loadFromStream(InputStream& stream, const IntRect& area)
|
|||||||
bool Texture::loadFromImage(const Image& image, const IntRect& area)
|
bool Texture::loadFromImage(const Image& image, const IntRect& area)
|
||||||
{
|
{
|
||||||
// Retrieve the image size
|
// Retrieve the image size
|
||||||
int width = static_cast<int>(image.getSize().x);
|
const auto [width, height] = Vector2i(image.getSize());
|
||||||
int height = static_cast<int>(image.getSize().y);
|
|
||||||
|
|
||||||
// Load the entire image if the source area is either empty or contains the whole image
|
// Load the entire image if the source area is either empty or contains the whole image
|
||||||
if (area.width == 0 || (area.height == 0) ||
|
if (area.width == 0 || (area.height == 0) ||
|
||||||
|
@ -165,8 +165,7 @@ m_cursorGrabbed(m_fullscreen)
|
|||||||
HDC screenDC = GetDC(nullptr);
|
HDC screenDC = GetDC(nullptr);
|
||||||
int left = (GetDeviceCaps(screenDC, HORZRES) - static_cast<int>(mode.size.x)) / 2;
|
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 top = (GetDeviceCaps(screenDC, VERTRES) - static_cast<int>(mode.size.y)) / 2;
|
||||||
int width = static_cast<int>(mode.size.x);
|
auto [width, height] = Vector2i(mode.size);
|
||||||
int height = static_cast<int>(mode.size.y);
|
|
||||||
ReleaseDC(nullptr, screenDC);
|
ReleaseDC(nullptr, screenDC);
|
||||||
|
|
||||||
// Choose the window style according to the Style parameter
|
// Choose the window style according to the Style parameter
|
||||||
|
Loading…
Reference in New Issue
Block a user