From e2e0f36d985279a8ffdc366551fd67537e9588f5 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 23 Oct 2023 18:20:08 -0500 Subject: [PATCH] Fix warnings in Linux OpenGL ES codepaths Because CI didn't cover this code we didn't know there were warnings in these codepaths to address. Not sure why GCC's -Wduplicated-branches is being emitted or how exactly to fix it. It's easier to simply ignore it in this one particular file. --- .github/workflows/ci.yml | 1 + changelog.md | 1 + src/SFML/Graphics/RenderTextureImplFBO.cpp | 2 +- src/SFML/Graphics/Texture.cpp | 14 ++++++++++++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30755fe3d..6f0841e4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: - { name: Windows VS2022 Clang, os: windows-2022, flags: -T ClangCL } - { name: Linux GCC, os: ubuntu-20.04 } - { name: Linux Clang, os: ubuntu-20.04, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ } + - { name: Linux GCC OpenGL ES, os: ubuntu-20.04, flags: -DSFML_OPENGL_ES=ON } - { name: MacOS XCode, os: macos-11 } config: - { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE } diff --git a/changelog.md b/changelog.md index 1b64ba39b..adf5f69cb 100644 --- a/changelog.md +++ b/changelog.md @@ -24,6 +24,7 @@ Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.6.1 **Bugfixes** - Ensure OpenGL extensions are loaded before querying maximum texture size (#2603) +- Fix warnings in Linux OpenGL ES codepaths (#2747) ### Audio diff --git a/src/SFML/Graphics/RenderTextureImplFBO.cpp b/src/SFML/Graphics/RenderTextureImplFBO.cpp index eab97150a..295577b4a 100644 --- a/src/SFML/Graphics/RenderTextureImplFBO.cpp +++ b/src/SFML/Graphics/RenderTextureImplFBO.cpp @@ -387,7 +387,7 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig if (createFrameBuffer()) { // Restore previously bound framebuffer - glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer)); + glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, static_cast(frameBuffer))); return true; } diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index a6648bef7..1600c3b4b 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -38,6 +38,10 @@ #include #include +#if defined(__GNUC__) + #pragma GCC diagnostic ignored "-Wduplicated-branches" +#endif + namespace { @@ -346,10 +350,16 @@ Image Texture::copyToImage() const glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer)); glCheck(GLEXT_glFramebufferTexture2D(GLEXT_GL_FRAMEBUFFER, GLEXT_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0)); - glCheck(glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0])); + glCheck(glReadPixels(0, + 0, + static_cast(m_size.x), + static_cast(m_size.y), + GL_RGBA, + GL_UNSIGNED_BYTE, + &pixels[0])); glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer)); - glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, previousFrameBuffer)); + glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, static_cast(previousFrameBuffer))); if (m_pixelsFlipped) {