//
// cocos2d::CCRenderTexture::initWithWidthAndHeight from 0x1006c8140 to 0x1006c84ad (877 bytes)
//
// 4 xrefs:
// > cocos2d::CCRenderTexture::create_1 @ 0x1006c8019
// > cocos2d::CCRenderTexture::initWithWidthAndHeight_1 @ 0x1006c8068
// > cocos2d::CCRenderTexture::create @ 0x1006c80ef
// > cocos2d::CCRenderTexture::create_2 @ 0x1006c8554
//
// 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 12:35:35 +0000
//
bool __fastcall cocos2d::CCRenderTexture::initWithWidthAndHeight(_QWORD *a1, int a2, int a3, int a4, GLenum a5)
{
__int64 v6; // rax
int v7; // r12d
__int64 v8; // rax
int v9; // r13d
__int64 v10; // rax
char v11; // al
__int64 v12; // r14
__int64 v13; // rcx
size_t v14; // r14
void *v15; // rax
GLvoid *v16; // r15
void *v17; // r14
float v18; // xmm0_4
unsigned int v19; // r12d
__int64 v20; // rax
bool v21; // r14
GLenum v22; // r12d
void *v23; // r14
unsigned int v24; // r12d
GLuint v25; // eax
char *v26; // rax
void *v28[3]; // [rsp+0h] [rbp-60h] BYREF
GLint params; // [rsp+18h] [rbp-48h] BYREF
float v30; // [rsp+1Ch] [rbp-44h]
GLsizei height[2]; // [rsp+20h] [rbp-40h]
GLenum internalformat; // [rsp+28h] [rbp-38h]
float v33; // [rsp+2Ch] [rbp-34h]
GLsizei width[12]; // [rsp+30h] [rbp-30h]
internalformat = a5;
v33 = *(float *)&a4;
v6 = cocos2d::CCDirector::sharedDirector();
v7 = (int)(float)(sub_100479350(v6) * (float)a2);
v8 = cocos2d::CCDirector::sharedDirector();
v9 = (int)(float)(sub_100479350(v8) * (float)a3);
glGetIntegerv(0x8CA6u, (GLint *)a1 + 84);
v10 = cocos2d::CCConfiguration::sharedConfiguration();
v11 = cocos2d::CCConfiguration::supportsNPOT(v10);
v12 = (unsigned int)v7;
v13 = (unsigned int)v9;
if ( !v11 )
{
v12 = sub_1005A4800(v7);
v13 = sub_1005A4800(v9);
}
*(_QWORD *)width = v12;
*(_QWORD *)height = v13;
v14 = 4 * (int)v13 * (int)v12;
v15 = malloc(v14);
v16 = v15;
if ( v15 )
{
__bzero(v15, v14);
*((float *)a1 + 92) = v33;
*((_DWORD *)a1 + 103) = v7;
*((_DWORD *)a1 + 104) = v9;
v17 = operator new(0x68u);
sub_10046C920((__int64)v17);
a1[43] = v17;
v18 = (float)v7;
v19 = *((_DWORD *)a1 + 92);
v33 = v18;
v30 = (float)v9;
sub_100278260((float *)v28, v18, (float)v9);
cocos2d::CCTexture2D::initWithData((__int64)v17, v16, v19, width[0], height[0], v28);
glGetIntegerv(0x8CA7u, ¶ms);
v20 = cocos2d::CCConfiguration::sharedConfiguration();
LOBYTE(v28[0]) = 14;
strcpy((char *)v28 + 1, "GL_QCOM");
v21 = cocos2d::CCConfiguration::checkForGLExtension(v20, (__int64)v28);
v22 = internalformat;
if ( ((__int64)v28[0] & 1) != 0 )
operator delete(v28[2]);
if ( v21 )
{
v23 = operator new(0x68u);
sub_10046C920((__int64)v23);
a1[44] = v23;
v24 = *((_DWORD *)a1 + 92);
sub_100278260((float *)v28, v33, v30);
cocos2d::CCTexture2D::initWithData((__int64)v23, v16, v24, width[0], height[0], v28);
v22 = internalformat;
}
glGenFramebuffers(1, (GLuint *)a1 + 82);
glBindFramebuffer(0x8D40u, *((_DWORD *)a1 + 82));
v25 = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)a1[43] + 104LL))(a1[43]);
glFramebufferTexture2D(0x8D40u, 0x8CE0u, 0xDE1u, v25, 0);
if ( v22 )
{
glGenRenderbuffers(1, (GLuint *)a1 + 83);
glBindRenderbuffer(0x8D41u, *((_DWORD *)a1 + 83));
glRenderbufferStorage(0x8D41u, v22, width[0], height[0]);
glFramebufferRenderbuffer(0x8D40u, 0x8D00u, 0x8D41u, *((_DWORD *)a1 + 83));
if ( v22 == 35056 )
glFramebufferRenderbuffer(0x8D40u, 0x8D20u, 0x8D41u, *((_DWORD *)a1 + 83));
}
glCheckFramebufferStatus(0x8D40u);
cocos2d::CCTexture2D::setAliasTexParameters(a1[43]);
v26 = cocos2d::CCSprite::createWithTexture_1(a1[43]);
(*(void (__fastcall **)(_QWORD *, char *))(*a1 + 904LL))(a1, v26);
cocos2d::CCObject::release((_DWORD *)a1[43]);
(*(void (__fastcall **)(_QWORD, float))(*(_QWORD *)a1[40] + 144LL))(a1[40], -1.0);
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)a1[40] + 1080LL))(a1[40], 0x30300000001LL);
glBindRenderbuffer(0x8D41u, params);
glBindFramebuffer(0x8D40u, *((_DWORD *)a1 + 84));
*((_BYTE *)a1 + 400) = 0;
(*(void (__fastcall **)(_QWORD *, _QWORD))(*a1 + 456LL))(a1, a1[40]);
free(v16);
}
return v16 != nullptr;
}