//
// cocos2d::CCRenderTexture::newCCImage from 0x1800624e0 to 0x1800626e7 (519 bytes)
//
// 4 xrefs:
// > cocos2d::CCRenderTexture::saveToFile @ 0x1800626ff
// > cocos2d::CCRenderTexture::saveToFile @ 0x18006277c
// > ??> @ 0x18014cf68
// > ??> @ 0x1801bd72c
//
// 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=1
struct cocos2d::CCImage *__fastcall cocos2d::CCRenderTexture::newCCImage(cocos2d::CCRenderTexture *this, char a2)
{
cocos2d::CCTexture2D *v3; // rcx
float *ContentSizeInPixels; // rax
GLsizei v6; // ebp
GLsizei v7; // r12d
cocos2d::CCImage *v8; // rax
__int64 v9; // rbx
int v10; // r15d
char *v11; // r14
char *pixels; // r13
char *v13; // rcx
cocos2d::CCDirector *v14; // rbx
size_t v15; // rsi
char *v16; // rdi
char *v17; // rbx
__int64 v18; // rbp
char *v19; // rdx
__int64 v20; // [rsp+40h] [rbp-58h]
GLsizei v22; // [rsp+B0h] [rbp+18h]
__int64 v23; // [rsp+B8h] [rbp+20h]
v3 = *((cocos2d::CCTexture2D **)this + 43);
if ( !v3 )
return nullptr;
ContentSizeInPixels = (float *)cocos2d::CCTexture2D::getContentSizeInPixels(v3);
v6 = (int)*ContentSizeInPixels;
v22 = v6;
v7 = (int)ContentSizeInPixels[1];
v8 = (cocos2d::CCImage *)sub_1800E4AC0(0x50u);
if ( v8 )
v9 = cocos2d::CCImage::CCImage(v8);
else
v9 = 0;
v23 = v9;
v10 = 4 * v6 * v7;
v11 = (char *)sub_1800E4C6C(v10);
if ( v11 )
{
pixels = (char *)sub_1800E4C6C(v10);
if ( pixels )
{
cocos2d::CCRenderTexture::begin(this);
glPixelStorei(0xD05u, 1);
glReadPixels(0, 0, v6, v7, 0x1908u, 0x1401u, pixels);
v14 = cocos2d::CCDirector::sharedDirector();
_glewBindFramebuffer(36160, *((unsigned int *)this + 84));
cocos2d::CCDirector::setViewport(v14);
kmGLMatrixMode(5889);
kmGLPopMatrix();
kmGLMatrixMode(5888);
kmGLPopMatrix();
if ( a2 )
{
if ( v7 > 0 )
{
v15 = 4 * v6;
v16 = v11;
v20 = -4 * v6;
v17 = &pixels[v6 * (4 * v7 - 4)];
v18 = (unsigned int)v7;
do
{
memcpy(v16, v17, v15);
v17 += v20;
v16 += v15;
--v18;
}
while ( v18 );
v6 = v22;
}
v19 = v11;
}
else
{
v19 = pixels;
}
v9 = v23;
cocos2d::CCImage::initWithImageData(v23, v19, (unsigned int)v10, 4, v6, v7, 8, 0);
j_j_free_0(v11);
v13 = pixels;
}
else
{
v13 = v11;
}
j_j_free_0(v13);
}
return (struct cocos2d::CCImage *)v9;
}