fixed #649 the user could save any domain of the render texture

This commit is contained in:
RongHong 2011-08-02 17:22:57 +08:00
parent 3a3a52c59a
commit 4a8e3f468e
1 changed files with 4 additions and 4 deletions

View File

@ -314,8 +314,8 @@ bool CCRenderTexture::getUIImageFromBuffer(CCImage *pImage, int x, int y, int nW
int nMaxTextureSize = 0;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &nMaxTextureSize);
nReadBufferWidth = ccNextPOT(nSavedBufferWidth);
nReadBufferHeight = ccNextPOT(nSavedBufferHeight);
nReadBufferWidth = ccNextPOT(tx);
nReadBufferHeight = ccNextPOT(ty);
CC_BREAK_IF(0 == nReadBufferWidth || 0 == nReadBufferHeight);
CC_BREAK_IF(nReadBufferWidth > nMaxTextureSize || nReadBufferHeight > nMaxTextureSize);
@ -324,7 +324,7 @@ bool CCRenderTexture::getUIImageFromBuffer(CCImage *pImage, int x, int y, int nW
this->begin();
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(x,y,nReadBufferWidth,nReadBufferHeight,GL_RGBA,GL_UNSIGNED_BYTE, pTempData);
glReadPixels(0,0,nReadBufferWidth,nReadBufferHeight,GL_RGBA,GL_UNSIGNED_BYTE, pTempData);
this->end();
// to get the actual texture data
@ -332,7 +332,7 @@ bool CCRenderTexture::getUIImageFromBuffer(CCImage *pImage, int x, int y, int nW
for (int i = 0; i < nSavedBufferHeight; ++i)
{
memcpy(&pBuffer[i * nSavedBufferWidth * 4],
&pTempData[(nSavedBufferHeight - i - 1) * nReadBufferWidth * 4],
&pTempData[(y + nSavedBufferHeight - i - 1) * nReadBufferWidth * 4 + x * 4],
nSavedBufferWidth * 4);
}