Fixed: Crash and bug if not supporting GL_ARB_texture_cube_map

This commit is contained in:
kervala 2010-12-20 17:00:58 +01:00
parent e60ba59fec
commit aa2e1a4717
2 changed files with 20 additions and 11 deletions

View file

@ -1250,10 +1250,13 @@ void CDriverGL::copyFrameBufferToTexture(ITexture *tex,
_DriverGLStates.setTextureMode(textureMode); _DriverGLStates.setTextureMode(textureMode);
if (tex->isTextureCube()) if (tex->isTextureCube())
{
if(_Extensions.ARBTextureCubeMap)
{ {
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID);
glCopyTexSubImage2D(NLCubeFaceToGLCubeFace[cubeFace], level, offsetx, offsety, x, y, width, height); glCopyTexSubImage2D(NLCubeFaceToGLCubeFace[cubeFace], level, offsetx, offsety, x, y, width, height);
} }
}
else else
{ {
glBindTexture(gltext->TextureMode, gltext->ID); glBindTexture(gltext->TextureMode, gltext->ID);

View file

@ -529,11 +529,14 @@ void CDriverGL::bindTextureWithMode(ITexture &tex)
// system of "backup the previous binded texture" seems to not work with some drivers.... // system of "backup the previous binded texture" seems to not work with some drivers....
_DriverGLStates.activeTextureARB(0); _DriverGLStates.activeTextureARB(0);
if(tex.isTextureCube()) if(tex.isTextureCube())
{
if (_Extensions.ARBTextureCubeMap)
{ {
_DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap); _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap);
// Bind this texture // Bind this texture
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID);
} }
}
else else
{ {
CDriverGLStates::TTextureMode textureMode= CDriverGLStates::Texture2D; CDriverGLStates::TTextureMode textureMode= CDriverGLStates::Texture2D;
@ -561,6 +564,8 @@ void CDriverGL::setupTextureBasicParameters(ITexture &tex)
gltext->MagFilter= tex.getMagFilter(); gltext->MagFilter= tex.getMagFilter();
gltext->MinFilter= tex.getMinFilter(); gltext->MinFilter= tex.getMinFilter();
if(tex.isTextureCube()) 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_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_T, translateWrapToGl(ITexture::Clamp, _Extensions));
@ -568,6 +573,7 @@ void CDriverGL::setupTextureBasicParameters(ITexture &tex)
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
} }
}
else else
{ {
glTexParameteri(gltext->TextureMode,GL_TEXTURE_WRAP_S, translateWrapToGl(gltext->WrapS, _Extensions)); glTexParameteri(gltext->TextureMode,GL_TEXTURE_WRAP_S, translateWrapToGl(gltext->WrapS, _Extensions));
@ -1161,7 +1167,7 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex)
if (this->_CurrentTexture[stage]!=tex) if (this->_CurrentTexture[stage]!=tex)
{ {
_DriverGLStates.activeTextureARB(stage); _DriverGLStates.activeTextureARB(stage);
if(tex) if(tex && tex->TextureDrvShare)
{ {
// get the drv info. should be not NULL. // get the drv info. should be not NULL.
CTextureDrvInfosGL* gltext; CTextureDrvInfosGL* gltext;