Beispiel #1
0
/*!***************************************************************************
@Function		PVRTPFXOnLoadTexture
@Input			TextureName
@Output			uiHandle
@Output			uiFlags
@Return			EPVRTError	PVR_SUCCESS on success.
@Description	Callback function on texture load.
*****************************************************************************/
EPVRTError OGLES3MagicLantern::PVRTPFXOnLoadTexture(const CPVRTStringHash& TextureName, GLuint& uiHandle, unsigned int& uiFlags)
{
	/*
		Because we have multiple effects being loaded yet the textures remain the same we can
		efficiently cache texture IDs and only load a texture once but assign it to
		multiple effects.
	*/

	// Check if the texture already exists in the map
	if(m_TextureCache.Exists(TextureName))
	{
		const STextureData& TexData = m_TextureCache[TextureName];
		uiHandle = TexData.uiHandle;
		uiFlags  = TexData.uiFlags;
		return PVR_SUCCESS;
	}

	// Texture is not loaded. Load and add to the map.
	PVRTextureHeaderV3 sHeader;
	if(PVRTTextureLoadFromPVR(TextureName.c_str(), &uiHandle, &sHeader) != PVR_SUCCESS)
		return PVR_FAIL;

	uiFlags = 0;
	if(sHeader.u32NumFaces == 6)
		uiFlags |= PVRTEX_CUBEMAP;

	STextureData& TexData = m_TextureCache[TextureName];
	TexData.uiFlags  = uiFlags;
	TexData.uiHandle = uiHandle;

	return PVR_SUCCESS;
}
/*!***************************************************************************
@Function		PVRTPFXOnLoadTexture
@Input			TextureName
@Output			uiHandle
@Output			uiFlags
@Return			EPVRTError	PVR_SUCCESS on success.
@Description	Callback for texture load.
*****************************************************************************/
EPVRTError OGLES3IntroducingPFX::PVRTPFXOnLoadTexture(const CPVRTStringHash& TextureName, GLuint& uiHandle, unsigned int& uiFlags)
{
	/*
		This is an optional callback function for PVRTPFXEffect and can be used to automate 
		the texture loading process.
		If multiple effects are to be loaded and they share textures it would be
		prudent to have a caching system in place so texture memory is not wasted.
		Please see OGLES3MagicLantern for an example of this.
	*/
	if(PVRTTextureLoadFromPVR(TextureName.String().c_str(), &uiHandle) != PVR_SUCCESS)
		return PVR_FAIL;

	return PVR_SUCCESS;
}
/*!***********************************************************************
@Function			!=
@Input				_Str 	A string to compare with
@Returns			True if they don't match
@Description		!= Operator
*************************************************************************/
bool CPVRTStringHash::operator!=(const CPVRTStringHash& _Str) const
{
	return (m_Hash != _Str.Hash());
}
Beispiel #4
0
/*!***************************************************************************
 @Function		PVRTPFXOnLoadTexture
 @Input			TextureName
 @Output		uiHandle
 @Output		uiFlags
 @Return		EPVRTError			PVR_SUCCESS on success.
 @Description	Callback for texture load.
 *****************************************************************************/
EPVRTError OGLES2MaximumIntensityBlend::PVRTPFXOnLoadTexture(const CPVRTStringHash& TextureName, GLuint& uiHandle, unsigned int& uiFlags)
{
	return PVRTTextureLoadFromPVR(TextureName.String().c_str(), &uiHandle);
}