//
// cocos2d::CCRenderTexture::initWithWidthAndHeight from 0x7e05b0 to 0x7e0840 (656 bytes)
//
// 3 xrefs:
// > cocos2d::CCRenderTexture::create @ 0x7e0876
// > cocos2d::CCRenderTexture::create @ 0x7e08b6
// > cocos2d::CCRenderTexture::initWithWidthAndHeight @ 0x7e08dc
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:00:49 +0000
//
void *__fastcall cocos2d::CCRenderTexture::initWithWidthAndHeight(int a1, int a2, int a3, int a4, int a5)
{
cocos2d::CCDirector *v9; // r0
float v10; // r0
float v11; // s17
cocos2d::CCDirector *v12; // r0
cocos2d *v13; // s17
float v14; // s16
cocos2d::CCConfiguration *v15; // r0
cocos2d::CCConfiguration *v16; // r0
unsigned int v17; // r1
cocos2d *POT; // r9
int v19; // r8
unsigned int v20; // r1
void *result; // r0
void *v22; // r6
cocos2d::CCTexture2D *v23; // r11
int v24; // r10
float v25; // s17
cocos2d::CCConfiguration *v26; // r0
int v27; // r0
int v28; // r10
const char *v29; // r10
cocos2d::CCTexture2D *v30; // r11
int v31; // r10
void (__fastcall *v32)(int, int); // r8
cocos2d::CCTexture2D *v33; // r1
int v34; // r0
GLint params; // [sp+Ch] [bp-20h] BYREF
float v36[2]; // [sp+10h] [bp-1Ch] BYREF
int v37[3]; // [sp+18h] [bp-14h] BYREF
v9 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)a1);
v10 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v9));
v11 = (float)a2 * v10;
v12 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)LODWORD(v10));
v13 = (cocos2d *)(int)v11;
v14 = (float)a3 * COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v12));
glGetIntegerv(0x8CA6u, (GLint *)(a1 + 276));
v16 = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::sharedConfiguration(v15);
if ( cocos2d::CCConfiguration::supportsNPOT(v16) )
{
POT = v13;
v19 = (int)v14;
}
else
{
POT = (cocos2d *)cocos2d::ccNextPOT(v13, v17);
v19 = cocos2d::ccNextPOT((cocos2d *)(int)v14, v20);
}
result = malloc(4 * v19 * (_DWORD)POT);
v22 = result;
if ( result )
{
memset(result, 0, 4 * v19 * (_DWORD)POT);
*(_DWORD *)(a1 + 292) = a4;
*(_DWORD *)(a1 + 336) = v13;
*(_DWORD *)(a1 + 340) = (int)v14;
v23 = (cocos2d::CCTexture2D *)operator new(0x60u);
cocos2d::CCTexture2D::CCTexture2D(v23);
v24 = *(_DWORD *)(a1 + 292);
v25 = (float)(int)v13;
*(_DWORD *)(a1 + 280) = v23;
cocos2d::CCSize::CCSize(v36, v25, (float)(int)v14);
cocos2d::CCTexture2D::initWithData(v23, v22, v24, POT, v19, v36);
glGetIntegerv(0x8CA7u, ¶ms);
v27 = cocos2d::CCConfiguration::sharedConfiguration(v26);
memset(v37, 0, sizeof(v37));
v28 = v27;
std::string::__init(v37, "GL_QCOM", 7u);
v29 = cocos2d::CCConfiguration::checkForGLExtension(v28, (int)v37);
std::string::~string((int)v37);
if ( v29 )
{
v30 = (cocos2d::CCTexture2D *)operator new(0x60u);
cocos2d::CCTexture2D::CCTexture2D(v30);
v31 = *(_DWORD *)(a1 + 292);
*(_DWORD *)(a1 + 284) = v30;
cocos2d::CCSize::CCSize(v36, v25, (float)(int)v14);
cocos2d::CCTexture2D::initWithData(v30, v22, v31, POT, v19, v36);
}
glGenFramebuffers();
glBindFramebuffer();
(*(void (__fastcall **)(_DWORD))(**(_DWORD **)(a1 + 280) + 52))(*(_DWORD *)(a1 + 280));
glFramebufferTexture2D();
if ( a5 )
{
glGenRenderbuffers();
glBindRenderbuffer();
glRenderbufferStorage();
glFramebufferRenderbuffer();
if ( a5 == 35056 )
glFramebufferRenderbuffer();
}
glCheckFramebufferStatus();
cocos2d::CCTexture2D::setAliasTexParameters(*(cocos2d::CCTexture2D **)(a1 + 280));
v32 = *(void (__fastcall **)(int, int))(*(_DWORD *)a1 + 452);
v34 = cocos2d::CCSprite::createWithTexture(*(cocos2d::CCSprite **)(a1 + 280), v33);
v32(a1, v34);
cocos2d::CCObject::release(*(_DWORD **)(a1 + 280));
(*(void (__fastcall **)(_DWORD, int))(**(_DWORD **)(a1 + 264) + 72))(*(_DWORD *)(a1 + 264), -1082130432);
LODWORD(v36[0]) = 1;
LODWORD(v36[1]) = 771;
(*(void (__fastcall **)(_DWORD, int, int))(**(_DWORD **)(a1 + 264) + 540))(*(_DWORD *)(a1 + 264), 1, 771);
glBindRenderbuffer();
glBindFramebuffer();
*(_BYTE *)(a1 + 324) = 0;
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)a1 + 228))(a1, *(_DWORD *)(a1 + 264));
free(v22);
return &dword_0 + 1;
}
return result;
}