From f99882c61cc2c809418eb86f0f8ff535efdd8991 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sun, 18 Oct 2015 11:16:54 +0200 Subject: [PATCH] gsdx-ogl: keep gl_ActiveTexture & gl_BlendColor (fix MS compilation) It seems openGL ABI isn't exactly the same between Windows and my PC. --- plugins/GSdx/GLLoader.cpp | 5 ++++- plugins/GSdx/GLLoader.h | 6 ++++++ plugins/GSdx/GSDeviceOGL.cpp | 2 +- plugins/GSdx/GSWnd.cpp | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/GSdx/GLLoader.cpp b/plugins/GSdx/GLLoader.cpp index d7c3440325..102689d422 100644 --- a/plugins/GSdx/GLLoader.cpp +++ b/plugins/GSdx/GLLoader.cpp @@ -22,6 +22,9 @@ #include "GLLoader.h" #include "GSdx.h" +PFNGLACTIVETEXTUREPROC gl_ActiveTexture = NULL; +PFNGLBLENDCOLORPROC gl_BlendColor = NULL; + PFNGLATTACHSHADERPROC glAttachShader = NULL; PFNGLBINDBUFFERPROC glBindBuffer = NULL; PFNGLBINDBUFFERBASEPROC glBindBufferBase = NULL; @@ -150,7 +153,7 @@ PFNGLBLENDCOLORPROC glBlendColor = NUL namespace Emulate_DSA { // Texture entry point void APIENTRY BindTextureUnit(GLuint unit, GLuint texture) { - glActiveTexture(GL_TEXTURE0 + unit); + gl_ActiveTexture(GL_TEXTURE0 + unit); glBindTexture(GL_TEXTURE_2D, texture); } diff --git a/plugins/GSdx/GLLoader.h b/plugins/GSdx/GLLoader.h index a54009237e..e4a97e58cb 100644 --- a/plugins/GSdx/GLLoader.h +++ b/plugins/GSdx/GLLoader.h @@ -183,6 +183,12 @@ typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); #endif /* GL_VERSION_4_5 */ +// Note: glActiveTexture & glBlendColor aren't included in the win GL ABI. +// (maybe gl.h is outdated, or my setup is wrong) +// Anyway, let's just keep the mangled function pointer for those 2 functions. +extern PFNGLACTIVETEXTUREPROC gl_ActiveTexture; +extern PFNGLBLENDCOLORPROC gl_BlendColor; + extern PFNGLATTACHSHADERPROC glAttachShader; extern PFNGLBINDBUFFERPROC glBindBuffer; extern PFNGLBINDBUFFERBASEPROC glBindBufferBase; diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 68e409d472..dc7cfd8237 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -1356,7 +1356,7 @@ void GSDeviceOGL::OMSetBlendState(uint8 blend_index, uint8 blend_factor, bool is if (is_blend_constant && GLState::bf != blend_factor) { GLState::bf = blend_factor; float bf = (float)blend_factor / 128.0f; - glBlendColor(bf, bf, bf, bf); + gl_BlendColor(bf, bf, bf, bf); } const OGLBlend& b = m_blendMapOGL[blend_index]; diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 11b4f8517e..f0af677130 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -25,6 +25,9 @@ void GSWndGL::PopulateGlFunction() { + *(void**)&(gl_ActiveTexture) = GetProcAddress("glActiveTexture"); + *(void**)&(gl_BlendColor) = GetProcAddress("glBlendColor"); + *(void**)&(glBlendEquationSeparate) = GetProcAddress("glBlendEquationSeparate"); *(void**)&(glBlendFuncSeparate) = GetProcAddress("glBlendFuncSeparate"); *(void**)&(glAttachShader) = GetProcAddress("glAttachShader");