Merge branch 'gles20' of https://github.com/MartinSherburn/cocos2d-x into merge_texparams

This commit is contained in:
minggo 2012-09-03 16:04:41 +08:00
commit 1a2dd6ae35
3 changed files with 33 additions and 0 deletions

View File

@ -622,6 +622,10 @@ void CCTexture2D::setTexParameters(ccTexParams *texParams)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParams->magFilter );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texParams->wrapS );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texParams->wrapT );
#if CC_ENABLE_CACHE_TEXTURE_DATA
VolatileTexture::setTexParameters(this, texParams);
#endif
}
void CCTexture2D::setAliasTexParameters()
@ -638,6 +642,10 @@ void CCTexture2D::setAliasTexParameters()
}
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
#if CC_ENABLE_CACHE_TEXTURE_DATA
ccTexParams texParams = {m_bHasMipmaps?GL_NEAREST_MIPMAP_NEAREST:GL_NEAREST,GL_NEAREST,GL_NONE,GL_NONE};
VolatileTexture::setTexParameters(this, &texParams);
#endif
}
void CCTexture2D::setAntiAliasTexParameters()
@ -654,6 +662,10 @@ void CCTexture2D::setAntiAliasTexParameters()
}
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
#if CC_ENABLE_CACHE_TEXTURE_DATA
ccTexParams texParams = {m_bHasMipmaps?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR,GL_LINEAR,GL_NONE,GL_NONE};
VolatileTexture::setTexParameters(this, &texParams);
#endif
}
const char* CCTexture2D::stringForFormat()

View File

@ -713,6 +713,10 @@ VolatileTexture::VolatileTexture(CCTexture2D *t)
, m_fFontSize(0.0f)
{
m_size = CCSizeMake(0, 0);
m_texParams.minFilter = GL_LINEAR;
m_texParams.magFilter = GL_LINEAR;
m_texParams.wrapS = GL_CLAMP_TO_EDGE;
m_texParams.wrapT = GL_CLAMP_TO_EDGE;
textures.push_back(this);
}
@ -801,6 +805,20 @@ void VolatileTexture::addStringTexture(CCTexture2D *tt, const char* text, const
vt->m_strText = text;
}
void VolatileTexture::setTexParameters(CCTexture2D *t, ccTexParams *texParams)
{
VolatileTexture *vt = findVolotileTexture(t);
if (texParams->minFilter != GL_NONE)
vt->m_texParams.minFilter = texParams->minFilter;
if (texParams->magFilter != GL_NONE)
vt->m_texParams.magFilter = texParams->magFilter;
if (texParams->wrapS != GL_NONE)
vt->m_texParams.wrapS = texParams->wrapS;
if (texParams->wrapT != GL_NONE)
vt->m_texParams.wrapT = texParams->wrapT;
}
void VolatileTexture::removeTexture(CCTexture2D *t)
{
@ -890,6 +908,7 @@ void VolatileTexture::reloadAllTextures()
default:
break;
}
vt->texture->setTexParameters(&vt->m_texParams);
}
isReloading = false;

View File

@ -195,6 +195,7 @@ public:
static void addDataTexture(CCTexture2D *tt, void* data, CCTexture2DPixelFormat pixelFormat, const CCSize& contentSize);
static void addCCImage(CCTexture2D *tt, CCImage *image);
static void setTexParameters(CCTexture2D *t, ccTexParams *texParams);
static void removeTexture(CCTexture2D *t);
static void reloadAllTextures();
@ -221,6 +222,7 @@ protected:
std::string m_strFileName;
CCImage::EImageFormat m_FmtImage;
ccTexParams m_texParams;
CCSize m_size;
CCTextAlignment m_alignment;
CCVerticalTextAlignment m_vAlignment;