mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6512 from dabingnn/v3_renderTextureBug
V3 render texture bug
This commit is contained in:
commit
2cbbaed5b3
|
@ -194,11 +194,12 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
|||
do
|
||||
{
|
||||
_fullRect = _rtTextureRect = Rect(0,0,w,h);
|
||||
Size size = Director::getInstance()->getWinSizeInPixels();
|
||||
_fullviewPort = Rect(0,0,size.width,size.height);
|
||||
//Size size = Director::getInstance()->getWinSizeInPixels();
|
||||
//_fullviewPort = Rect(0,0,size.width,size.height);
|
||||
w = (int)(w * CC_CONTENT_SCALE_FACTOR());
|
||||
h = (int)(h * CC_CONTENT_SCALE_FACTOR());
|
||||
|
||||
_fullviewPort = Rect(0,0,w,h);
|
||||
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
|
||||
|
||||
// textures must be power of two squared
|
||||
|
@ -522,7 +523,6 @@ void RenderTexture::onBegin()
|
|||
{
|
||||
//
|
||||
Director *director = Director::getInstance();
|
||||
Size size = director->getWinSizeInPixels();
|
||||
|
||||
_oldProjMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, _projectionMatrix);
|
||||
|
@ -541,14 +541,17 @@ void RenderTexture::onBegin()
|
|||
#endif
|
||||
|
||||
const Size& texSize = _texture->getContentSizeInPixels();
|
||||
|
||||
|
||||
// Calculate the adjustment ratios based on the old and new projections
|
||||
Size size = director->getWinSizeInPixels();
|
||||
float widthRatio = size.width / texSize.width;
|
||||
float heightRatio = size.height / texSize.height;
|
||||
|
||||
Matrix orthoMatrix;
|
||||
Matrix::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, orthoMatrix);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
|
||||
}
|
||||
|
||||
//calculate viewport
|
||||
{
|
||||
Rect viewport;
|
||||
|
@ -696,12 +699,13 @@ void RenderTexture::begin()
|
|||
|
||||
// Calculate the adjustment ratios based on the old and new projections
|
||||
Size size = director->getWinSizeInPixels();
|
||||
|
||||
float widthRatio = size.width / texSize.width;
|
||||
float heightRatio = size.height / texSize.height;
|
||||
|
||||
Matrix orthoMatrix;
|
||||
Matrix::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, orthoMatrix);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
|
||||
}
|
||||
|
||||
_groupCommand.init(_globalZOrder);
|
||||
|
|
|
@ -408,8 +408,7 @@ void RenderTextureZbuffer::renderScreenShot()
|
|||
{
|
||||
return;
|
||||
}
|
||||
texture->setAnchorPoint(Vector2(0, 0));
|
||||
texture->setKeepMatrix(true);
|
||||
|
||||
texture->begin();
|
||||
|
||||
this->visit();
|
||||
|
|
Loading…
Reference in New Issue