diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index d9816e1204..7d979f921c 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -153,7 +153,6 @@ void gl_LoadExtensions() { gl.flags|=RFL_FRAMEBUFFER; } - } //========================================================================== diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index d280242e1b..d5346fa7dc 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -41,6 +41,11 @@ struct RenderContext { return glslversion >= 1.3f; } + + bool hasCompatibility() // will return false, once transition to a core profile is possible and a core profile is used. + { + return true; + } }; extern RenderContext gl; diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp index 83a92e0feb..c37e7a90eb 100644 --- a/src/gl/textures/gl_bitmap.cpp +++ b/src/gl/textures/gl_bitmap.cpp @@ -42,6 +42,7 @@ #include "gl/renderer/gl_lightdata.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_bitmap.h" +#include "gl/system/gl_interface.h" //=========================================================================== // @@ -54,7 +55,7 @@ void iCopyColors(unsigned char * pout, const unsigned char * pin, bool alphatex, { int i; - if (!alphatex) + if (!alphatex || gl.version >= 3.3f) // GL 3.3+ uses a GL_R8 texture for alpha textures so the channels can remain as they are. { for(i=0;i 0) diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 7aa8b610c6..a2a83e5db9 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -190,8 +190,26 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i bool deletebuffer=false; bool use_mipmapping = TexFilter[gl_texture_filter].mipmapping; - if (alphatexture) texformat=GL_ALPHA8; - else if (forcenocompression) texformat = GL_RGBA8; + if (alphatexture) + { + // thanks to deprecation and delayed introduction of a suitable replacement feature this has become a bit messy... + if (gl.version >= 3.3f) + { + texformat = GL_R8; + } + else if (gl.version <= 3.0f || gl.hasCompatibility()) + { + texformat = GL_ALPHA8; + } + else + { + texformat = GL_RGBA8; + } + } + else if (forcenocompression) + { + texformat = GL_RGBA8; + } if (glTexID==0) glGenTextures(1,&glTexID); glBindTexture(GL_TEXTURE_2D, glTexID); lastbound[texunit]=glTexID; @@ -238,6 +256,11 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT); + if (alphatexture && gl.version >= 3.3f) + { + static const GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_RED}; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } clampmode = wrapparam==GL_CLAMP? GLT_CLAMPX|GLT_CLAMPY : 0; if (forcenofiltering)