//
// cocos2d::CCRenderTexture::initWithWidthAndHeight from 0x1003c0344 to 0x1003c0658 (788 bytes)
//
// 2 xrefs:
// > cocos2d::CCRenderTexture::create @ 0x1003c02f4
// > cocos2d::CCRenderTexture::create_1 @ 0x1003c06f8
//
// 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
//
bool __fastcall cocos2d::CCRenderTexture::initWithWidthAndHeight(
cocos2d::CCRenderTexture *a1,
int a2,
int a3,
cocos2d::CCTexture2DPixelFormat a4,
unsigned int a5)
{
float v9; // s8
cocos2d::CCDirector *v10; // x0
int v11; // w26
cocos2d::CCDirector *v12; // x0
int v13; // w27
cocos2d::CCConfiguration *v14; // x0
unsigned int v15; // w22
unsigned int v16; // w23
size_t v17; // x25
void *v18; // x0
void *v19; // x20
cocos2d::CCTexture2D *v20; // x24
GLenum m_ePixelFormat; // w25
cocos2d::CCConfiguration *v22; // x24
unsigned int v23; // w0
unsigned int v24; // w24
cocos2d::CCTexture2D *v25; // x24
GLenum v26; // w25
GLuint v27; // w0
cocos2d::CCSprite *v28; // x0
void *__p[2]; // [xsp+0h] [xbp-80h] BYREF
char v31; // [xsp+17h] [xbp-69h]
GLint params; // [xsp+1Ch] [xbp-64h] BYREF
v9 = (float)a2;
v10 = cocos2d::CCDirector::sharedDirector();
v11 = (int)(float)(sub_1001765E4((__int64)v10) * v9);
v12 = cocos2d::CCDirector::sharedDirector();
v13 = (int)(float)(sub_1001765E4((__int64)v12) * (float)a3);
glGetIntegerv(0x8CA6u, &a1->m_nOldFBO);
v14 = cocos2d::CCConfiguration::sharedConfiguration();
v15 = v11;
v16 = v13;
if ( !cocos2d::CCConfiguration::supportsNPOT(v14) )
{
v15 = sub_100084720(v11);
v16 = sub_100084720(v13);
}
v17 = (int)(4 * v15 * v16);
v18 = malloc(v17);
v19 = v18;
if ( v18 )
{
bzero(v18, v17);
a1->m_ePixelFormat = a4;
a1->m_nWidth = v11;
a1->m_nHeight = v13;
v20 = (cocos2d::CCTexture2D *)operator new(0x68u);
j_cocos2d::CCTexture2D::CCTexture2D((__int64)v20);
a1->m_pTexture = v20;
m_ePixelFormat = a1->m_ePixelFormat;
sub_100022988((float *)__p, (float)v11, (float)v13);
cocos2d::CCTexture2D::initWithData(
v20,
v19,
(cocos2d::CCTexture2DPixelFormat)m_ePixelFormat,
v15,
v16,
(const cocos2d::CCSize *)__p);
glGetIntegerv(0x8CA7u, ¶ms);
v22 = cocos2d::CCConfiguration::sharedConfiguration();
sub_100009900(__p, "GL_QCOM");
v23 = (unsigned int)cocos2d::CCConfiguration::checkForGLExtension((__int64)v22, (const char *)__p);
v24 = v23;
if ( v31 < 0 )
{
operator delete(__p[0]);
if ( !v24 )
goto LABEL_9;
}
else if ( !v23 )
{
LABEL_9:
glGenFramebuffers(1, &a1->m_uFBO);
glBindFramebuffer(0x8D40u, a1->m_uFBO);
v27 = ((__int64 (__fastcall *)(cocos2d::CCTexture2D *))a1->m_pTexture->getName)(a1->m_pTexture);
glFramebufferTexture2D(0x8D40u, 0x8CE0u, 0xDE1u, v27, 0);
if ( a5 )
{
glGenRenderbuffers(1, &a1->m_uDepthRenderBufffer);
glBindRenderbuffer(0x8D41u, a1->m_uDepthRenderBufffer);
glRenderbufferStorage(0x8D41u, a5, v15, v16);
glFramebufferRenderbuffer(0x8D40u, 0x8D00u, 0x8D41u, a1->m_uDepthRenderBufffer);
if ( a5 == 35056 )
glFramebufferRenderbuffer(0x8D40u, 0x8D20u, 0x8D41u, a1->m_uDepthRenderBufffer);
}
glCheckFramebufferStatus(0x8D40u);
cocos2d::CCTexture2D::setAliasTexParameters(a1->m_pTexture);
v28 = cocos2d::CCSprite::createWithTexture_1(a1->m_pTexture);
((void (__fastcall *)(cocos2d::CCRenderTexture *, cocos2d::CCSprite *))a1->setSprite)(a1, v28);
cocos2d::CCObject::release(a1->m_pTexture);
((void (__fastcall *)(cocos2d::CCSprite *, float))a1->m_pSprite->setScaleY)(a1->m_pSprite, -1.0);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a1->m_pSprite->setBlendFunc)(a1->m_pSprite, 0x30300000001LL);
glBindRenderbuffer(0x8D41u, params);
glBindFramebuffer(0x8D40u, a1->m_nOldFBO);
a1->m_bAutoDraw = 0;
((void (__fastcall *)(cocos2d::CCRenderTexture *, cocos2d::CCSprite *))a1->addChild)(a1, a1->m_pSprite);
free(v19);
return v19 != nullptr;
}
v25 = (cocos2d::CCTexture2D *)operator new(0x68u);
j_cocos2d::CCTexture2D::CCTexture2D((__int64)v25);
a1->m_pTextureCopy = v25;
v26 = a1->m_ePixelFormat;
sub_100022988((float *)__p, (float)v11, (float)v13);
cocos2d::CCTexture2D::initWithData(
v25,
v19,
(cocos2d::CCTexture2DPixelFormat)v26,
v15,
v16,
(const cocos2d::CCSize *)__p);
goto LABEL_9;
}
return v19 != nullptr;
}