Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/examples/opengl/OpenGL.cpp b/examples/opengl/OpenGL.cpp
- index 639254b..3831508 100644
- --- a/examples/opengl/OpenGL.cpp
- +++ b/examples/opengl/OpenGL.cpp
- @@ -68,7 +68,7 @@ int main()
- // Setup a perspective projection
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- - GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
- + GLfloat ratio = static_cast<float>(window.getSize().x) / static_cast<float>(window.getSize().y);
- glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
- // Bind the texture
- @@ -164,8 +164,8 @@ int main()
- glClear(GL_DEPTH_BUFFER_BIT);
- // We get the position of the mouse cursor, so that we can move the box accordingly
- - float x = sf::Mouse::getPosition(window).x * 200.f / window.getSize().x - 100.f;
- - float y = -sf::Mouse::getPosition(window).y * 200.f / window.getSize().y + 100.f;
- + float x = static_cast<float>(sf::Mouse::getPosition(window).x) * 200.f / static_cast<float>(window.getSize().x) - 100.f;
- + float y = -static_cast<float>(sf::Mouse::getPosition(window).y) * 200.f / static_cast<float>(window.getSize().y) + 100.f;
- // Apply some transformations
- glMatrixMode(GL_MODELVIEW);
- diff --git a/examples/pong/Pong.cpp b/examples/pong/Pong.cpp
- index 1b9a74f..20de537 100644
- --- a/examples/pong/Pong.cpp
- +++ b/examples/pong/Pong.cpp
- @@ -90,7 +90,7 @@ int main()
- while (window.pollEvent(event))
- {
- // Window closed or escape key pressed: exit
- - if ((event.type == sf::Event::Closed) ||
- + if ((event.type == sf::Event::Closed) ||
- ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
- {
- window.close();
- @@ -115,7 +115,7 @@ int main()
- do
- {
- // Make sure the ball initial angle is not too much vertical
- - ballAngle = (std::rand() % 360) * 2 * pi / 360;
- + ballAngle = static_cast<float>(std::rand() % 360) * 2.f * pi / 360.f;
- }
- while (std::abs(std::cos(ballAngle)) < 0.7f);
- }
- @@ -187,15 +187,15 @@ int main()
- // Check the collisions between the ball and the paddles
- // Left Paddle
- - if (ball.getPosition().x - ballRadius < leftPaddle.getPosition().x + paddleSize.x / 2 &&
- + if (ball.getPosition().x - ballRadius < leftPaddle.getPosition().x + paddleSize.x / 2 &&
- ball.getPosition().x - ballRadius > leftPaddle.getPosition().x &&
- ball.getPosition().y + ballRadius >= leftPaddle.getPosition().y - paddleSize.y / 2 &&
- ball.getPosition().y - ballRadius <= leftPaddle.getPosition().y + paddleSize.y / 2)
- {
- if (ball.getPosition().y > leftPaddle.getPosition().y)
- - ballAngle = pi - ballAngle + (std::rand() % 20) * pi / 180;
- + ballAngle = pi - ballAngle + static_cast<float>(std::rand() % 20) * pi / 180.f;
- else
- - ballAngle = pi - ballAngle - (std::rand() % 20) * pi / 180;
- + ballAngle = pi - ballAngle - static_cast<float>(std::rand() % 20) * pi / 180.f;
- ballSound.play();
- ball.setPosition(leftPaddle.getPosition().x + ballRadius + paddleSize.x / 2 + 0.1f, ball.getPosition().y);
- @@ -208,9 +208,9 @@ int main()
- ball.getPosition().y - ballRadius <= rightPaddle.getPosition().y + paddleSize.y / 2)
- {
- if (ball.getPosition().y > rightPaddle.getPosition().y)
- - ballAngle = pi - ballAngle + (std::rand() % 20) * pi / 180;
- + ballAngle = pi - ballAngle + static_cast<float>(std::rand() % 20) * pi / 180.f;
- else
- - ballAngle = pi - ballAngle - (std::rand() % 20) * pi / 180;
- + ballAngle = pi - ballAngle - static_cast<float>(std::rand() % 20) * pi / 180.f;
- ballSound.play();
- ball.setPosition(rightPaddle.getPosition().x - ballRadius - paddleSize.x / 2 - 0.1f, ball.getPosition().y);
- diff --git a/examples/shader/Shader.cpp b/examples/shader/Shader.cpp
- index 9595920..af013a5 100644
- --- a/examples/shader/Shader.cpp
- +++ b/examples/shader/Shader.cpp
- @@ -139,9 +139,9 @@ public :
- {
- float x = static_cast<float>(std::rand() % 800);
- float y = static_cast<float>(std::rand() % 600);
- - sf::Uint8 r = std::rand() % 255;
- - sf::Uint8 g = std::rand() % 255;
- - sf::Uint8 b = std::rand() % 255;
- + sf::Uint8 r = static_cast<sf::Uint8>(std::rand() % 255);
- + sf::Uint8 g = static_cast<sf::Uint8>(std::rand() % 255);
- + sf::Uint8 b = static_cast<sf::Uint8>(std::rand() % 255);
- m_points.append(sf::Vertex(sf::Vector2f(x, y), sf::Color(r, g, b)));
- }
- @@ -228,8 +228,8 @@ public :
- for (std::size_t i = 0; i < m_entities.size(); ++i)
- {
- sf::Vector2f position;
- - position.x = std::cos(0.25f * (time * i + (m_entities.size() - i))) * 300 + 350;
- - position.y = std::sin(0.25f * (time * (m_entities.size() - i) + i)) * 200 + 250;
- + position.x = std::cos(0.25f * (time * static_cast<float>(i + (m_entities.size() - i)))) * 300.f + 350.f;
- + position.y = std::sin(0.25f * (time * static_cast<float>((m_entities.size() - i) + i))) * 200.f + 250.f;
- m_entities[i].setPosition(position);
- }
- @@ -352,8 +352,8 @@ int main()
- }
- // Update the current example
- - float x = static_cast<float>(sf::Mouse::getPosition(window).x) / window.getSize().x;
- - float y = static_cast<float>(sf::Mouse::getPosition(window).y) / window.getSize().y;
- + 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);
- effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
- // Clear the window
- diff --git a/examples/window/Window.cpp b/examples/window/Window.cpp
- index 360703b..e9ec847 100644
- --- a/examples/window/Window.cpp
- +++ b/examples/window/Window.cpp
- @@ -41,7 +41,7 @@ int main()
- // Setup a perspective projection
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- - GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
- + GLfloat ratio = static_cast<float>(window.getSize().x) / static_cast<float>(window.getSize().y);
- glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
- // Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
- diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp
- index b8dc6eb..eddc74f 100644
- --- a/src/SFML/Audio/Music.cpp
- +++ b/src/SFML/Audio/Music.cpp
- @@ -139,7 +139,7 @@ void Music::onSeek(Time timeOffset)
- void Music::initialize()
- {
- // Compute the music duration
- - m_duration = seconds(static_cast<float>(m_file->getSampleCount()) / m_file->getSampleRate() / m_file->getChannelCount());
- + m_duration = seconds(static_cast<float>(m_file->getSampleCount()) / static_cast<float>(m_file->getSampleRate()) / static_cast<float>(m_file->getChannelCount()));
- // Resize the internal buffer so that it can contain 1 second of audio samples
- m_samples.resize(m_file->getSampleRate() * m_file->getChannelCount());
- diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp
- index cfd1c6a..bf4ac08 100644
- --- a/src/SFML/Audio/SoundBuffer.cpp
- +++ b/src/SFML/Audio/SoundBuffer.cpp
- @@ -253,7 +253,7 @@ bool SoundBuffer::update(unsigned int channelCount, unsigned int sampleRate)
- alCheck(alBufferData(m_buffer, format, &m_samples[0], size, sampleRate));
- // Compute the duration
- - m_duration = seconds(static_cast<float>(m_samples.size()) / sampleRate / channelCount);
- + m_duration = seconds(static_cast<float>(m_samples.size()) / static_cast<float>(sampleRate) / static_cast<float>(channelCount));
- return true;
- }
- diff --git a/src/SFML/Audio/SoundFile.cpp b/src/SFML/Audio/SoundFile.cpp
- index fdd7667..e0101d3 100644
- --- a/src/SFML/Audio/SoundFile.cpp
- +++ b/src/SFML/Audio/SoundFile.cpp
- @@ -284,7 +284,7 @@ void SoundFile::seek(Time timeOffset)
- {
- if (m_file)
- {
- - sf_count_t frameOffset = static_cast<sf_count_t>(timeOffset.asSeconds() * m_sampleRate);
- + sf_count_t frameOffset = static_cast<sf_count_t>(timeOffset.asSeconds() * static_cast<float>(m_sampleRate));
- sf_seek(m_file, frameOffset, SEEK_SET);
- }
- }
- diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp
- index 31df188..7fb6ece 100644
- --- a/src/SFML/Audio/SoundStream.cpp
- +++ b/src/SFML/Audio/SoundStream.cpp
- @@ -159,7 +159,7 @@ void SoundStream::setPlayingOffset(Time timeOffset)
- onSeek(timeOffset);
- // Restart streaming
- - m_samplesProcessed = static_cast<Uint64>(timeOffset.asSeconds() * m_sampleRate * m_channelCount);
- + m_samplesProcessed = static_cast<Uint64>(timeOffset.asSeconds() * static_cast<float>(m_sampleRate) * static_cast<float>(m_channelCount));
- m_isStreaming = true;
- m_thread.launch();
- }
- @@ -173,7 +173,7 @@ Time SoundStream::getPlayingOffset() const
- ALfloat secs = 0.f;
- alCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &secs));
- - return seconds(secs + static_cast<float>(m_samplesProcessed) / m_sampleRate / m_channelCount);
- + return seconds(secs + static_cast<float>(m_samplesProcessed) / static_cast<float>(m_sampleRate) / static_cast<float>(m_channelCount));
- }
- else
- {
- diff --git a/src/SFML/Graphics/CircleShape.cpp b/src/SFML/Graphics/CircleShape.cpp
- index 23e9e77..c51c533 100644
- --- a/src/SFML/Graphics/CircleShape.cpp
- +++ b/src/SFML/Graphics/CircleShape.cpp
- @@ -74,7 +74,7 @@ Vector2f CircleShape::getPoint(unsigned int index) const
- {
- static const float pi = 3.141592654f;
- - float angle = index * 2 * pi / m_pointCount - pi / 2;
- + float angle = static_cast<float>(index) * 2.f * pi / static_cast<float>(m_pointCount) - pi / 2.f;
- float x = std::cos(angle) * m_radius;
- float y = std::sin(angle) * m_radius;
- diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp
- index 1e26c81..72b101c 100644
- --- a/src/SFML/Graphics/Font.cpp
- +++ b/src/SFML/Graphics/Font.cpp
- @@ -542,7 +542,7 @@ IntRect Font::findGlyphRect(Page& page, unsigned int width, unsigned int height)
- float bestRatio = 0;
- for (std::vector<Row>::iterator it = page.rows.begin(); it != page.rows.end() && !row; ++it)
- {
- - float ratio = static_cast<float>(height) / it->height;
- + float ratio = static_cast<float>(height) / static_cast<float>(it->height);
- // Ignore rows that are either too small or too high
- if ((ratio < 0.7f) || (ratio > 1.f))
- diff --git a/src/SFML/Graphics/GLExtensions.cpp b/src/SFML/Graphics/GLExtensions.cpp
- index 83afa86..ad6cdd4 100644
- --- a/src/SFML/Graphics/GLExtensions.cpp
- +++ b/src/SFML/Graphics/GLExtensions.cpp
- @@ -26,6 +26,7 @@
- // Headers
- ////////////////////////////////////////////////////////////
- #include <SFML/Graphics/GLExtensions.hpp>
- +#include <SFML/System/Err.hpp>
- namespace sf
- diff --git a/src/SFML/Graphics/GLExtensions.hpp b/src/SFML/Graphics/GLExtensions.hpp
- index de12af6..0f74d3a 100644
- --- a/src/SFML/Graphics/GLExtensions.hpp
- +++ b/src/SFML/Graphics/GLExtensions.hpp
- @@ -34,56 +34,186 @@
- #include <SFML/OpenGL.hpp>
- - #define GL_blend_func_separate GL_OES_blend_func_separate
- - #define glBlendFuncSeparate glBlendFuncSeparateOES
- - #define GL_framebuffer_object GL_OES_framebuffer_object
- - #define glGenFramebuffers glGenFramebuffersOES
- - #define glGenRenderbuffers glGenRenderbuffersOES
- - #define glBindFramebuffer glBindFramebufferOES
- - #define glBindRenderbuffer glBindRenderbufferOES
- - #define glDeleteFramebuffers glDeleteFramebuffersOES
- - #define glDeleteRenderbuffers glDeleteRenderbuffersOES
- - #define glRenderbufferStorage glRenderbufferStorageOES
- - #define glFramebufferRenderbuffer glFramebufferRenderbufferOES
- - #define glFramebufferTexture2D glFramebufferTexture2DOES
- - #define glCheckFramebufferStatus glCheckFramebufferStatusOES
- - #define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
- - #define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_OES
- - #define GL_RENDERBUFFER GL_RENDERBUFFER_OES
- - #define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES
- - #define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES
- - #define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
- - #define GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT16_OES
- - #define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_OES
- - #define GL_texture_non_power_of_two false
- + #if !defined(GL_blend_func_separate)
- + #define GL_blend_func_separate GL_OES_blend_func_separate
- + #endif
- +
- + #if !defined(glBlendFuncSeparate)
- + #define glBlendFuncSeparate glBlendFuncSeparateOES
- + #endif
- +
- + #if !defined(GL_framebuffer_object)
- + #define GL_framebuffer_object GL_OES_framebuffer_object
- + #endif
- +
- + #if !defined(glGenFramebuffers)
- + #define glGenFramebuffers glGenFramebuffersOES
- + #endif
- +
- + #if !defined(glGenRenderbuffers)
- + #define glGenRenderbuffers glGenRenderbuffersOES
- + #endif
- +
- + #if !defined(glBindFramebuffer)
- + #define glBindFramebuffer glBindFramebufferOES
- + #endif
- +
- + #if !defined(glBindRenderbuffer)
- + #define glBindRenderbuffer glBindRenderbufferOES
- + #endif
- +
- + #if !defined(glDeleteFramebuffers)
- + #define glDeleteFramebuffers glDeleteFramebuffersOES
- + #endif
- +
- + #if !defined(glDeleteRenderbuffers)
- + #define glDeleteRenderbuffers glDeleteRenderbuffersOES
- + #endif
- +
- + #if !defined(glRenderbufferStorage)
- + #define glRenderbufferStorage glRenderbufferStorageOES
- + #endif
- +
- + #if !defined(glFramebufferRenderbuffer)
- + #define glFramebufferRenderbuffer glFramebufferRenderbufferOES
- + #endif
- +
- + #if !defined(glFramebufferTexture2D)
- + #define glFramebufferTexture2D glFramebufferTexture2DOES
- + #endif
- +
- + #if !defined(glCheckFramebufferStatus)
- + #define glCheckFramebufferStatus glCheckFramebufferStatusOES
- + #endif
- +
- + #if !defined(GL_FRAMEBUFFER)
- + #define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
- + #endif
- +
- + #if !defined(GL_FRAMEBUFFER_BINDING)
- + #define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_OES
- + #endif
- +
- + #if !defined(GL_RENDERBUFFER)
- + #define GL_RENDERBUFFER GL_RENDERBUFFER_OES
- + #endif
- +
- + #if !defined(GL_COLOR_ATTACHMENT0)
- + #define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES
- + #endif
- +
- + #if !defined(GL_DEPTH_ATTACHMENT)
- + #define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES
- + #endif
- +
- + #if !defined(GL_FRAMEBUFFER_COMPLETE)
- + #define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
- + #endif
- +
- + #if !defined(GL_DEPTH_COMPONENT)
- + #define GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT16_OES
- + #endif
- +
- + #if !defined(GL_INVALID_FRAMEBUFFER_OPERATION)
- + #define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_OES
- + #endif
- +
- + #if !defined(GL_texture_non_power_of_two
- + #define GL_texture_non_power_of_two false
- + #endif
- #else
- #include <GL/glew.h>
- #include <SFML/OpenGL.hpp>
- - #define GL_blend_func_separate GLEW_EXT_blend_func_separate
- - #define glBlendFuncSeparate glBlendFuncSeparateEXT
- - #define GL_framebuffer_object GLEW_EXT_framebuffer_object
- - #define glGenFramebuffers glGenFramebuffersEXT
- - #define glGenRenderbuffers glGenRenderbuffersEXT
- - #define glBindFramebuffer glBindFramebufferEXT
- - #define glBindRenderbuffer glBindRenderbufferEXT
- - #define glDeleteFramebuffers glDeleteFramebuffersEXT
- - #define glDeleteRenderbuffers glDeleteRenderbuffersEXT
- - #define glRenderbufferStorage glRenderbufferStorageEXT
- - #define glFramebufferRenderbuffer glRenderbufferStorageEXT
- - #define glFramebufferTexture2D glFramebufferTexture2DEXT
- - #define glCheckFramebufferStatus glCheckFramebufferStatusEXT
- - #define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
- - #define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
- - #define GL_RENDERBUFFER GL_RENDERBUFFER_EXT
- - #define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
- - #define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
- - #define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
- - //#define GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT
- - #define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT
- - #define GL_texture_non_power_of_two GLEW_ARB_texture_non_power_of_two
- + #if !defined(GL_blend_func_separate)
- + #define GL_blend_func_separate GLEW_EXT_blend_func_separate
- + #endif
- +
- + #if !defined(glBlendFuncSeparate)
- + #define glBlendFuncSeparate glBlendFuncSeparateEXT
- + #endif
- +
- + #if !defined(GL_framebuffer_object)
- + #define GL_framebuffer_object GLEW_EXT_framebuffer_object
- + #endif
- +
- + #if !defined(glGenFramebuffers)
- + #define glGenFramebuffers glGenFramebuffersEXT
- + #endif
- +
- + #if !defined(glGenRenderbuffers)
- + #define glGenRenderbuffers glGenRenderbuffersEXT
- + #endif
- +
- + #if !defined(glBindFramebuffer)
- + #define glBindFramebuffer glBindFramebufferEXT
- + #endif
- +
- + #if !defined(glBindRenderbuffer)
- + #define glBindRenderbuffer glBindRenderbufferEXT
- + #endif
- +
- + #if !defined(glDeleteFramebuffers)
- + #define glDeleteFramebuffers glDeleteFramebuffersEXT
- + #endif
- +
- + #if !defined(glDeleteRenderbuffers)
- + #define glDeleteRenderbuffers glDeleteRenderbuffersEXT
- + #endif
- +
- + #if !defined(glRenderbufferStorage)
- + #define glRenderbufferStorage glRenderbufferStorageEXT
- + #endif
- +
- + #if !defined(glFramebufferRenderbuffer)
- + #define glFramebufferRenderbuffer glRenderbufferStorageEXT
- + #endif
- +
- + #if !defined(glFramebufferTexture2D)
- + #define glFramebufferTexture2D glFramebufferTexture2DEXT
- + #endif
- +
- + #if !defined(glCheckFramebufferStatus)
- + #define glCheckFramebufferStatus glCheckFramebufferStatusEXT
- + #endif
- +
- + #if !defined(GL_FRAMEBUFFER)
- + #define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
- + #endif
- +
- + #if !defined(GL_FRAMEBUFFER_BINDING)
- + #define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
- + #endif
- +
- + #if !defined(GL_RENDERBUFFER)
- + #define GL_RENDERBUFFER GL_RENDERBUFFER_EXT
- + #endif
- +
- + #if !defined(GL_COLOR_ATTACHMENT0)
- + #define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
- + #endif
- +
- + #if !defined(GL_DEPTH_ATTACHMENT)
- + #define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
- + #endif
- +
- + #if !defined(GL_FRAMEBUFFER_COMPLETE)
- + #define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
- + #endif
- +
- + #if !defined(GL_DEPTH_COMPONENT)
- + //#define GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT
- + #endif
- +
- + #if !defined(GL_INVALID_FRAMEBUFFER_OPERATION)
- + #define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT
- + #endif
- +
- + #if !defined(GL_texture_non_power_of_two)
- + #define GL_texture_non_power_of_two GLEW_ARB_texture_non_power_of_two
- + #endif
- #endif
- diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp
- index 8efb9c7..a4d575b 100644
- --- a/src/SFML/Graphics/Image.cpp
- +++ b/src/SFML/Graphics/Image.cpp
- @@ -240,10 +240,10 @@ void Image::copy(const Image& source, unsigned int destX, unsigned int destY, co
- // Interpolate RGBA components using the alpha value of the source pixel
- Uint8 alpha = src[3];
- - dst[0] = (src[0] * alpha + dst[0] * (255 - alpha)) / 255;
- - dst[1] = (src[1] * alpha + dst[1] * (255 - alpha)) / 255;
- - dst[2] = (src[2] * alpha + dst[2] * (255 - alpha)) / 255;
- - dst[3] = alpha + dst[3] * (255 - alpha) / 255;
- + dst[0] = static_cast<Uint8>((src[0] * alpha + dst[0] * (255 - alpha)) / 255);
- + dst[1] = static_cast<Uint8>((src[1] * alpha + dst[1] * (255 - alpha)) / 255);
- + dst[2] = static_cast<Uint8>((src[2] * alpha + dst[2] * (255 - alpha)) / 255);
- + dst[3] = static_cast<Uint8>(alpha + dst[3] * (255 - alpha) / 255);
- }
- srcPixels += srcStride;
- diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp
- index f015139..c5205ec 100644
- --- a/src/SFML/Graphics/RenderTarget.cpp
- +++ b/src/SFML/Graphics/RenderTarget.cpp
- @@ -113,8 +113,8 @@ Vector2f RenderTarget::mapPixelToCoords(const Vector2i& point, const View& view)
- // First, convert from viewport coordinates to homogeneous coordinates
- Vector2f normalized;
- IntRect viewport = getViewport(view);
- - normalized.x = -1.f + 2.f * (point.x - viewport.left) / viewport.width;
- - normalized.y = 1.f - 2.f * (point.y - viewport.top) / viewport.height;
- + normalized.x = -1.f + 2.f * static_cast<float>(point.x - viewport.left) / static_cast<float>(viewport.width);
- + normalized.y = 1.f - 2.f * static_cast<float>(point.y - viewport.top) / static_cast<float>(viewport.height);
- // Then transform by the inverse of the view matrix
- return view.getInverseTransform().transformPoint(normalized);
- @@ -137,8 +137,8 @@ Vector2i RenderTarget::mapCoordsToPixel(const Vector2f& point, const View& view)
- // Then convert to viewport coordinates
- Vector2i pixel;
- IntRect viewport = getViewport(view);
- - pixel.x = static_cast<int>(( normalized.x + 1.f) / 2.f * viewport.width + viewport.left);
- - pixel.y = static_cast<int>((-normalized.y + 1.f) / 2.f * viewport.height + viewport.top);
- + pixel.x = static_cast<int>(( normalized.x + 1.f) / 2.f * static_cast<float>(viewport.width + viewport.left));
- + pixel.y = static_cast<int>((-normalized.y + 1.f) / 2.f * static_cast<float>(viewport.height + viewport.top));
- return pixel;
- }
- diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp
- index 0b6efc6..a2a13d7 100644
- --- a/src/SFML/Graphics/Shader.cpp
- +++ b/src/SFML/Graphics/Shader.cpp
- @@ -54,7 +54,7 @@ namespace
- if (file)
- {
- file.seekg(0, std::ios_base::end);
- - std::streamsize size = file.tellg();
- + std::streamsize size = static_cast<std::streamsize>(file.tellg());
- if (size > 0)
- {
- file.seekg(0, std::ios_base::beg);
- diff --git a/src/SFML/Graphics/Shape.cpp b/src/SFML/Graphics/Shape.cpp
- index 16524f5..2d15367 100644
- --- a/src/SFML/Graphics/Shape.cpp
- +++ b/src/SFML/Graphics/Shape.cpp
- @@ -39,7 +39,7 @@ namespace
- {
- sf::Vector2f normal(p1.y - p2.y, p2.x - p1.x);
- float length = std::sqrt(normal.x * normal.x + normal.y * normal.y);
- - if (length != 0.f)
- + if (std::abs(length) > 0.f)
- normal /= length;
- return normal;
- }
- @@ -219,7 +219,7 @@ void Shape::draw(RenderTarget& target, RenderStates states) const
- target.draw(m_vertices, states);
- // Render the outline
- - if (m_outlineThickness != 0)
- + if (std::abs(m_outlineThickness) > 0.f)
- {
- states.texture = NULL;
- target.draw(m_outlineVertices, states);
- @@ -242,8 +242,8 @@ void Shape::updateTexCoords()
- {
- float xratio = (m_vertices[i].position.x - m_insideBounds.left) / m_insideBounds.width;
- float yratio = (m_vertices[i].position.y - m_insideBounds.top) / m_insideBounds.height;
- - m_vertices[i].texCoords.x = m_textureRect.left + m_textureRect.width * xratio;
- - m_vertices[i].texCoords.y = m_textureRect.top + m_textureRect.height * yratio;
- + m_vertices[i].texCoords.x = static_cast<float>(m_textureRect.left + m_textureRect.width) * xratio;
- + m_vertices[i].texCoords.y = static_cast<float>(m_textureRect.top + m_textureRect.height) * yratio;
- }
- }
- diff --git a/src/SFML/Graphics/Sprite.cpp b/src/SFML/Graphics/Sprite.cpp
- index a64f920..b625ac0 100644
- --- a/src/SFML/Graphics/Sprite.cpp
- +++ b/src/SFML/Graphics/Sprite.cpp
- @@ -161,9 +161,9 @@ void Sprite::updatePositions()
- void Sprite::updateTexCoords()
- {
- float left = static_cast<float>(m_textureRect.left);
- - float right = left + m_textureRect.width;
- + float right = left + static_cast<float>(m_textureRect.width);
- float top = static_cast<float>(m_textureRect.top);
- - float bottom = top + m_textureRect.height;
- + float bottom = top + static_cast<float>(m_textureRect.height);
- m_vertices[0].texCoords = Vector2f(left, top);
- m_vertices[1].texCoords = Vector2f(left, bottom);
- diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp
- index ec9128c..745bb7f 100644
- --- a/src/SFML/Graphics/Text.cpp
- +++ b/src/SFML/Graphics/Text.cpp
- @@ -241,8 +241,8 @@ void Text::updateGeometry()
- bool bold = (m_style & Bold) != 0;
- bool underlined = (m_style & Underlined) != 0;
- float italic = (m_style & Italic) ? 0.208f : 0.f; // 12 degrees
- - float underlineOffset = m_characterSize * 0.1f;
- - float underlineThickness = m_characterSize * (bold ? 0.1f : 0.07f);
- + float underlineOffset = static_cast<float>(m_characterSize) * 0.1f;
- + float underlineThickness = static_cast<float>(m_characterSize) * (bold ? 0.1f : 0.07f);
- // Precompute the variables needed by the algorithm
- float hspace = static_cast<float>(m_font->getGlyph(L' ', m_characterSize, bold).advance);
- @@ -304,10 +304,10 @@ void Text::updateGeometry()
- // Extract the current glyph's description
- const Glyph& glyph = m_font->getGlyph(curChar, m_characterSize, bold);
- - int left = glyph.bounds.left;
- - int top = glyph.bounds.top;
- - int right = glyph.bounds.left + glyph.bounds.width;
- - int bottom = glyph.bounds.top + glyph.bounds.height;
- + float left = static_cast<float>(glyph.bounds.left);
- + float top = static_cast<float>(glyph.bounds.top);
- + float right = static_cast<float>(glyph.bounds.left + glyph.bounds.width);
- + float bottom = static_cast<float>(glyph.bounds.top + glyph.bounds.height);
- float u1 = static_cast<float>(glyph.textureRect.left);
- float v1 = static_cast<float>(glyph.textureRect.top);
- @@ -329,7 +329,7 @@ void Text::updateGeometry()
- maxY = std::max(maxY, y + bottom);
- // Advance to the next character
- - x += glyph.advance;
- + x += static_cast<float>(glyph.advance);
- }
- // If we're using the underlined style, add the last line
- diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp
- index 322f18e..1097f90 100644
- --- a/src/SFML/Graphics/Texture.cpp
- +++ b/src/SFML/Graphics/Texture.cpp
- @@ -485,15 +485,15 @@ void Texture::bind(const Texture* texture, CoordinateType coordinateType)
- // setup scale factors that convert the range [0 .. size] to [0 .. 1]
- if (coordinateType == Pixels)
- {
- - matrix[0] = 1.f / texture->m_actualSize.x;
- - matrix[5] = 1.f / texture->m_actualSize.y;
- + matrix[0] = 1.f / static_cast<float>(texture->m_actualSize.x);
- + matrix[5] = 1.f / static_cast<float>(texture->m_actualSize.y);
- }
- // If pixels are flipped we must invert the Y axis
- if (texture->m_pixelsFlipped)
- {
- matrix[5] = -matrix[5];
- - matrix[13] = static_cast<float>(texture->m_size.y) / texture->m_actualSize.y;
- + matrix[13] = static_cast<float>(texture->m_size.y) / static_cast<float>(texture->m_actualSize.y);
- }
- // Load the matrix
- diff --git a/src/SFML/Graphics/Transform.cpp b/src/SFML/Graphics/Transform.cpp
- index 6da0b51..10049cb 100644
- --- a/src/SFML/Graphics/Transform.cpp
- +++ b/src/SFML/Graphics/Transform.cpp
- @@ -27,6 +27,7 @@
- ////////////////////////////////////////////////////////////
- #include <SFML/Graphics/Transform.hpp>
- #include <cmath>
- +#include <limits>
- namespace sf
- @@ -75,7 +76,8 @@ Transform Transform::getInverse() const
- // Compute the inverse if the determinant is not zero
- // (don't use an epsilon because the determinant may *really* be tiny)
- - if (det != 0.f)
- + // (instead, compare against the smallest representable positive value)
- + if (std::abs(det) >= std::numeric_limits<float>::min())
- {
- return Transform( (m_matrix[15] * m_matrix[5] - m_matrix[7] * m_matrix[13]) / det,
- -(m_matrix[15] * m_matrix[4] - m_matrix[7] * m_matrix[12]) / det,
- diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp
- index 079e655..40089ae 100644
- --- a/src/SFML/Network/Ftp.cpp
- +++ b/src/SFML/Network/Ftp.cpp
- @@ -546,7 +546,7 @@ Ftp::Response Ftp::DataChannel::open(Ftp::TransferMode mode)
- // Extract the current number
- while (isdigit(str[index]))
- {
- - data[i] = data[i] * 10 + (str[index] - '0');
- + data[i] = static_cast<Uint8>(data[i] * 10 + (str[index] - '0'));
- index++;
- }
- @@ -555,7 +555,7 @@ Ftp::Response Ftp::DataChannel::open(Ftp::TransferMode mode)
- }
- // Reconstruct connection port and address
- - unsigned short port = data[4] * 256 + data[5];
- + unsigned short port = static_cast<unsigned short>(data[4] * 256 + data[5]);
- IpAddress address(static_cast<Uint8>(data[0]),
- static_cast<Uint8>(data[1]),
- static_cast<Uint8>(data[2]),
- diff --git a/src/SFML/System/Time.cpp b/src/SFML/System/Time.cpp
- index b41ae9d..1e6fb0c 100644
- --- a/src/SFML/System/Time.cpp
- +++ b/src/SFML/System/Time.cpp
- @@ -44,7 +44,7 @@ m_microseconds(0)
- ////////////////////////////////////////////////////////////
- float Time::asSeconds() const
- {
- - return m_microseconds / 1000000.f;
- + return static_cast<float>(m_microseconds) / 1000000.f;
- }
- diff --git a/src/SFML/Window/Win32/InputImpl.cpp b/src/SFML/Window/Win32/InputImpl.cpp
- index f38ada7..1f2bc8e 100644
- --- a/src/SFML/Window/Win32/InputImpl.cpp
- +++ b/src/SFML/Window/Win32/InputImpl.cpp
- @@ -157,7 +157,7 @@ bool InputImpl::isKeyPressed(Keyboard::Key key)
- ////////////////////////////////////////////////////////////
- -void InputImpl::setVirtualKeyboardVisible(bool visible)
- +void InputImpl::setVirtualKeyboardVisible(bool /*visible*/)
- {
- // Not applicable
- }
- diff --git a/src/SFML/Window/Win32/JoystickImpl.cpp b/src/SFML/Window/Win32/JoystickImpl.cpp
- index 7f2bec2..3c86d55 100644
- --- a/src/SFML/Window/Win32/JoystickImpl.cpp
- +++ b/src/SFML/Window/Win32/JoystickImpl.cpp
- @@ -156,17 +156,17 @@ JoystickState JoystickImpl::update()
- state.connected = true;
- // Axes
- - state.axes[Joystick::X] = (pos.dwXpos - (m_caps.wXmax + m_caps.wXmin) / 2.f) * 200.f / (m_caps.wXmax - m_caps.wXmin);
- - state.axes[Joystick::Y] = (pos.dwYpos - (m_caps.wYmax + m_caps.wYmin) / 2.f) * 200.f / (m_caps.wYmax - m_caps.wYmin);
- - state.axes[Joystick::Z] = (pos.dwZpos - (m_caps.wZmax + m_caps.wZmin) / 2.f) * 200.f / (m_caps.wZmax - m_caps.wZmin);
- - state.axes[Joystick::R] = (pos.dwRpos - (m_caps.wRmax + m_caps.wRmin) / 2.f) * 200.f / (m_caps.wRmax - m_caps.wRmin);
- - state.axes[Joystick::U] = (pos.dwUpos - (m_caps.wUmax + m_caps.wUmin) / 2.f) * 200.f / (m_caps.wUmax - m_caps.wUmin);
- - state.axes[Joystick::V] = (pos.dwVpos - (m_caps.wVmax + m_caps.wVmin) / 2.f) * 200.f / (m_caps.wVmax - m_caps.wVmin);
- + state.axes[Joystick::X] = (static_cast<float>(pos.dwXpos - (m_caps.wXmax + m_caps.wXmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wXmax - m_caps.wXmin);
- + state.axes[Joystick::Y] = (static_cast<float>(pos.dwYpos - (m_caps.wYmax + m_caps.wYmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wYmax - m_caps.wYmin);
- + state.axes[Joystick::Z] = (static_cast<float>(pos.dwZpos - (m_caps.wZmax + m_caps.wZmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wZmax - m_caps.wZmin);
- + state.axes[Joystick::R] = (static_cast<float>(pos.dwRpos - (m_caps.wRmax + m_caps.wRmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wRmax - m_caps.wRmin);
- + state.axes[Joystick::U] = (static_cast<float>(pos.dwUpos - (m_caps.wUmax + m_caps.wUmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wUmax - m_caps.wUmin);
- + state.axes[Joystick::V] = (static_cast<float>(pos.dwVpos - (m_caps.wVmax + m_caps.wVmin)) / 2.f) * 200.f / static_cast<float>(m_caps.wVmax - m_caps.wVmin);
- // Special case for POV, it is given as an angle
- if (pos.dwPOV != 0xFFFF)
- {
- - float angle = pos.dwPOV / 18000.f * 3.141592654f;
- + float angle = static_cast<float>(pos.dwPOV) / 18000.f * 3.141592654f;
- state.axes[Joystick::PovX] = std::sin(angle) * 100;
- state.axes[Joystick::PovY] = std::cos(angle) * 100;
- }
- diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp
- index 658c7ff..ce8638f 100644
- --- a/src/SFML/Window/Window.cpp
- +++ b/src/SFML/Window/Window.cpp
- @@ -299,7 +299,7 @@ void Window::setKeyRepeatEnabled(bool enabled)
- void Window::setFramerateLimit(unsigned int limit)
- {
- if (limit > 0)
- - m_frameTimeLimit = seconds(1.f / limit);
- + m_frameTimeLimit = seconds(1.f / static_cast<float>(limit));
- else
- m_frameTimeLimit = Time::Zero;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement