Exemple #1
0
		void EffectsManager::CleanInstance()
		{
			if (!s_pEffectsManager) return;

			for (std::map<const char*, Effect*>::const_iterator iter = s_pEffectsManager->_effectManager.begin(); iter != s_pEffectsManager->_effectManager.end();)
			{
				char* pKey = const_cast<char*>(iter->first);
				SAFE_DELETE(pKey);
				Effect* pEffect = (iter++)->second;
				pEffect->Release();
				SAFE_DELETE(pEffect);
			}
			s_pEffectsManager->_effectManager.clear();
			if (s_pEffectsManager)
				delete s_pEffectsManager;
			s_pEffectsManager = nullptr;
		}
Exemple #2
0
Effect* Effect::Create(DeviceManager* pDeviceManager, InputLayoutDesc* pLayoutDesc, char* pFilename, char* pVertexShaderEntry, char* pPixelShaderEntry, char* pGeometryShaderEntry, char* pDomainShaderEntry, char* pHullShaderEntry, bool model5)
{
	HRESULT hr = S_OK;

	Effect* effect = new Effect();

	effect->mpDeviceManager = pDeviceManager;
	
	if(pVertexShaderEntry != NULL)
	{
		if(!effect->Compile(pFilename, pVertexShaderEntry, Target_VertexShader, model5))
		{
			effect->Release();
			delete effect;
			return NULL;
		}
	}

	if(pPixelShaderEntry != NULL)
	{
		if(!effect->Compile(pFilename, pPixelShaderEntry, Target_PixelShader, model5))
		{
			effect->Release();
			delete effect;
			return NULL;
		}
	}

	if(pGeometryShaderEntry != NULL)
	{
		if(!effect->Compile(pFilename, pGeometryShaderEntry, Target_GeometryShader, model5))
		{
			effect->Release();
			delete effect;
			return NULL;
		}
	}

	if( pDomainShaderEntry != NULL)
	{
		if(!effect->Compile(pFilename, pDomainShaderEntry, Target_DomainShader, model5))
		{
			effect->Release();
			delete effect;
			return NULL;
		}
	}

	if(pHullShaderEntry != NULL)
	{
		if(!effect->Compile(pFilename, pHullShaderEntry, Target_HullShader, model5))
		{
			effect->Release();
			delete effect;
			return NULL;
		}
	}

	HR(hr = pDeviceManager->mpDevice->CreateInputLayout( pLayoutDesc->mpDesc, pLayoutDesc->mDescSize, effect->mpVertexByteCode, effect->mVertexByteSize, &(effect->mpInputLayout) ));
	if(hr!=S_OK)
	{
		effect->Release();
		delete effect;
		return NULL;
	}	


	return effect;
}