Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed texture edge clamp extension not being detected properly #882

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/SFML/Graphics/GLExtensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
// Core since 1.0
#define GLEXT_multitexture true
#define GLEXT_texture_edge_clamp true
#define GLEXT_EXT_texture_edge_clamp true
#define GLEXT_blend_minmax true
#define GLEXT_glClientActiveTexture glClientActiveTexture
#define GLEXT_glActiveTexture glActiveTexture
Expand Down Expand Up @@ -130,6 +131,9 @@
#define GLEXT_texture_edge_clamp sfogl_ext_SGIS_texture_edge_clamp
#define GLEXT_GL_CLAMP_TO_EDGE GL_CLAMP_TO_EDGE_SGIS

// Core since 1.2 - EXT_texture_edge_clamp
#define GLEXT_EXT_texture_edge_clamp sfogl_ext_EXT_texture_edge_clamp

// Core since 1.2 - EXT_blend_minmax
#define GLEXT_blend_minmax sfogl_ext_EXT_blend_minmax
#define GLEXT_glBlendEquation glBlendEquationEXT
Expand Down
1 change: 1 addition & 0 deletions src/SFML/Graphics/GLExtensions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// lua LoadGen.lua -style=pointer_c -spec=gl -version=1.1 -indent=space -prefix=sf -extfile=GLExtensions.txt GLLoader

SGIS_texture_edge_clamp
//EXT_texture_edge_clamp
EXT_blend_minmax
EXT_blend_subtract
ARB_multitexture
Expand Down
7 changes: 5 additions & 2 deletions src/SFML/Graphics/GLLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static sf::GlFunctionPointer IntGetProcAddress(const char* name)
}

int sfogl_ext_SGIS_texture_edge_clamp = sfogl_LOAD_FAILED;
int sfogl_ext_EXT_texture_edge_clamp = sfogl_LOAD_FAILED;
int sfogl_ext_EXT_blend_minmax = sfogl_LOAD_FAILED;
int sfogl_ext_EXT_blend_subtract = sfogl_LOAD_FAILED;
int sfogl_ext_ARB_multitexture = sfogl_LOAD_FAILED;
Expand Down Expand Up @@ -317,8 +318,9 @@ typedef struct sfogl_StrToExtMap_s
PFN_LOADFUNCPOINTERS LoadExtension;
} sfogl_StrToExtMap;

static sfogl_StrToExtMap ExtensionMap[12] = {
static sfogl_StrToExtMap ExtensionMap[13] = {
{"GL_SGIS_texture_edge_clamp", &sfogl_ext_SGIS_texture_edge_clamp, NULL},
{"GL_EXT_texture_edge_clamp", &sfogl_ext_EXT_texture_edge_clamp, NULL},
{"GL_EXT_blend_minmax", &sfogl_ext_EXT_blend_minmax, Load_EXT_blend_minmax},
{"GL_EXT_blend_subtract", &sfogl_ext_EXT_blend_subtract, NULL},
{"GL_ARB_multitexture", &sfogl_ext_ARB_multitexture, Load_ARB_multitexture},
Expand All @@ -332,7 +334,7 @@ static sfogl_StrToExtMap ExtensionMap[12] = {
{"GL_EXT_framebuffer_object", &sfogl_ext_EXT_framebuffer_object, Load_EXT_framebuffer_object}
};

static int g_extensionMapSize = 12;
static int g_extensionMapSize = 13;

static sfogl_StrToExtMap *FindExtEntry(const char *extensionName)
{
Expand All @@ -350,6 +352,7 @@ static sfogl_StrToExtMap *FindExtEntry(const char *extensionName)
static void ClearExtensionVars()
{
sfogl_ext_SGIS_texture_edge_clamp = sfogl_LOAD_FAILED;
sfogl_ext_EXT_texture_edge_clamp = sfogl_LOAD_FAILED;
sfogl_ext_EXT_blend_minmax = sfogl_LOAD_FAILED;
sfogl_ext_EXT_blend_subtract = sfogl_LOAD_FAILED;
sfogl_ext_ARB_multitexture = sfogl_LOAD_FAILED;
Expand Down
3 changes: 3 additions & 0 deletions src/SFML/Graphics/GLLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ extern "C" {
#endif /*__cplusplus*/

extern int sfogl_ext_SGIS_texture_edge_clamp;
extern int sfogl_ext_EXT_texture_edge_clamp;
extern int sfogl_ext_EXT_blend_minmax;
extern int sfogl_ext_EXT_blend_subtract;
extern int sfogl_ext_ARB_multitexture;
Expand All @@ -188,6 +189,8 @@ extern int sfogl_ext_EXT_framebuffer_object;

#define GL_CLAMP_TO_EDGE_SGIS 0x812F

#define GL_CLAMP_TO_EDGE_EXT 0x812F

#define GL_BLEND_EQUATION_EXT 0x8009
#define GL_FUNC_ADD_EXT 0x8006
#define GL_MAX_EXT 0x8008
Expand Down
16 changes: 10 additions & 6 deletions src/SFML/Graphics/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ bool Texture::create(unsigned int width, unsigned int height)
// Make sure that the current texture binding will be preserved
priv::TextureSaver save;

if (!m_isRepeated && !GLEXT_texture_edge_clamp)
static bool textureEdgeClamp = GLEXT_texture_edge_clamp || GLEXT_EXT_texture_edge_clamp;

if (!m_isRepeated && !textureEdgeClamp)
{
static bool warned = false;

Expand All @@ -175,8 +177,8 @@ bool Texture::create(unsigned int width, unsigned int height)
// Initialize the texture
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
glCheck(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_actualSize.x, m_actualSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_isRepeated ? GL_REPEAT : (GLEXT_texture_edge_clamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP)));
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_isRepeated ? GL_REPEAT : (GLEXT_texture_edge_clamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP)));
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_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 = getUniqueId();
Expand Down Expand Up @@ -480,7 +482,9 @@ void Texture::setRepeated(bool repeated)
// Make sure that the current texture binding will be preserved
priv::TextureSaver save;

if (!m_isRepeated && !GLEXT_texture_edge_clamp)
static bool textureEdgeClamp = GLEXT_texture_edge_clamp || GLEXT_EXT_texture_edge_clamp;

if (!m_isRepeated && !textureEdgeClamp)
{
static bool warned = false;

Expand All @@ -495,8 +499,8 @@ void Texture::setRepeated(bool repeated)
}

glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_isRepeated ? GL_REPEAT : (GLEXT_texture_edge_clamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP)));
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_isRepeated ? GL_REPEAT : (GLEXT_texture_edge_clamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP)));
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)));
}
}
}
Expand Down