From 52e5d96389879b6c88ec329a1f79bf6f93fc22ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Fri, 28 Jul 2023 07:58:58 -0400 Subject: [PATCH 1/3] refactor: fix conversion warnings on Clang --- imgui-SFML.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/imgui-SFML.cpp b/imgui-SFML.cpp index 62bb49f..f8424a9 100644 --- a/imgui-SFML.cpp +++ b/imgui-SFML.cpp @@ -568,10 +568,12 @@ void ProcessEvent(const sf::Event& event) { if (s_currWindowCtx->windowHasFocus) { switch (event.type) { case sf::Event::Resized: - io.DisplaySize = ImVec2(event.size.width, event.size.height); + io.DisplaySize = + ImVec2(static_cast(event.size.width), static_cast(event.size.height)); break; case sf::Event::MouseMoved: - io.AddMousePosEvent(event.mouseMove.x, event.mouseMove.y); + io.AddMousePosEvent(static_cast(event.mouseMove.x), + static_cast(event.mouseMove.y)); s_currWindowCtx->mouseMoved = true; break; case sf::Event::MouseButtonPressed: // fall-through @@ -800,7 +802,8 @@ bool UpdateFontTexture() { sf::Texture& texture = s_currWindowCtx->fontTexture; #if SFML_VERSION_MAJOR >= 3 - if (!texture.create(sf::Vector2u(width, height))) { + if (!texture.create( + sf::Vector2u(static_cast(width), static_cast(height)))) { return false; } #else @@ -988,7 +991,7 @@ void Image(const sf::Sprite& sprite, const sf::Vector2f& size, const sf::Color& const sf::Texture& texture = *texturePtr; sf::Vector2f textureSize = static_cast(texture.getSize()); - const sf::IntRect& textureRect = sprite.getTextureRect(); + sf::FloatRect textureRect = static_cast(sprite.getTextureRect()); ImVec2 uv0(textureRect.left / textureSize.x, textureRect.top / textureSize.y); ImVec2 uv1((textureRect.left + textureRect.width) / textureSize.x, (textureRect.top + textureRect.height) / textureSize.y); @@ -1053,7 +1056,7 @@ bool ImageButton(const sf::Sprite& sprite, const sf::Vector2f& size, const int f const sf::Texture& texture = *texturePtr; sf::Vector2f textureSize = static_cast(texture.getSize()); - const sf::IntRect& textureRect = sprite.getTextureRect(); + sf::FloatRect textureRect = static_cast(sprite.getTextureRect()); ImVec2 uv0(textureRect.left / textureSize.x, textureRect.top / textureSize.y); ImVec2 uv1((textureRect.left + textureRect.width) / textureSize.x, (textureRect.top + textureRect.height) / textureSize.y); @@ -1239,10 +1242,11 @@ void RenderDrawLists(ImDrawData* draw_data) { clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x; clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y; - if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && + if (clip_rect.x < static_cast(fb_width) && + clip_rect.y < static_cast(fb_height) && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f) { // Apply scissor/clipping rectangle - glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), + glScissor((int)clip_rect.x, (int)(static_cast(fb_height) - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y)); // Bind texture, Draw @@ -1272,7 +1276,7 @@ void RenderDrawLists(ImDrawData* draw_data) { (GLsizei)last_viewport[3]); glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]); - glShadeModel(last_shade_model); + glShadeModel((GLenum)last_shade_model); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, last_tex_env_mode); #ifdef GL_VERSION_ES_CL_1_1 @@ -1328,7 +1332,8 @@ void updateJoystickButtonState(ImGuiIO& io) { for (int i = 0; i < static_cast(sf::Joystick::ButtonCount); ++i) { ImGuiKey key = s_currWindowCtx->joystickMapping[i]; if (key != ImGuiKey_None) { - bool isPressed = sf::Joystick::isButtonPressed(s_currWindowCtx->joystickId, i); + bool isPressed = sf::Joystick::isButtonPressed(s_currWindowCtx->joystickId, + static_cast(i)); if (s_currWindowCtx->windowHasFocus || !isPressed) { io.AddKeyEvent(key, isPressed); } From f2b20b62f6a76466f5c014aade5aa4fd54bed5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Sun, 30 Jul 2023 17:59:15 -0400 Subject: [PATCH 2/3] refactor: use direct construction --- imgui-SFML.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imgui-SFML.cpp b/imgui-SFML.cpp index f8424a9..3d85156 100644 --- a/imgui-SFML.cpp +++ b/imgui-SFML.cpp @@ -990,8 +990,8 @@ void Image(const sf::Sprite& sprite, const sf::Vector2f& size, const sf::Color& } const sf::Texture& texture = *texturePtr; - sf::Vector2f textureSize = static_cast(texture.getSize()); - sf::FloatRect textureRect = static_cast(sprite.getTextureRect()); + const sf::Vector2f textureSize(texture.getSize()); + const sf::FloatRect textureRect(sprite.getTextureRect()); ImVec2 uv0(textureRect.left / textureSize.x, textureRect.top / textureSize.y); ImVec2 uv1((textureRect.left + textureRect.width) / textureSize.x, (textureRect.top + textureRect.height) / textureSize.y); @@ -1055,8 +1055,8 @@ bool ImageButton(const sf::Sprite& sprite, const sf::Vector2f& size, const int f } const sf::Texture& texture = *texturePtr; - sf::Vector2f textureSize = static_cast(texture.getSize()); - sf::FloatRect textureRect = static_cast(sprite.getTextureRect()); + const sf::Vector2f textureSize(texture.getSize()); + const sf::FloatRect textureRect(sprite.getTextureRect()); ImVec2 uv0(textureRect.left / textureSize.x, textureRect.top / textureSize.y); ImVec2 uv1((textureRect.left + textureRect.width) / textureSize.x, (textureRect.top + textureRect.height) / textureSize.y); From b5a390f9af8df7ac759fe51f41b4b1dc1868c6f0 Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Tue, 8 Aug 2023 20:06:10 +0200 Subject: [PATCH 3/3] Another fix --- imgui-SFML.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui-SFML.cpp b/imgui-SFML.cpp index 9555fd9..d9c4f52 100644 --- a/imgui-SFML.cpp +++ b/imgui-SFML.cpp @@ -811,7 +811,7 @@ bool UpdateFontTexture() { return false; } #else - if (!texture.create(width, height)) { + if (!texture.create(static_cast(width), static_cast(height))) { return false; } #endif