MCPcopy Create free account
hub / github.com/axmolengine/axmol / onBegin

Method onBegin

core/2d/RenderTexture.cpp:600–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

598}
599
600void RenderTexture::onBegin()
601{
602 _oldProjMatrix = _director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
603 _director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, _projectionMatrix);
604
605 _oldTransMatrix = _director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
606 _director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _transformMatrix);
607
608 if (!_keepMatrix)
609 {
610 _director->setProjection(_director->getProjection());
611 const Vec2& texSize = _texture2D->getContentSizeInPixels();
612
613 // Calculate the adjustment ratios based on the old and new projections
614 Vec2 size = _director->getWinSizeInPixels();
615 float widthRatio = size.width / texSize.width;
616 float heightRatio = size.height / texSize.height;
617
618 Mat4 orthoMatrix;
619 Mat4::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio,
620 (float)1.0 / heightRatio, -1, 1, &orthoMatrix);
621 _director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
622 }
623
624 Rect viewport;
625 viewport.size.width = _fullviewPort.size.width;
626 viewport.size.height = _fullviewPort.size.height;
627 float viewPortRectWidthRatio = float(viewport.size.width) / _fullRect.size.width;
628 float viewPortRectHeightRatio = float(viewport.size.height) / _fullRect.size.height;
629 viewport.origin.x = (_fullRect.origin.x - _rtTextureRect.origin.x) * viewPortRectWidthRatio;
630 viewport.origin.y = (_fullRect.origin.y - _rtTextureRect.origin.y) * viewPortRectHeightRatio;
631
632 Renderer* renderer = _director->getRenderer();
633
634 _oldViewport = renderer->getViewport();
635 renderer->setViewPort(viewport.origin.x, viewport.origin.y, viewport.size.width, viewport.size.height);
636
637 _oldRenderTarget = renderer->getRenderTarget();
638 renderer->setRenderTarget(_renderTarget);
639}
640
641void RenderTexture::onEnd()
642{

Callers

nothing calls this directly

Calls 7

loadMatrixMethod · 0.80
setProjectionMethod · 0.80
getWinSizeInPixelsMethod · 0.80
getRendererMethod · 0.80
setViewPortMethod · 0.80
setRenderTargetMethod · 0.80
multiplyMatrixMethod · 0.45

Tested by

no test coverage detected