From 725ec3518827c877a26b43f1ee88a40e1e1eac4a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 1 Apr 2014 22:03:21 +0200 Subject: [PATCH] GL3: Use core profile texture formats --HG-- branch : opengl3 --- .../driver/opengl3/driver_opengl_texture.cpp | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_texture.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_texture.cpp index d6a5519ae..e3b01dcd1 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_texture.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_texture.cpp @@ -335,9 +335,9 @@ GLint CDriverGL3::getGlTextureFormat(ITexture& tex, bool &compressed) case ITexture::RGBA5551: return GL_RGB5_A1; case ITexture::RGB888: return GL_RGB8; case ITexture::RGB565: return GL_RGB5; - case ITexture::Luminance: return GL_LUMINANCE8; - case ITexture::Alpha: return GL_ALPHA8; - case ITexture::AlphaLuminance: return GL_LUMINANCE8_ALPHA8; + case ITexture::Luminance: return GL_R8; // GL_LUMINANCE8; + case ITexture::Alpha: return GL_R8; // GL_ALPHA8; + case ITexture::AlphaLuminance: return GL_RG8; // GL_LUMINANCE8_ALPHA8; case ITexture::DsDt: { return GL_RG8; @@ -363,9 +363,9 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt) { switch(tex.getPixelFormat()) { - case CBitmap::Alpha: return GL_ALPHA; - case CBitmap::AlphaLuminance: return GL_LUMINANCE_ALPHA; - case CBitmap::Luminance: return GL_LUMINANCE; + case CBitmap::Alpha: return GL_RED; // GL_ALPHA; + case CBitmap::AlphaLuminance: return GL_RG; // GL_LUMINANCE_ALPHA; + case CBitmap::Luminance: return GL_RED; // GL_LUMINANCE; default: break; } } @@ -659,6 +659,23 @@ void CDriverGL3::setupTextureBasicParameters(ITexture &tex) if (_AnisotropicFilter > 1.f && gltext->MinFilter > ITexture::NearestMipMapLinear) glTexParameteri(gltext->TextureMode, GL_TEXTURE_MAX_ANISOTROPY_EXT, _AnisotropicFilter); } + switch (tex.getUploadFormat()) + { + case ITexture::Luminance: + case ITexture::Alpha: + { + static const GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_RED }; + glTexParameteriv(gltext->TextureMode, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + break; + } + case ITexture::AlphaLuminance: + case ITexture::DsDt: + { + static const GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_RED, GL_GREEN }; + glTexParameteriv(gltext->TextureMode, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + break; + } + } // tex.clearFilterOrWrapModeTouched(); }