//
// cocos2d::CCRenderTexture::begin from 0xaf9bc8 to 0xaf9e04 (572 bytes)
//
// 9 xrefs:
// > cocos2d::extension::CCControlSwitchSprite::needsLayout @ 0xa9f590
// > cocos2d::CCTransitionCrossFade::onEnter @ 0xaf0238
// > cocos2d::CCTransitionCrossFade::onEnter @ 0xaf02f8
// > cocos2d::CCTransitionProgress::onEnter @ 0xaf16c0
// > cocos2d::CCRenderTexture::beginWithClear @ 0xaf9e4c
// > cocos2d::CCRenderTexture::draw @ 0xafa01c
// > cocos2d::CCRenderTexture::clearDepth @ 0xafa1b8
// > cocos2d::CCRenderTexture::newCCImage @ 0xafa2ec
// > ??> @ 0x9f2b8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void cocos2d::CCRenderTexture::begin(cocos2d::CCRenderTexture *a1)
{
cocos2d::CCDirector *v2; // x21
const cocos2d::CCSize *ContentSizeInPixels; // x0
float m_fInternalScaleX; // s0
float m_fInternalScaleY; // s0
float v6; // s9
float v7; // s8
cocos2d::CCConfiguration *v8; // x22
_BOOL4 v9; // w21
char *v10; // x0
unsigned int *v11; // x2
int v12; // w1
cocos2d::CCSize v13; // [xsp+50h] [xbp+50h] BYREF
float v14; // [xsp+58h] [xbp+58h]
float v15; // [xsp+5Ch] [xbp+5Ch]
const char *v16; // [xsp+60h] [xbp+60h] BYREF
float v17[16]; // [xsp+68h] [xbp+68h] BYREF
kmGLMatrixMode((__int64 *)((char *)&elf_hash_bucket[1346] + 1));
kmGLPushMatrix();
kmGLMatrixMode((__int64 *)&elf_hash_bucket[1346]);
kmGLPushMatrix();
v2 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::setProjection(v2, v2->m_eProjection);
ContentSizeInPixels = cocos2d::CCTexture2D::getContentSizeInPixels(a1->m_pTexture);
cocos2d::CCSize::CCSize(&v13, ContentSizeInPixels);
m_fInternalScaleX = a1->m_fInternalScaleX;
if ( m_fInternalScaleX > 0.0 )
v13.width = roundf(m_fInternalScaleX * v13.width);
m_fInternalScaleY = a1->m_fInternalScaleY;
if ( m_fInternalScaleY > 0.0 )
v13.height = roundf(m_fInternalScaleY * v13.height);
cocos2d::CCDirector::getWinSizeInPixels(v2);
v6 = v14 / v13.width;
v7 = v15 / v13.height;
glViewport();
kmMat4OrthographicProjection(v17, -1.0 / v6, 1.0 / v6, -1.0 / v7, 1.0 / v7, -1.0, 1.0);
kmGLMultMatrix(v17);
glGetIntegerv();
glBindFramebuffer();
v8 = cocos2d::CCConfiguration::sharedConfiguration();
sub_D153B8((int)&v16, "GL_QCOM");
v9 = cocos2d::CCConfiguration::checkForGLExtension((__int64)v8, &v16);
v10 = (char *)(v16 - 24);
if ( v16 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v16 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *((_DWORD *)v16 - 2);
*((_DWORD *)v16 - 2) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v10);
}
if ( v9 )
{
a1->m_pTextureCopy->getName(a1->m_pTextureCopy);
glFramebufferTexture2D();
glClear();
a1->m_pTexture->getName(a1->m_pTexture);
glFramebufferTexture2D();
}
}