//
// cocos2d::CCRenderTexture::begin from 0x18005f3a0 to 0x18005f636 (662 bytes)
//
// 9 xrefs:
// > cocos2d::CCTransitionCrossFade::onEnter @ 0x180054c73
// > cocos2d::CCTransitionCrossFade::onEnter @ 0x180054d2a
// > cocos2d::CCTransitionProgress::onEnter @ 0x180057670
// > cocos2d::CCRenderTexture::beginWithClear @ 0x18005f672
// > cocos2d::CCRenderTexture::clearDepth @ 0x18005f8f5
// > cocos2d::CCRenderTexture::draw @ 0x18005fbba
// > cocos2d::CCRenderTexture::newCCImage @ 0x180060373
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b3384
//
// 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
//
// Hidden C++ exception states: #wind=1
void __fastcall cocos2d::CCRenderTexture::begin(cocos2d::CCRenderTexture *this)
{
struct cocos2d::CCDirector *v2; // rdi
struct cocos2d::CCSize *ContentSizeInPixels; // rax
float m_fInternalScaleX; // xmm0_4
float m_fInternalScaleY; // xmm0_4
int v6; // edx
int v7; // r8d
int v8; // r9d
struct cocos2d::CCConfiguration *v9; // rax
char v10; // di
void *v11; // rcx
unsigned int v12; // eax
unsigned int v13; // eax
float v14; // [rsp+40h] [rbp-A8h] BYREF
float v15; // [rsp+44h] [rbp-A4h]
void *Block[2]; // [rsp+50h] [rbp-98h] BYREF
__int64 v17; // [rsp+60h] [rbp-88h]
unsigned __int64 v18; // [rsp+68h] [rbp-80h]
_BYTE v19[64]; // [rsp+70h] [rbp-78h] BYREF
kmGLMatrixMode(5889);
kmGLPushMatrix();
kmGLMatrixMode(5888);
kmGLPushMatrix();
v2 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::setProjection(v2, v2->m_eProjection);
ContentSizeInPixels = (struct cocos2d::CCSize *)cocos2d::CCTexture2D::getContentSizeInPixels(this->m_pTexture);
cocos2d::cc_timeval::operator=(&v14, ContentSizeInPixels);
m_fInternalScaleX = this->m_fInternalScaleX;
if ( m_fInternalScaleX > 0.0 )
v14 = roundf(m_fInternalScaleX * v14);
m_fInternalScaleY = this->m_fInternalScaleY;
if ( m_fInternalScaleY > 0.0 )
v15 = roundf(m_fInternalScaleY * v15);
cocos2d::CCDirector::getWinSizeInPixels(v2);
glViewport(0, 0, (int)v14, (int)v15);
kmMat4OrthographicProjection((unsigned int)v19, v6, v7, v8);
kmGLMultMatrix(v19);
glGetIntegerv(0x8CA6u, &this->m_nOldFBO);
_glewBindFramebuffer(36160, this->m_uFBO);
Block[1] = nullptr;
v17 = 7;
v18 = 15;
Block[0] = (void *)0x4D4F43515F4C47LL;
v9 = cocos2d::CCConfiguration::sharedConfiguration();
v10 = cocos2d::CCConfiguration::checkForGLExtension(v9, Block);
if ( v18 > 0xF )
{
v11 = Block[0];
if ( v18 + 1 >= 0x1000 )
{
v11 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v11 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v11);
}
if ( v10 )
{
v12 = ((__int64 (__fastcall *)(cocos2d::CCTexture2D *))this->m_pTextureCopy->getName)(this->m_pTextureCopy);
_glewFramebufferTexture2D(36160, 36064, 3553, v12, 0);
glClear(0x4100u);
v13 = ((__int64 (__fastcall *)(cocos2d::CCTexture2D *))this->m_pTexture->getName)(this->m_pTexture);
_glewFramebufferTexture2D(36160, 36064, 3553, v13, 0);
}
}