Пример #1
0
bool CEffectFileDirectX::begin(bool bApplyParam, DWORD dwFlag, bool bForceBegin )
{
	IScene* pScene = CGlobals::GetEffectManager()->GetScene();
	if(m_pEffect!=NULL)
	{
		if(bApplyParam)
		{
			// set the lighting parameters
			// from the global light manager
			applyGlobalLightingData(pScene->GetSunLight());

			// set the camera matrix
			applyCameraMatrices();
		}
		
		if(bForceBegin|| !m_bSharedMode)
		{
			HRESULT result = m_pEffect->Begin(0, dwFlag);
			if( SUCCEEDED( result ) )
			{
				m_bIsBegin = true;
				return true;
			}
			else
			{
				OUTPUT_LOG("error: CEffectFileDirectX::begin failed: %s \n", m_filename.c_str());
				return false;
			}
		}
		return true;
	}
	else
		return false;
}
Пример #2
0
bool ParaEngine::CEffectFileOpenGL::begin(bool bApplyParam /*= true*/, DWORD flag /*= 0*/)
{
	IScene* pScene = CGlobals::GetEffectManager()->GetScene();
	auto program = GetGLProgram();
	if (program != 0)
	{
		if (m_programs.size() == 1)
			program->use();
		else
		{
			// TODO: multiple pass effect in opengl is implemented as shader arrays.
			// uniform values are currently NOT shared among different passes like directX.
			// hence DO NOT set any uniform between begin() and beginPass().
			// TODO: In future: uniform values should be cached until Commit() is called.
			program->use();
		}

		if (bApplyParam)
		{
			// set the lighting parameters
			// from the global light manager
			applyGlobalLightingData(pScene->GetSunLight());

			// set the camera matrix
			applyCameraMatrices();
		}

		m_bIsBegin = true;
		return true;
	}
	else
		return false;
}