From 90ebf68ba39ae0b657d768f632edb57f9ddeb540 Mon Sep 17 00:00:00 2001 From: binary1248 Date: Fri, 6 Oct 2023 15:59:27 +0200 Subject: [PATCH] Added GitHub Actions jobs to build with OpenGL ES on Linux GCC. --- .github/workflows/ci.yml | 6 ++++ src/SFML/Graphics/RenderTextureImplFBO.cpp | 2 +- src/SFML/Graphics/Texture.cpp | 41 +++++++++++++--------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b0144955..0acded1c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,12 @@ jobs: config: { name: Static DRM, flags: -GNinja -DSFML_USE_DRM=TRUE -DSFML_RUN_DISPLAY_TESTS=FALSE } - platform: { name: Linux GCC, os: ubuntu-22.04 } config: { name: Shared DRM, flags: -GNinja -DBUILD_SHARED_LIBS=TRUE -DSFML_USE_DRM=TRUE -DSFML_RUN_DISPLAY_TESTS=FALSE } + - platform: { name: Linux GCC, os: ubuntu-22.04 } + config: { name: OpenGL ES, flags: -GNinja -DSFML_OPENGL_ES=ON -DSFML_RUN_DISPLAY_TESTS=ON } + type: { name: Release } + - platform: { name: Linux GCC, os: ubuntu-22.04 } + config: { name: OpenGL ES, flags: -GNinja -DSFML_OPENGL_ES=ON -DSFML_RUN_DISPLAY_TESTS=ON } + type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE } - platform: { name: macOS , os: macos-12 } config: { name: System Deps, flags: -GNinja -DBUILD_SHARED_LIBS=TRUE -DSFML_USE_SYSTEM_DEPS=TRUE } steps: diff --git a/src/SFML/Graphics/RenderTextureImplFBO.cpp b/src/SFML/Graphics/RenderTextureImplFBO.cpp index afb9b1085..d9fbf8685 100644 --- a/src/SFML/Graphics/RenderTextureImplFBO.cpp +++ b/src/SFML/Graphics/RenderTextureImplFBO.cpp @@ -341,7 +341,7 @@ bool RenderTextureImplFBO::create(const Vector2u& size, unsigned int textureId, 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 1111fa050..0e9575c18 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -231,6 +231,12 @@ bool Texture::create(const Vector2u& size) m_sRgb = false; } +#ifndef SFML_OPENGL_ES + const GLint textureWrapParam = m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP); +#else + const GLint textureWrapParam = m_isRepeated ? GL_REPEAT : GLEXT_GL_CLAMP_TO_EDGE; +#endif + // Initialize the texture glCheck(glBindTexture(GL_TEXTURE_2D, m_texture)); glCheck(glTexImage2D(GL_TEXTURE_2D, @@ -242,12 +248,8 @@ bool Texture::create(const Vector2u& size) GL_RGBA, GL_UNSIGNED_BYTE, nullptr)); - glCheck(glTexParameteri(GL_TEXTURE_2D, - GL_TEXTURE_WRAP_S, - m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP))); - glCheck(glTexParameteri(GL_TEXTURE_2D, - GL_TEXTURE_WRAP_T, - m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP))); + glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureWrapParam)); + glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureWrapParam)); glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST)); glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST)); m_cacheId = TextureImpl::getUniqueId(); @@ -388,10 +390,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.data())); + glCheck(glReadPixels(0, + 0, + static_cast(m_size.x), + static_cast(m_size.y), + GL_RGBA, + GL_UNSIGNED_BYTE, + pixels.data())); glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer)); - glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, previousFrameBuffer)); + glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, static_cast(previousFrameBuffer))); } #else @@ -745,15 +753,16 @@ void Texture::setRepeated(bool repeated) } } +#ifndef SFML_OPENGL_ES + const GLint textureWrapParam = m_isRepeated ? GL_REPEAT + : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP); +#else + const GLint textureWrapParam = m_isRepeated ? GL_REPEAT : GLEXT_GL_CLAMP_TO_EDGE; +#endif + glCheck(glBindTexture(GL_TEXTURE_2D, m_texture)); - glCheck( - glTexParameteri(GL_TEXTURE_2D, - GL_TEXTURE_WRAP_S, - m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP))); - glCheck( - glTexParameteri(GL_TEXTURE_2D, - GL_TEXTURE_WRAP_T, - m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP))); + glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textureWrapParam)); + glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textureWrapParam)); } } }