From 43b2e9dc125954a40af8a4dc135a6841b4adabb8 Mon Sep 17 00:00:00 2001 From: binary1248 Date: Wed, 14 Apr 2021 04:15:33 +0200 Subject: [PATCH] Fixed regression introduced in 4fcef89 causing EXT_texture_edge_clamp support to not be considered, added explicit initialization of nbFormats to 0 in WglContext.cpp in order to prevent broken graphics drivers from filling nbFormats with a garbage value. Fixes #1786. --- src/SFML/Graphics/GLExtensions.hpp | 4 ++-- src/SFML/Graphics/Texture.cpp | 2 +- src/SFML/Window/Win32/WglContext.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SFML/Graphics/GLExtensions.hpp b/src/SFML/Graphics/GLExtensions.hpp index dc1218784b..41376a3f9e 100644 --- a/src/SFML/Graphics/GLExtensions.hpp +++ b/src/SFML/Graphics/GLExtensions.hpp @@ -308,6 +308,8 @@ #define GLEXT_geometry_shader4 SF_GLAD_GL_ARB_geometry_shader4 #define GLEXT_GL_GEOMETRY_SHADER GL_GEOMETRY_SHADER_ARB +#endif + // OpenGL Versions #define GLEXT_GL_VERSION_1_0 SF_GLAD_GL_VERSION_1_0 #define GLEXT_GL_VERSION_1_1 SF_GLAD_GL_VERSION_1_1 @@ -329,8 +331,6 @@ #define GLEXT_GL_VERSION_4_5 SF_GLAD_GL_VERSION_4_5 #define GLEXT_GL_VERSION_4_6 SF_GLAD_GL_VERSION_4_6 -#endif - namespace sf { namespace priv diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index a2f157a922..9da32b05b5 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -162,7 +162,7 @@ bool Texture::create(unsigned int width, unsigned int height) // Make sure that the current texture binding will be preserved priv::TextureSaver save; - static bool textureEdgeClamp = GLEXT_texture_edge_clamp; + static bool textureEdgeClamp = GLEXT_texture_edge_clamp || GLEXT_GL_VERSION_1_2 || Context::isExtensionAvailable("GL_EXT_texture_edge_clamp"); if (!m_isRepeated && !textureEdgeClamp) { diff --git a/src/SFML/Window/Win32/WglContext.cpp b/src/SFML/Window/Win32/WglContext.cpp index 916912cbf2..ea8001fc53 100644 --- a/src/SFML/Window/Win32/WglContext.cpp +++ b/src/SFML/Window/Win32/WglContext.cpp @@ -295,7 +295,7 @@ int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPix // Let's check how many formats are supporting our requirements int formats[512]; - UINT nbFormats; + UINT nbFormats = 0; // We must initialize to 0 otherwise broken drivers might fill with garbage in the following call bool isValid = wglChoosePixelFormatARB(deviceContext, intAttributes, NULL, 512, formats, &nbFormats) != FALSE; if (!isValid)