mirror of https://github.com/axmolengine/axmol.git
fixed #696 Some android machines may crash at CCRenderTexture::end(bool bIsTOCasheTexture)
This commit is contained in:
parent
63bded4082
commit
fea3da3156
|
@ -78,13 +78,9 @@ public:
|
|||
/** end is key word of lua, use other name to export to lua. */
|
||||
inline void endToLua(){ end();};
|
||||
|
||||
#if CC_ENABLE_CACHE_TEXTTURE_DATA
|
||||
/** ends grabbing for android */
|
||||
/** ends grabbing*/
|
||||
// para bIsTOCacheTexture the parameter is only used for android to cache the texture
|
||||
void end(bool bIsTOCacheTexture = true);
|
||||
#else
|
||||
/** ends grabbing */
|
||||
void end();
|
||||
#endif
|
||||
|
||||
/** clears the texture with a color */
|
||||
void clear(float r, float g, float b, float a);
|
||||
|
|
|
@ -204,46 +204,36 @@ void CCRenderTexture::beginWithClear(float r, float g, float b, float a)
|
|||
glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
|
||||
}
|
||||
|
||||
#if CC_ENABLE_CACHE_TEXTTURE_DATA
|
||||
void CCRenderTexture::end(bool bIsTOCacheTexture)
|
||||
{
|
||||
ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_nOldFBO);
|
||||
// Restore the original matrix and viewport
|
||||
glPopMatrix();
|
||||
CCSize size = CCDirector::sharedDirector()->getDisplaySizeInPixels();
|
||||
// glViewport(0, 0, (GLsizei)size.width, (GLsizei)size.height);
|
||||
CCDirector::sharedDirector()->getOpenGLView()->setViewPortInPoints(0, 0, size.width, size.height);
|
||||
|
||||
if (bIsTOCacheTexture)
|
||||
{
|
||||
CC_SAFE_DELETE(m_pUITextureImage);
|
||||
|
||||
// to get the rendered texture data
|
||||
const CCSize& s = m_pTexture->getContentSizeInPixels();
|
||||
int tx = (int)s.width;
|
||||
int ty = (int)s.height;
|
||||
m_pUITextureImage = new CCImage;
|
||||
if (true == getUIImageFromBuffer(m_pUITextureImage, 0, 0, tx, ty))
|
||||
{
|
||||
VolatileTexture::addDataTexture(m_pTexture, m_pUITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Cache rendertexture failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void CCRenderTexture::end()
|
||||
{
|
||||
ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_nOldFBO);
|
||||
// Restore the original matrix and viewport
|
||||
glPopMatrix();
|
||||
CCSize size = CCDirector::sharedDirector()->getDisplaySizeInPixels();
|
||||
void CCRenderTexture::end(bool bIsTOCacheTexture)
|
||||
{
|
||||
ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_nOldFBO);
|
||||
// Restore the original matrix and viewport
|
||||
glPopMatrix();
|
||||
CCSize size = CCDirector::sharedDirector()->getDisplaySizeInPixels();
|
||||
// glViewport(0, 0, (GLsizei)size.width, (GLsizei)size.height);
|
||||
CCDirector::sharedDirector()->getOpenGLView()->setViewPortInPoints(0, 0, size.width, size.height);
|
||||
}
|
||||
#endif
|
||||
CCDirector::sharedDirector()->getOpenGLView()->setViewPortInPoints(0, 0, size.width, size.height);
|
||||
|
||||
#if CC_ENABLE_CACHE_TEXTTURE_DATA
|
||||
if (bIsTOCacheTexture)
|
||||
{
|
||||
CC_SAFE_DELETE(m_pUITextureImage);
|
||||
|
||||
// to get the rendered texture data
|
||||
const CCSize& s = m_pTexture->getContentSizeInPixels();
|
||||
int tx = (int)s.width;
|
||||
int ty = (int)s.height;
|
||||
m_pUITextureImage = new CCImage;
|
||||
if (true == getUIImageFromBuffer(m_pUITextureImage, 0, 0, tx, ty))
|
||||
{
|
||||
VolatileTexture::addDataTexture(m_pTexture, m_pUITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Cache rendertexture failed!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CCRenderTexture::clear(float r, float g, float b, float a)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue