//
// cocos2d::CCRenderTexture::begin from 0x1003c076c to 0x1003c0920 (436 bytes)
//
// 2 xrefs:
// > cocos2d::CCRenderTexture::beginWithClear @ 0x1003c0994
// > cocos2d::CCRenderTexture::draw @ 0x1003c0b8c
//
// 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 __fastcall cocos2d::CCRenderTexture::begin(cocos2d::CCRenderTexture *a1)
{
cocos2d::CCDirector *v2; // x20
double *ContentSizeInPixels; // x0
float m_fInternalScaleX; // s0
float m_fInternalScaleY; // s0
float v6; // s8
float v7; // s9
cocos2d::CCConfiguration *v8; // x20
unsigned int v9; // w0
unsigned int v10; // w20
GLuint v11; // w0
GLuint v12; // w0
void *__p[2]; // [xsp+8h] [xbp-88h] BYREF
char v14; // [xsp+1Fh] [xbp-71h]
_BYTE v15[64]; // [xsp+20h] [xbp-70h] BYREF
float v16; // [xsp+60h] [xbp-30h]
float v17; // [xsp+64h] [xbp-2Ch]
__int64 v18; // [xsp+68h] [xbp-28h] BYREF
sub_10016854C(5889);
sub_100168594();
sub_10016854C(5888);
sub_100168594();
v2 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::setProjection(v2, v2->m_eProjection);
ContentSizeInPixels = (double *)cocos2d::CCTexture2D::getContentSizeInPixels(a1->m_pTexture);
sub_100022AFC(&v18, ContentSizeInPixels);
m_fInternalScaleX = a1->m_fInternalScaleX;
if ( m_fInternalScaleX > 0.0 )
LODWORD(v18) = roundf(m_fInternalScaleX * *(float *)&v18);
m_fInternalScaleY = a1->m_fInternalScaleY;
if ( m_fInternalScaleY > 0.0 )
HIDWORD(v18) = roundf(m_fInternalScaleY * *((float *)&v18 + 1));
cocos2d::CCDirector::getWinSizeInPixels(v2);
v6 = v16 / *(float *)&v18;
v7 = v17 / *((float *)&v18 + 1);
glViewport(0, 0, (int)*(float *)&v18, (int)*((float *)&v18 + 1));
sub_1003B2F10((__int64)v15, -1.0 / v6, 1.0 / v6, -1.0 / v7, 1.0 / v7, -1.0, 1.0);
sub_100168664((__int64)v15);
glGetIntegerv(0x8CA6u, &a1->m_nOldFBO);
glBindFramebuffer(0x8D40u, a1->m_uFBO);
v8 = cocos2d::CCConfiguration::sharedConfiguration();
sub_100009900(__p, "GL_QCOM");
v9 = (unsigned int)cocos2d::CCConfiguration::checkForGLExtension((__int64)v8, (const char *)__p);
v10 = v9;
if ( v14 < 0 )
{
operator delete(__p[0]);
if ( !v10 )
return;
}
else if ( !v9 )
{
return;
}
v11 = ((__int64 (__fastcall *)(cocos2d::CCTexture2D *))a1->m_pTextureCopy->getName)(a1->m_pTextureCopy);
glFramebufferTexture2D(0x8D40u, 0x8CE0u, 0xDE1u, v11, 0);
glClear(0x4100u);
v12 = ((__int64 (__fastcall *)(cocos2d::CCTexture2D *))a1->m_pTexture->getName)(a1->m_pTexture);
glFramebufferTexture2D(0x8D40u, 0x8CE0u, 0xDE1u, v12, 0);
}