From ad15dbfc75c31f8e03dfbcb7fe55a2b5e9baf2a6 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 20 Dec 2010 17:00:58 +0100 Subject: [PATCH] Fixed: Crash and bug if not supporting GL_ARB_texture_cube_map --- .../src/3d/driver/opengl/driver_opengl.cpp | 7 ++++-- .../driver/opengl/driver_opengl_texture.cpp | 24 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 730470626..e8238ac4a 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -1251,8 +1251,11 @@ void CDriverGL::copyFrameBufferToTexture(ITexture *tex, _DriverGLStates.setTextureMode(textureMode); if (tex->isTextureCube()) { - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); - glCopyTexSubImage2D(NLCubeFaceToGLCubeFace[cubeFace], level, offsetx, offsety, x, y, width, height); + if(_Extensions.ARBTextureCubeMap) + { + glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); + glCopyTexSubImage2D(NLCubeFaceToGLCubeFace[cubeFace], level, offsetx, offsety, x, y, width, height); + } } else { diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp index d747fe793..6079dc6f3 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp @@ -530,9 +530,12 @@ void CDriverGL::bindTextureWithMode(ITexture &tex) _DriverGLStates.activeTextureARB(0); if(tex.isTextureCube()) { - _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap); - // Bind this texture - glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); + if (_Extensions.ARBTextureCubeMap) + { + _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap); + // Bind this texture + glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); + } } else { @@ -562,11 +565,14 @@ void CDriverGL::setupTextureBasicParameters(ITexture &tex) gltext->MinFilter= tex.getMinFilter(); if(tex.isTextureCube()) { - 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 (_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)); + } } else { @@ -1161,7 +1167,7 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex) if (this->_CurrentTexture[stage]!=tex) { _DriverGLStates.activeTextureARB(stage); - if(tex) + if(tex && tex->TextureDrvShare) { // get the drv info. should be not NULL. CTextureDrvInfosGL* gltext;