//
// cocos2d::CCTexturePVR::createGLTexture from 0x100285160 to 0x100285496 (822 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x100285705
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
bool __fastcall cocos2d::CCTexturePVR::createGLTexture(cocos2d::CCTexturePVR *a1)
{
unsigned int m_uUnknown; // r15d
unsigned int m_unknown2; // r14d
GLuint *p_m_nZOrder; // r12
unsigned int m_nZOrder; // edi
cocos2d::CCTexturePVR_vtbl *v6; // rax
GLenum copyWithZone; // r12d
cocos2d::CCConfiguration *v8; // rax
bool v9; // r13
unsigned int v10; // r13d
unsigned int v11; // r14d
GLsizei *p_m_uAutoReleaseCount; // r12
unsigned __int64 v13; // r15
cocos2d::CCConfiguration *v14; // rax
int v15; // eax
int v16; // ecx
unsigned int v17; // r12d
unsigned int v18; // r14d
const GLvoid **p_m_nTag; // rbx
unsigned __int64 v20; // r15
GLenum Error; // eax
int v22; // eax
int v23; // ecx
GLenum format; // [rsp+8h] [rbp-48h]
GLenum type; // [rsp+10h] [rbp-40h]
cocos2d::CCTexturePVR *v27; // [rsp+18h] [rbp-38h]
GLenum internalformat; // [rsp+24h] [rbp-2Ch]
GLint internalformata; // [rsp+24h] [rbp-2Ch]
if ( !a1[5].m_uIndexInArray )
return 1;
m_uUnknown = a1[5].m_uUnknown;
m_unknown2 = a1[5].m_unknown2;
p_m_nZOrder = (GLuint *)&a1[5].m_nZOrder;
m_nZOrder = a1[5].m_nZOrder;
if ( m_nZOrder )
cocos2d::ccGLDeleteTexture(m_nZOrder);
glPixelStorei(0xCF5u, 1);
glGenTextures(1, p_m_nZOrder);
cocos2d::ccGLBindTexture2D(a1[5].m_nZOrder);
glTexParameteri(0xDE1u, 0x2801u, ((a1[5].m_uIndexInArray != 1) << 8) | 0x2601);
glTexParameteri(0xDE1u, 0x2800u, 9729);
glTexParameteri(0xDE1u, 0x2802u, 33071);
glTexParameteri(0xDE1u, 0x2803u, 33071);
if ( !a1[5].m_uIndexInArray )
return 1;
v6 = a1[6].__vftable;
copyWithZone = (GLenum)v6->copyWithZone;
if ( !LOBYTE(v6->~CCTexturePVR_0) )
{
v9 = 0;
internalformata = (GLint)v6->copyWithZone;
v27 = a1;
type = (GLenum)v6->~CCTexturePVR;
format = HIDWORD(v6->copyWithZone);
glTexImage2D(0xDE1u, 0, copyWithZone, m_uUnknown, m_unknown2, 0, format, type, a1[1].__vftable);
if ( glGetError() )
return v9;
if ( a1[5].m_uIndexInArray >= 2u )
{
v17 = m_unknown2 >> 1;
if ( m_unknown2 < 2 )
v17 = 1;
v18 = m_uUnknown >> 1;
if ( m_uUnknown < 2 )
v18 = 1;
p_m_nTag = (const GLvoid **)&a1[1].m_nTag;
v20 = 1;
while ( 1 )
{
glTexImage2D(0xDE1u, v20, internalformata, v18, v17, 0, format, type, *p_m_nTag);
if ( v18 == v17 )
sub_1005772B0(v18);
Error = glGetError();
v9 = Error == 0;
if ( Error )
break;
v22 = v18 >> 1;
if ( v18 < 2 )
v22 = 1;
v23 = v17 >> 1;
if ( v17 < 2 )
v23 = 1;
++v20;
p_m_nTag += 2;
v18 = v22;
v17 = v23;
if ( v20 >= (unsigned int)v27[5].m_uIndexInArray )
return 1;
}
return v9;
}
return 1;
}
v8 = cocos2d::CCConfiguration::sharedConfiguration();
if ( !cocos2d::CCConfiguration::supportsPVRTC(v8) )
return 0;
v9 = 0;
internalformat = copyWithZone;
glCompressedTexImage2D(0xDE1u, 0, copyWithZone, m_uUnknown, m_unknown2, 0, a1[1].m_uID, a1[1].__vftable);
if ( !glGetError() )
{
if ( a1[5].m_uIndexInArray >= 2u )
{
v10 = m_unknown2 >> 1;
if ( m_unknown2 < 2 )
v10 = 1;
v11 = m_uUnknown >> 1;
if ( m_uUnknown < 2 )
v11 = 1;
p_m_uAutoReleaseCount = (GLsizei *)&a1[1].m_uAutoReleaseCount;
v13 = 1;
while ( 1 )
{
v14 = cocos2d::CCConfiguration::sharedConfiguration();
if ( !cocos2d::CCConfiguration::supportsPVRTC(v14) )
break;
glCompressedTexImage2D(
0xDE1u,
v13,
internalformat,
v11,
v10,
0,
*p_m_uAutoReleaseCount,
*((const GLvoid **)p_m_uAutoReleaseCount - 1));
if ( v11 == v10 )
sub_1005772B0(v11);
if ( glGetError() )
break;
v15 = v11 >> 1;
if ( v11 < 2 )
v15 = 1;
v16 = v10 >> 1;
if ( v10 < 2 )
v16 = 1;
++v13;
p_m_uAutoReleaseCount += 4;
v11 = v15;
v10 = v16;
if ( v13 >= (unsigned int)a1[5].m_uIndexInArray )
return 1;
}
return 0;
}
return 1;
}
return v9;
}