//
// CCSpriteWithHue::initShader from 0x1005effc0 to 0x1005f0170 (432 bytes)
//
// 3 xrefs:
// > CCSpriteWithHue::createWithTexture @ 0x1005efdff
// > CCSpriteWithHue::initWithTexture @ 0x1005eff85
// > CCSpriteGrayscale::createWithTexture @ 0x1005f0fff
//
// 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
//
void __fastcall CCSpriteWithHue::initShader(CCSpriteWithHue *a1)
{
cocos2d::CCShaderCache *v1; // r14
const char *v2; // rsi
cocos2d::CCGLProgram *v3; // r14
const char *v4; // r15
const char *v5; // rax
cocos2d::CCShaderCache *v6; // r15
const char *v7; // rdx
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
char v11; // [rsp+0h] [rbp-30h] BYREF
_BYTE v12[15]; // [rsp+1h] [rbp-2Fh] BYREF
void *__p; // [rsp+10h] [rbp-20h]
v1 = cocos2d::CCShaderCache::sharedShaderCache();
((void (__fastcall *)(char *, CCSpriteWithHue *))a1->getShaderName)(&v11, a1);
if ( (v11 & 1) != 0 )
v2 = (const char *)__p;
else
v2 = v12;
v3 = cocos2d::CCShaderCache::programForKey(v1, v2);
if ( (v11 & 1) != 0 )
operator delete(__p);
if ( !v3 )
{
v3 = (cocos2d::CCGLProgram *)operator new(0x78u);
cocos2d::CCGLProgram::CCGLProgram((__int64)v3);
v4 = off_10099C910[0];
v5 = (const char *)((__int64 (__fastcall *)(CCSpriteWithHue *))a1->shaderBody)(a1);
cocos2d::CCGLProgram::initWithVertexShaderByteArray(v3, v4, v5);
cocos2d::CCGLProgram::addAttribute(v3, "a_position", 0);
cocos2d::CCGLProgram::addAttribute(v3, "a_color", 1u);
cocos2d::CCGLProgram::addAttribute(v3, "a_texCoord", 2u);
cocos2d::CCGLProgram::link(v3);
cocos2d::CCGLProgram::updateUniforms(v3);
v6 = cocos2d::CCShaderCache::sharedShaderCache();
((void (__fastcall *)(char *, CCSpriteWithHue *))a1->getShaderName)(&v11, a1);
if ( (v11 & 1) != 0 )
v7 = (const char *)__p;
else
v7 = v12;
cocos2d::CCShaderCache::addProgram(v6, v3, v7);
if ( (v11 & 1) != 0 )
operator delete(__p);
cocos2d::CCObject::release(v3);
}
((void (__fastcall *)(CCSpriteWithHue *, cocos2d::CCGLProgram *))a1->setShaderProgram)(a1, v3);
v8 = ((__int64 (__fastcall *)(CCSpriteWithHue *))a1->getShaderProgram)(a1);
a1->m_uHueLoc = glGetUniformLocation(*(_DWORD *)(v8 + 56), "u_hue");
v9 = ((__int64 (__fastcall *)(CCSpriteWithHue *))a1->getShaderProgram)(a1);
a1->m_uAlphaLoc = glGetUniformLocation(*(_DWORD *)(v9 + 56), "u_alpha");
v10 = ((__int64 (__fastcall *)(CCSpriteWithHue *))a1->getShaderProgram)(a1);
a1->m_uLumLoc = glGetUniformLocation(*(_DWORD *)(v10 + 56), "u_lum");
((void (__fastcall *)(CCSpriteWithHue *))a1->updateColor)(a1);
}