//
// cocos2d::CCRenderTexture::initWithWidthAndHeight from 0xd6a7d4 to 0xd6ab60 (908 bytes)
//
// 4 xrefs:
// > cocos2d::CCRenderTexture::create @ 0xd6aba8
// > cocos2d::CCRenderTexture::create @ 0xd6ac30
// > cocos2d::CCRenderTexture::initWithWidthAndHeight @ 0xd6ac78
// > ??> @ 0xacb88
//
// 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 13:07:56 +0000
//
__int64 __fastcall cocos2d::CCRenderTexture::initWithWidthAndHeight(__int64 a1, int a2, int a3, int a4, int a5)
{
cocos2d::CCDirector *v8; // x0
int v9; // w20
cocos2d::CCDirector *v10; // x0
cocos2d::CCDirector *v11; // x0
int v12; // w21
cocos2d::CCConfiguration *Integerv; // x0
cocos2d::CCConfiguration *v14; // x0
unsigned __int64 v15; // x1
unsigned int POT; // w24
unsigned int v17; // w25
void *v18; // x0
void *v19; // x28
cocos2d::CCTexture2D *v20; // x26
float v21; // s8
float v22; // s9
cocos2d::CCConfiguration *v23; // x0
__int64 v24; // x21
_BOOL4 v25; // w20
cocos2d::CCTexture2D *v26; // x20
void (__fastcall *v27)(__int64, __int64); // x21
__int64 v28; // x0
unsigned __int64 v30; // x1
__int64 v33; // [xsp+78h] [xbp+78h]
__int64 v34; // [xsp+78h] [xbp+78h]
float v35; // [xsp+88h] [xbp+88h] BYREF
__int64 v36[2]; // [xsp+90h] [xbp+90h] BYREF
void *v37; // [xsp+A0h] [xbp+A0h]
v8 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(_stack_chk_guard);
v9 = (int)(float)((float)a2 * cocos2d::CCDirector::getContentScaleFactor(v8));
v11 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v10);
v12 = (int)(float)((float)a3 * cocos2d::CCDirector::getContentScaleFactor(v11));
Integerv = (cocos2d::CCConfiguration *)glGetIntegerv();
v14 = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::sharedConfiguration(Integerv);
if ( (unsigned __int8)cocos2d::CCConfiguration::supportsNPOT(v14) )
{
POT = v9;
v17 = v12;
}
else
{
POT = cocos2d::ccNextPOT((cocos2d *)v9, v15);
v17 = cocos2d::ccNextPOT((cocos2d *)v12, v30);
}
v18 = malloc((int)(4 * POT * v17));
v19 = v18;
if ( !v18 )
return 0;
memset(v18, 0, (int)(4 * POT * v17));
*(_DWORD *)(a1 + 368) = a4;
*(_DWORD *)(a1 + 412) = v9;
*(_DWORD *)(a1 + 416) = v12;
v20 = (cocos2d::CCTexture2D *)operator new(0x68u);
cocos2d::CCTexture2D::CCTexture2D(v20);
*(_QWORD *)(a1 + 344) = v20;
v21 = (float)v9;
v22 = (float)v12;
v33 = *(unsigned int *)(a1 + 368);
cocos2d::CCSize::CCSize(&v35, (float)v9, (float)v12);
cocos2d::CCTexture2D::initWithData(v20, v19, v33, POT, v17, &v35);
v23 = (cocos2d::CCConfiguration *)glGetIntegerv();
v24 = cocos2d::CCConfiguration::sharedConfiguration(v23);
v36[0] = 0;
v36[1] = 0;
v37 = nullptr;
std::string::__init(v36, "GL_QCOM", 7u);
v25 = cocos2d::CCConfiguration::checkForGLExtension(v24, (char *)v36);
if ( (v36[0] & 1) != 0 )
operator delete(v37);
if ( v25 )
{
v26 = (cocos2d::CCTexture2D *)operator new(0x68u);
cocos2d::CCTexture2D::CCTexture2D(v26);
*(_QWORD *)(a1 + 352) = v26;
v34 = *(unsigned int *)(a1 + 368);
cocos2d::CCSize::CCSize(&v35, v21, v22);
cocos2d::CCTexture2D::initWithData(v26, v19, v34, POT, v17, &v35);
}
glGenFramebuffers();
glBindFramebuffer();
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 344) + 104LL))(*(_QWORD *)(a1 + 344));
glFramebufferTexture2D();
if ( a5 )
{
glGenRenderbuffers();
glBindRenderbuffer();
glRenderbufferStorage();
glFramebufferRenderbuffer();
if ( a5 == 35056 )
glFramebufferRenderbuffer();
}
glCheckFramebufferStatus();
cocos2d::CCTexture2D::setAliasTexParameters(*(cocos2d::CCTexture2D **)(a1 + 344));
v27 = *(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 904LL);
v28 = cocos2d::CCSprite::createWithTexture(*(cocos2d::CCSprite **)(a1 + 344), *(cocos2d::CCTexture2D **)a1);
v27(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();
glBindFramebuffer();
*(_BYTE *)(a1 + 400) = 0;
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 456LL))(a1, *(_QWORD *)(a1 + 320));
free(v19);
return 1;
}