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.
This commit is contained in:
Chris Thrasher 2023-10-23 18:20:08 -05:00
parent 13c8a1de4e
commit e2e0f36d98
4 changed files with 15 additions and 3 deletions

View File

@ -16,6 +16,7 @@ jobs:
- { name: Windows VS2022 Clang, os: windows-2022, flags: -T ClangCL } - { name: Windows VS2022 Clang, os: windows-2022, flags: -T ClangCL }
- { name: Linux GCC, os: ubuntu-20.04 } - { 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 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 } - { name: MacOS XCode, os: macos-11 }
config: config:
- { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE } - { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE }

View File

@ -24,6 +24,7 @@ Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.6.1
**Bugfixes** **Bugfixes**
- Ensure OpenGL extensions are loaded before querying maximum texture size (#2603) - Ensure OpenGL extensions are loaded before querying maximum texture size (#2603)
- Fix warnings in Linux OpenGL ES codepaths (#2747)
### Audio ### Audio

View File

@ -387,7 +387,7 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig
if (createFrameBuffer()) if (createFrameBuffer())
{ {
// Restore previously bound framebuffer // Restore previously bound framebuffer
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer)); glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, static_cast<GLuint>(frameBuffer)));
return true; return true;
} }

View File

@ -38,6 +38,10 @@
#include <cstring> #include <cstring>
#include <climits> #include <climits>
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wduplicated-branches"
#endif
namespace namespace
{ {
@ -346,10 +350,16 @@ Image Texture::copyToImage() const
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer)); glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer));
glCheck(GLEXT_glFramebufferTexture2D(GLEXT_GL_FRAMEBUFFER, GLEXT_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0)); 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<GLsizei>(m_size.x),
static_cast<GLsizei>(m_size.y),
GL_RGBA,
GL_UNSIGNED_BYTE,
&pixels[0]));
glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer)); glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer));
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, previousFrameBuffer)); glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, static_cast<GLuint>(previousFrameBuffer)));
if (m_pixelsFlipped) if (m_pixelsFlipped)
{ {