//
// cocos2d::CCTexturePVR::createGLTexture from 0x100271d10 to 0x100272046 (822 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x1002722b5
//
// 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:27:37 +0000
//
__int64 __fastcall cocos2d::CCTexturePVR::createGLTexture(__int64 a1)
{
unsigned int v1; // r13d
unsigned int v3; // r15d
unsigned int v4; // r14d
GLuint *v5; // r12
__int64 v6; // rdi
__int64 v7; // rdx
__int64 v8; // rcx
__int64 v9; // r8
__int64 v10; // rax
GLenum v11; // r12d
__int64 v12; // rax
__int64 v13; // rdi
__int64 v14; // rsi
unsigned __int64 v15; // rdx
__int64 v16; // rcx
__int64 v17; // r8
unsigned int v18; // r14d
GLsizei *v19; // r12
unsigned __int64 v20; // r15
__int64 v21; // rax
int v22; // eax
unsigned int v23; // r12d
unsigned int v24; // r14d
const GLvoid **v25; // rbx
unsigned __int64 v26; // r15
GLenum Error; // eax
int v28; // eax
int v29; // ecx
GLenum format; // [rsp+8h] [rbp-48h]
GLenum type; // [rsp+10h] [rbp-40h]
__int64 v33; // [rsp+18h] [rbp-38h]
GLenum internalformat; // [rsp+24h] [rbp-2Ch]
GLint internalformata; // [rsp+24h] [rbp-2Ch]
if ( !*(_DWORD *)(a1 + 312) )
goto LABEL_39;
v3 = *(_DWORD *)(a1 + 316);
v4 = *(_DWORD *)(a1 + 320);
v5 = (GLuint *)(a1 + 324);
v6 = *(unsigned int *)(a1 + 324);
if ( (_DWORD)v6 )
cocos2d::ccGLDeleteTexture(v6);
glPixelStorei(0xCF5u, 1);
glGenTextures(1, v5);
cocos2d::ccGLBindTexture2D(*(_DWORD *)(a1 + 324));
glTexParameteri(0xDE1u, 0x2801u, ((*(_DWORD *)(a1 + 312) != 1) << 8) | 0x2601);
glTexParameteri(0xDE1u, 0x2800u, 9729);
glTexParameteri(0xDE1u, 0x2802u, 33071);
glTexParameteri(0xDE1u, 0x2803u, 33071);
if ( !*(_DWORD *)(a1 + 312) )
goto LABEL_39;
v10 = *(_QWORD *)(a1 + 336);
v11 = *(_DWORD *)v10;
if ( !*(_BYTE *)(v10 + 16) )
{
v1 = 0;
internalformata = *(_DWORD *)v10;
v33 = a1;
type = *(_DWORD *)(v10 + 8);
format = *(_DWORD *)(v10 + 4);
glTexImage2D(0xDE1u, 0, v11, v3, v4, 0, format, type, *(const GLvoid **)(a1 + 56));
if ( glGetError() )
return v1;
if ( *(_DWORD *)(a1 + 312) >= 2u )
{
v23 = v4 >> 1;
if ( v4 < 2 )
v23 = 1;
v24 = v3 >> 1;
if ( v3 < 2 )
v24 = 1;
v25 = (const GLvoid **)(a1 + 72);
v26 = 1;
do
{
glTexImage2D(0xDE1u, v26, internalformata, v24, v23, 0, format, type, *v25);
if ( v24 == v23 )
sub_1005A4800(v24);
Error = glGetError();
LOBYTE(v1) = Error == 0;
if ( Error )
return v1;
v28 = v24 >> 1;
if ( v24 < 2 )
v28 = 1;
v29 = v23 >> 1;
if ( v23 < 2 )
v29 = 1;
++v26;
v25 += 2;
v24 = v28;
v23 = v29;
}
while ( v26 < *(unsigned int *)(v33 + 312) );
}
LABEL_39:
LOBYTE(v1) = 1;
return v1;
}
v12 = cocos2d::CCConfiguration::sharedConfiguration(3553, 10243, v7, v8, v9);
if ( !(unsigned __int8)cocos2d::CCConfiguration::supportsPVRTC(v12) )
return 0;
v1 = 0;
v13 = 3553;
v14 = 0;
internalformat = v11;
glCompressedTexImage2D(0xDE1u, 0, v11, v3, v4, 0, *(_DWORD *)(a1 + 64), *(const GLvoid **)(a1 + 56));
if ( !glGetError() )
{
if ( *(_DWORD *)(a1 + 312) >= 2u )
{
v1 = v4 >> 1;
if ( v4 < 2 )
v1 = 1;
v18 = v3 >> 1;
if ( v3 < 2 )
v18 = 1;
v19 = (GLsizei *)(a1 + 80);
v20 = 1;
while ( 1 )
{
v21 = cocos2d::CCConfiguration::sharedConfiguration(v13, v14, v15, v16, v17);
if ( !(unsigned __int8)cocos2d::CCConfiguration::supportsPVRTC(v21) )
return 0;
v13 = 3553;
v14 = (unsigned int)v20;
glCompressedTexImage2D(0xDE1u, v20, internalformat, v18, v1, 0, *v19, *((const GLvoid **)v19 - 1));
if ( v18 == v1 )
{
v13 = v18;
sub_1005A4800(v18);
}
if ( glGetError() )
return 0;
v22 = v18 >> 1;
if ( v18 < 2 )
v22 = 1;
v16 = v1 >> 1;
if ( v1 < 2 )
v16 = 1;
++v20;
v15 = *(unsigned int *)(a1 + 312);
v19 += 4;
v18 = v22;
v1 = v16;
if ( v20 >= v15 )
goto LABEL_39;
}
}
goto LABEL_39;
}
return v1;
}