//
// cocos2d::CCRenderTexture::initWithWidthAndHeight from 0x180062020 to 0x1800624cf (1199 bytes)
//
// 6 xrefs:
// > cocos2d::CCRenderTexture::create @ 0x180061bfe
// > cocos2d::CCRenderTexture::create @ 0x180061c96
// > cocos2d::CCRenderTexture::create @ 0x180061d2d
// > cocos2d::CCRenderTexture::initWithWidthAndHeight @ 0x18006200c
// > ??> @ 0x18014cf68
// > ??> @ 0x1801bd720
//
// This function is hookable on this platform (idp: pc, 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:21:51 +0000
//
// Hidden C++ exception states: #wind=3
__int64 __fastcall cocos2d::CCRenderTexture::initWithWidthAndHeight(
__int64 *a1,
int a2,
int a3,
int a4,
unsigned int a5)
{
cocos2d::CCDirector *v9; // rax
int v10; // ebx
cocos2d::CCDirector *v11; // rax
int v12; // edi
cocos2d::CCConfiguration *v13; // rax
unsigned int v14; // r14d
unsigned int v15; // r15d
void *v16; // rax
void *v17; // rbp
cocos2d::CCTexture2D *v18; // rax
__int64 v19; // rax
float v20; // xmm6_4
float v21; // xmm7_4
unsigned int v22; // ebx
__int64 v23; // rdi
float *v24; // rax
struct cocos2d::CCConfiguration *v25; // rax
char v26; // bl
void *v27; // r8
cocos2d::CCTexture2D *v28; // rax
__int64 v29; // rax
unsigned int v30; // ebx
__int64 v31; // rdi
float *v32; // rax
unsigned int v33; // eax
__int64 v34; // rbx
struct cocos2d::CCSprite *v35; // rax
unsigned __int8 v37; // [rsp+30h] [rbp-98h]
__int64 v38; // [rsp+38h] [rbp-90h] BYREF
GLint params; // [rsp+40h] [rbp-88h] BYREF
void *Block[2]; // [rsp+48h] [rbp-80h] BYREF
__m128i si128; // [rsp+58h] [rbp-70h]
v37 = 0;
v9 = cocos2d::CCDirector::sharedDirector();
v10 = (int)(float)(cocos2d::CCDirector::getContentScaleFactor(v9) * (float)a2);
v11 = cocos2d::CCDirector::sharedDirector();
v12 = (int)(float)(cocos2d::CCDirector::getContentScaleFactor(v11) * (float)a3);
glGetIntegerv(0x8CA6u, (GLint *)a1 + 84);
v13 = cocos2d::CCConfiguration::sharedConfiguration();
if ( cocos2d::CCConfiguration::supportsNPOT(v13) )
{
v14 = v10;
v15 = v12;
}
else
{
v14 = sub_1800992B0((unsigned int)v10);
v15 = sub_1800992B0((unsigned int)v12);
}
v16 = malloc((int)(4 * v14 * v15));
v17 = v16;
if ( v16 )
{
memset(v16, 0, (int)(4 * v14 * v15));
*((_DWORD *)a1 + 92) = a4;
*((_DWORD *)a1 + 103) = v10;
*((_DWORD *)a1 + 104) = v12;
v18 = (cocos2d::CCTexture2D *)sub_1800E4AC0(0x68u);
v38 = (__int64)v18;
if ( v18 )
v19 = cocos2d::CCTexture2D::CCTexture2D(v18);
else
v19 = 0;
a1[43] = v19;
if ( v19 )
{
v20 = (float)v12;
v21 = (float)v10;
v22 = *((_DWORD *)a1 + 92);
v23 = v19;
v24 = kmVec2Fill((float *)&v38, v21, v20);
cocos2d::CCTexture2D::initWithData(v23, v17, v22, v14, v15, v24);
glGetIntegerv(0x8CA7u, ¶ms);
HIWORD(Block[1]) = 0;
si128 = _mm_load_si128((const __m128i *)&xmmword_1800F1920);
qmemcpy(Block, "GL_QCO", 6);
*(void **)((char *)Block + 6) = (void *)(unsigned __int8)aGlQcom[6];
v25 = cocos2d::CCConfiguration::sharedConfiguration();
v26 = cocos2d::CCConfiguration::checkForGLExtension(v25, Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v27 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v27 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v27 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v27);
}
if ( !v26 )
goto LABEL_20;
v28 = (cocos2d::CCTexture2D *)sub_1800E4AC0(0x68u);
v38 = (__int64)v28;
if ( v28 )
v29 = cocos2d::CCTexture2D::CCTexture2D(v28);
else
v29 = 0;
a1[44] = v29;
if ( v29 )
{
v30 = *((_DWORD *)a1 + 92);
v31 = v29;
v32 = kmVec2Fill((float *)&v38, v21, v20);
cocos2d::CCTexture2D::initWithData(v31, v17, v30, v14, v15, v32);
LABEL_20:
_glewGenFramebuffers(1);
_glewBindFramebuffer(36160, *((unsigned int *)a1 + 82));
v33 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1[43] + 96LL))(a1[43]);
_glewFramebufferTexture2D(36160, 36064, 3553, v33, 0);
if ( a5 )
{
_glewGenRenderbuffers(1, (char *)a1 + 332);
_glewBindRenderbuffer(36161, *((unsigned int *)a1 + 83));
_glewRenderbufferStorage(36161, a5, v14, v15);
_glewFramebufferRenderbuffer(36160, 36096, 36161, *((unsigned int *)a1 + 83));
if ( a5 == 35056 )
_glewFramebufferRenderbuffer(36160, 36128, 36161, *((unsigned int *)a1 + 83));
}
_glewCheckFramebufferStatus(36160);
cocos2d::CCTexture2D::setAliasTexParameters((cocos2d::CCTexture2D *)a1[43]);
v34 = *a1;
v35 = cocos2d::CCSprite::createWithTexture((struct cocos2d::CCTexture2D *)a1[43]);
(*(void (__fastcall **)(__int64 *, struct cocos2d::CCSprite *))(v34 + 896))(a1, v35);
cocos2d::CCObject::release((cocos2d::CCObject *)a1[43]);
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1[40] + 136LL))(a1[40]);
v38 = 0x30300000001LL;
(**(void (__fastcall ***)(__int64, __int64))(a1[40] + 344))(a1[40] + 344, 0x30300000001LL);
_glewBindRenderbuffer(36161, (unsigned int)params);
_glewBindFramebuffer(36160, *((unsigned int *)a1 + 84));
*((_BYTE *)a1 + 400) = 0;
(*(void (__fastcall **)(__int64 *, __int64))(*a1 + 464))(a1, a1[40]);
v37 = 1;
}
}
free(v17);
}
return v37;
}