//
// cocos2d::CCRenderTexture::initWithWidthAndHeight from 0x100467074 to 0x100467388 (788 bytes)
//
// 2 xrefs:
// > cocos2d::CCRenderTexture::create @ 0x100467024
// > cocos2d::CCRenderTexture::create_1 @ 0x100467428
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:05:32 +0000
//
bool __fastcall cocos2d::CCRenderTexture::initWithWidthAndHeight(__int64 a1, int a2, int a3, int a4, GLenum a5)
{
float v9; // s8
__int64 v10; // x0
int v11; // w26
__int64 v12; // x0
int v13; // w27
__int64 v14; // x0
GLsizei v15; // w22
GLsizei v16; // w23
size_t v17; // x25
void *v18; // x0
GLvoid *v19; // x20
void *v20; // x24
__int64 v21; // x25
__int64 v22; // x24
unsigned int v23; // w0
unsigned int v24; // w24
void *v25; // x24
__int64 v26; // x25
GLuint v27; // w0
void *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_100207B64(v10) * v9);
v12 = cocos2d::CCDirector::sharedDirector();
v13 = (int)(float)(sub_100207B64(v12) * (float)a3);
glGetIntegerv(0x8CA6u, (GLint *)(a1 + 336));
v14 = cocos2d::CCConfiguration::sharedConfiguration();
v15 = v11;
v16 = v13;
if ( (cocos2d::CCConfiguration::supportsNPOT(v14) & 1) == 0 )
{
v15 = sub_10008E7D4(v11);
v16 = sub_10008E7D4(v13);
}
v17 = 4 * v15 * v16;
v18 = malloc(v17);
v19 = v18;
if ( v18 )
{
bzero(v18, v17);
*(_DWORD *)(a1 + 368) = a4;
*(_DWORD *)(a1 + 412) = v11;
*(_DWORD *)(a1 + 416) = v13;
v20 = operator new(0x68u);
j_cocos2d::CCTexture2D::CCTexture2D((__int64)v20);
*(_QWORD *)(a1 + 344) = v20;
v21 = *(unsigned int *)(a1 + 368);
sub_1000262C4((float *)__p, (float)v11, (float)v13);
cocos2d::CCTexture2D::initWithData((__int64)v20, v19, v21, v15, v16, (double *)__p);
glGetIntegerv(0x8CA7u, ¶ms);
v22 = cocos2d::CCConfiguration::sharedConfiguration();
sub_100009900(__p, "GL_QCOM");
v23 = (unsigned int)cocos2d::CCConfiguration::checkForGLExtension(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, (GLuint *)(a1 + 328));
glBindFramebuffer(0x8D40u, *(_DWORD *)(a1 + 328));
v27 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 344) + 104LL))(*(_QWORD *)(a1 + 344));
glFramebufferTexture2D(0x8D40u, 0x8CE0u, 0xDE1u, v27, 0);
if ( a5 )
{
glGenRenderbuffers(1, (GLuint *)(a1 + 332));
glBindRenderbuffer(0x8D41u, *(_DWORD *)(a1 + 332));
glRenderbufferStorage(0x8D41u, a5, v15, v16);
glFramebufferRenderbuffer(0x8D40u, 0x8D00u, 0x8D41u, *(_DWORD *)(a1 + 332));
if ( a5 == 35056 )
glFramebufferRenderbuffer(0x8D40u, 0x8D20u, 0x8D41u, *(_DWORD *)(a1 + 332));
}
glCheckFramebufferStatus(0x8D40u);
cocos2d::CCTexture2D::setAliasTexParameters(*(_QWORD *)(a1 + 344));
v28 = cocos2d::CCSprite::createWithTexture_1(*(_QWORD *)(a1 + 344));
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)a1 + 904LL))(a1, v28);
cocos2d::CCObject::release(*(_DWORD **)(a1 + 344));
(*(void (__fastcall **)(_QWORD, float))(**(_QWORD **)(a1 + 320) + 144LL))(*(_QWORD *)(a1 + 320), -1.0);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 320) + 1080LL))(
*(_QWORD *)(a1 + 320),
0x30300000001LL);
glBindRenderbuffer(0x8D41u, params);
glBindFramebuffer(0x8D40u, *(_DWORD *)(a1 + 336));
*(_BYTE *)(a1 + 400) = 0;
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 456LL))(a1, *(_QWORD *)(a1 + 320));
free(v19);
return v19 != nullptr;
}
v25 = operator new(0x68u);
j_cocos2d::CCTexture2D::CCTexture2D((__int64)v25);
*(_QWORD *)(a1 + 352) = v25;
v26 = *(unsigned int *)(a1 + 368);
sub_1000262C4((float *)__p, (float)v11, (float)v13);
cocos2d::CCTexture2D::initWithData((__int64)v25, v19, v26, v15, v16, (double *)__p);
goto LABEL_9;
}
return v19 != nullptr;
}