From 08023309855c3e3bf5df68e0e2874ac235f214a1 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 30 Mar 2014 15:06:52 +0200 Subject: [PATCH] GL3: Remove GL_ARB_texture_cube_map --HG-- branch : opengl3 --- .../src/3d/driver/opengl3/driver_opengl.cpp | 11 +-- .../opengl3/driver_opengl_extension.cpp | 13 --- .../driver/opengl3/driver_opengl_extension.h | 3 - .../driver/opengl3/driver_opengl_material.cpp | 5 +- .../driver/opengl3/driver_opengl_states.cpp | 7 +- .../3d/driver/opengl3/driver_opengl_states.h | 5 +- .../driver/opengl3/driver_opengl_texture.cpp | 96 ++++++++----------- 7 files changed, 51 insertions(+), 89 deletions(-) diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl.cpp index 2820b4bb7..af006527e 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl.cpp @@ -409,7 +409,7 @@ bool CDriverGL3::setupDisplay() _UserLightEnable[i]= false; // init _DriverGLStates - _DriverGLStates.init(_Extensions.ARBTextureCubeMap, (_Extensions.NVTextureRectangle || _Extensions.EXTTextureRectangle || _Extensions.ARBTextureRectangle), _MaxDriverLight); + _DriverGLStates.init((_Extensions.NVTextureRectangle || _Extensions.EXTTextureRectangle || _Extensions.ARBTextureRectangle), _MaxDriverLight); // Init OpenGL/Driver defaults. //============================= @@ -999,11 +999,8 @@ void CDriverGL3::copyFrameBufferToTexture(ITexture *tex, _DriverGLStates.setTextureMode(textureMode); if (tex->isTextureCube()) { - if (_Extensions.ARBTextureCubeMap) - { - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); - glCopyTexSubImage2D(NLCubeFaceToGLCubeFace[cubeFace], level, offsetx, offsety, x, y, width, height); - } + glBindTexture(GL_TEXTURE_CUBE_MAP, gltext->ID); + glCopyTexSubImage2D(NLCubeFaceToGLCubeFace[cubeFace], level, offsetx, offsety, x, y, width, height); } else { @@ -1631,7 +1628,7 @@ void CDriverGL3::checkTextureOn() const GLboolean flagCM; GLboolean flagTR; glGetBooleanv(GL_TEXTURE_2D, &flag2D); - glGetBooleanv(GL_TEXTURE_CUBE_MAP_ARB, &flagCM); + glGetBooleanv(GL_TEXTURE_CUBE_MAP, &flagCM); glGetBooleanv(GL_TEXTURE_RECTANGLE_NV, &flagTR); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp index 6a6b8a5e1..54329e717 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_extension.cpp @@ -519,16 +519,6 @@ static bool setupEXTTextureCompressionS3TC(const char *glext) return true; } -// ********************************* -static bool setupARBTextureCubeMap(const char *glext) -{ - H_AUTO_OGL(setupARBTextureCubeMap); - - CHECK_EXT("GL_ARB_texture_cube_map"); - - return true; -} - // ********************************* static bool setupEXTSecondaryColor(const char *glext) { @@ -878,9 +868,6 @@ void registerGlExtensions(CGlExtensions &ext) // Check ARBMultisample ext.ARBMultisample = setupARBMultisample(glext); - // Check for cube mapping - ext.ARBTextureCubeMap = setupARBTextureCubeMap(glext); - // Check EXTSecondaryColor ext.EXTSecondaryColor= setupEXTSecondaryColor(glext); diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_extension.h b/code/nel/src/3d/driver/opengl3/driver_opengl_extension.h index f67da18cd..3a8c2c7b9 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_extension.h +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_extension.h @@ -49,7 +49,6 @@ struct CGlExtensions uint NbTextureStages; // Optional Extensions. (old) - bool ARBTextureCubeMap; bool NVTextureRectangle; bool EXTTextureRectangle; bool ARBTextureRectangle; @@ -74,7 +73,6 @@ public: ARBMultiTexture= false; NbTextureStages= 1; EXTTextureCompressionS3TC= false; - ARBTextureCubeMap= false; EXTSecondaryColor= false; WGLARBPBuffer= false; WGLARBPixelFormat= false; @@ -100,7 +98,6 @@ public: result += "\n Texturing: "; result += ARBMultiTexture ? "ARBMultiTexture " : ""; result += EXTTextureCompressionS3TC ? "EXTTextureCompressionS3TC " : ""; - result += ARBTextureCubeMap ? "ARBTextureCubeMap " : ""; result += NVTextureRectangle ? "NVTextureRectangle " : ""; result += EXTTextureRectangle ? "EXTTextureRectangle " : ""; result += ARBTextureRectangle ? "ARBTextureRectangle " : ""; diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp index 9a08b041b..4b9526204 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_material.cpp @@ -94,7 +94,7 @@ static inline void convTexAddr(ITexture *tex, CMaterial::TTexAddressingMode mode static const GLenum glTexCubeAddrModesNV[] = { - GL_NONE, GL_TEXTURE_CUBE_MAP_ARB, + GL_NONE, GL_TEXTURE_CUBE_MAP, GL_PASS_THROUGH_NV, GL_CULL_FRAGMENT_NV, GL_OFFSET_TEXTURE_2D_NV, GL_OFFSET_TEXTURE_2D_SCALE_NV, GL_DEPENDENT_AR_TEXTURE_2D_NV, GL_DEPENDENT_GB_TEXTURE_2D_NV, @@ -1124,9 +1124,6 @@ sint CDriverGL3::beginSpecularMultiPass() // Manage the rare case when the SpecularMap is not provided (fault of graphist). if (mat.getTexture(1)==NULL) return 1; - - if (!_Extensions.ARBTextureCubeMap) - return 1; return 1; } diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp index 10dc2908f..152c18581 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_states.cpp @@ -32,7 +32,6 @@ namespace NLDRIVERGL3 { CDriverGLStates3::CDriverGLStates3() { H_AUTO_OGL(CDriverGLStates3_CDriverGLStates) - _TextureCubeMapSupported= false; _CurrARBVertexBuffer = 0; _DepthRangeNear = 0.f; _DepthRangeFar = 1.f; @@ -43,10 +42,9 @@ CDriverGLStates3::CDriverGLStates3() // *************************************************************************** -void CDriverGLStates3::init(bool supportTextureCubeMap, bool supportTextureRectangle, uint maxLight) +void CDriverGLStates3::init(bool supportTextureRectangle, uint maxLight) { H_AUTO_OGL(CDriverGLStates3_init) - _TextureCubeMapSupported= supportTextureCubeMap; _TextureRectangleSupported= supportTextureRectangle; _MaxDriverLight= maxLight; _MaxDriverLight= std::min(_MaxDriverLight, uint(MaxLight)); @@ -146,8 +144,7 @@ void CDriverGLStates3::forceDefaults(uint nbStages) nglActiveTextureARB(GL_TEXTURE0_ARB+stage); glDisable(GL_TEXTURE_2D); - if (_TextureCubeMapSupported) - glDisable(GL_TEXTURE_CUBE_MAP_ARB); + glDisable(GL_TEXTURE_CUBE_MAP); _TextureMode[stage]= TextureDisabled; diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_states.h b/code/nel/src/3d/driver/opengl3/driver_opengl_states.h index 2e6d83ee2..663fa1f21 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_states.h +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_states.h @@ -36,7 +36,7 @@ namespace NLDRIVERGL3 { - GL_ALPHA_TEST - GL_LIGHTING - GL_LIGHT0 + i ..... - - GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP_ARB/OES. + - GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP/OES. - GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R - GL_COLOR_MATERIAL - GL_FOG @@ -74,7 +74,7 @@ public: /// Constructor. no-op. CDriverGLStates3(); // init. Do it just after setDisplay() - void init(bool supportTextureCubeMap, bool supportTextureRectangle, uint maxLight); + void init(bool supportTextureRectangle, uint maxLight); /// Reset all OpenGL states of interest to default, and update caching. This don't apply to light. void forceDefaults(uint nbTextureStages); @@ -195,7 +195,6 @@ private: float _CurShininess; bool _VertexColorLighted; - bool _TextureCubeMapSupported; bool _TextureRectangleSupported; uint _CurrentActiveTextureARB; TTextureMode _TextureMode[8]; 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 50f4346bc..201105b8f 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_texture.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_texture.cpp @@ -600,12 +600,9 @@ void CDriverGL3::bindTextureWithMode(ITexture &tex) _DriverGLStates.activeTextureARB(0); if (tex.isTextureCube()) { - if (_Extensions.ARBTextureCubeMap) - { - _DriverGLStates.setTextureMode(CDriverGLStates3::TextureCubeMap); - // Bind this texture - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); - } + _DriverGLStates.setTextureMode(CDriverGLStates3::TextureCubeMap); + // Bind this texture + glBindTexture(GL_TEXTURE_CUBE_MAP, gltext->ID); } else { @@ -627,26 +624,23 @@ void CDriverGL3::bindTextureWithMode(ITexture &tex) void CDriverGL3::setupTextureBasicParameters(ITexture &tex) { CTextureDrvInfosGL3* gltext; - gltext= getTextureGl(tex); + gltext = getTextureGl(tex); // TODO: possible cache here, but beware, this is called just after texture creation as well, so these fields // haven't ever been filled. - gltext->WrapS= tex.getWrapS(); - gltext->WrapT= tex.getWrapT(); - gltext->MagFilter= tex.getMagFilter(); - gltext->MinFilter= tex.getMinFilter(); + gltext->WrapS = tex.getWrapS(); + gltext->WrapT = tex.getWrapT(); + gltext->MagFilter = tex.getMagFilter(); + gltext->MinFilter = tex.getMinFilter(); if (tex.isTextureCube()) { - if (_Extensions.ARBTextureCubeMap) - { - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_S, translateWrapToGl(ITexture::Clamp, _Extensions)); - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_T, translateWrapToGl(ITexture::Clamp, _Extensions)); - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_R, translateWrapToGl(ITexture::Clamp, _Extensions)); - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); - - if (_AnisotropicFilter > 1.f && gltext->MinFilter > ITexture::NearestMipMapLinear) - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAX_ANISOTROPY_EXT, _AnisotropicFilter); - } + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, translateWrapToGl(ITexture::Clamp, _Extensions)); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, translateWrapToGl(ITexture::Clamp, _Extensions)); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, translateWrapToGl(ITexture::Clamp, _Extensions)); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); + + if (_AnisotropicFilter > 1.f && gltext->MinFilter > ITexture::NearestMipMapLinear) + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, _AnisotropicFilter); } else { @@ -669,9 +663,6 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded //nldebug("3D: CDriverGL3::setupTextureEx(%016p, %d, %d, %d)", &tex, bUpload, bAllUploaded, bMustRecreateSharedTexture); bAllUploaded = false; - if (tex.isTextureCube() && (!_Extensions.ARBTextureCubeMap)) - return true; - // 0. Create/Retrieve the driver texture. //======================================= bool mustCreate = false; @@ -679,9 +670,9 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded { //nldebug("3D: creating CTextureDrvShare()"); // insert into driver list. (so it is deleted when driver is deleted). - ItTexDrvSharePtrList it= _TexDrvShares.insert(_TexDrvShares.end(), (NL3D::CTextureDrvShare*)NULL); + ItTexDrvSharePtrList it = _TexDrvShares.insert(_TexDrvShares.end(), (NL3D::CTextureDrvShare*)NULL); // create and set iterator, for future deletion. - *it= tex.TextureDrvShare= new CTextureDrvShare(this, it, &tex); + *it = tex.TextureDrvShare = new CTextureDrvShare(this, it, &tex); // Must (re)-create the texture. mustCreate = true; @@ -699,8 +690,8 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded setupTextureBasicParameters(tex); // setup what has changed (will reset the touch flag) // Disable texture 0 - _CurrentTexture[0]= NULL; - _CurrentTextureInfoGL[0]= NULL; + _CurrentTexture[0] = NULL; + _CurrentTextureInfoGL[0] = NULL; _DriverGLStates.setTextureMode(CDriverGLStates3::TextureDisabled); // } @@ -711,8 +702,8 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded // 1. If modified, may (re)load texture part or all of the texture. //================================================================= - bool mustLoadAll= false; - bool mustLoadPart= false; + bool mustLoadAll = false; + bool mustLoadPart = false; // To avoid any delete/new ptr problem, disable all texturing. /* If an old texture is deleted, _CurrentTexture[*] and _CurrentTextureInfoGL[*] are invalid. @@ -1267,32 +1258,29 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex) // setup texture mode, after activeTextureARB() _DriverGLStates.setTextureMode(CDriverGLStates3::TextureCubeMap); - if (_Extensions.ARBTextureCubeMap) - { - // Activate texturing... - //====================== + // Activate texturing... + //====================== - // If the shared texture is the same than before, no op. - if (_CurrentTextureInfoGL[stage] != gltext) - { - // Cache setup. - _CurrentTextureInfoGL[stage]= gltext; + // If the shared texture is the same than before, no op. + if (_CurrentTextureInfoGL[stage] != gltext) + { + // Cache setup. + _CurrentTextureInfoGL[stage]= gltext; - // setup this texture - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); + // setup this texture + glBindTexture(GL_TEXTURE_CUBE_MAP, gltext->ID); - // Change parameters of texture, if necessary. - //============================================ - if (gltext->MagFilter!= tex->getMagFilter()) - { - gltext->MagFilter= tex->getMagFilter(); - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); - } - if (gltext->MinFilter!= tex->getMinFilter()) - { - gltext->MinFilter= tex->getMinFilter(); - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); - } + // Change parameters of texture, if necessary. + //============================================ + if (gltext->MagFilter!= tex->getMagFilter()) + { + gltext->MagFilter= tex->getMagFilter(); + glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); + } + if (gltext->MinFilter!= tex->getMinFilter()) + { + gltext->MinFilter= tex->getMinFilter(); + glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); } } }