/*!*************************************************************************** @Function LoadEffect @Output ppEffect @Input pszEffectName @Input pszFileName @Return bool @Description Loads a PFX Effect. *****************************************************************************/ bool OGLES3Skybox2::LoadEffect( CPVRTPFXEffect **ppEffect, const char * pszEffectName, const char *pszFileName ) { if(!ppEffect) return false; unsigned int nUnknownUniformCount; CPVRTString error; CPVRTPFXEffect* pEffect = *ppEffect; // Load an effect from the file if(!pEffect) { *ppEffect = new CPVRTPFXEffect(); pEffect = *ppEffect; if(!pEffect) { delete m_pEffectParser; PVRShellSet(prefExitMessage, "Failed to create effect.\n"); return false; } } if(pEffect->Load(*m_pEffectParser, pszEffectName, pszFileName, NULL, nUnknownUniformCount, &error) != PVR_SUCCESS) { PVRShellSet(prefExitMessage, error.c_str()); return false; } if(nUnknownUniformCount) { PVRShellOutputDebug(error.c_str()); PVRShellOutputDebug("Unknown uniform semantic count: %d\n", nUnknownUniformCount); } /* Set the textures for each effect */ unsigned int i,j ; const CPVRTArray<SPVRTPFXTexture>& sTex = pEffect->GetTextureArray(); for(i = 0; i < sTex.GetSize(); ++i) { for(j = 0; j < g_ui32TexNo; ++j) { int iTexIdx = m_pEffectParser->FindTextureByName(sTex[i].Name); const CPVRTStringHash& FileName = m_pEffectParser->GetTexture(iTexIdx)->FileName; if(FileName == g_aszTextureNames[j]) { if(j == 3 || j == 4) pEffect->SetTexture(i, m_ui32TextureIDs[j], PVRTEX_CUBEMAP); else pEffect->SetTexture(i, m_ui32TextureIDs[j]); break; } } } return true; }
/*!*************************************************************************** @Function ChangeSkyboxTo @Output pEffect @Input ui32NewSkybox @Description Changes the skybox to use the selected effect. *****************************************************************************/ void OGLES3Skybox2::ChangeSkyboxTo(CPVRTPFXEffect *pEffect, GLuint ui32NewSkybox) { const CPVRTArray<SPVRTPFXTexture>& sTex = pEffect->GetTextureArray(); for(unsigned int i = 0; i < sTex.GetSize(); ++i) { int iTexIdx = m_pEffectParser->FindTextureByName(sTex[i].Name); const CPVRTStringHash& FileName = m_pEffectParser->GetTexture(iTexIdx)->FileName; if(FileName == g_aszTextureNames[3]) { pEffect->SetTexture(i, ui32NewSkybox, PVRTEX_CUBEMAP); return; } } }