示例#1
0
////////////////////////////////////////////////////////////
/// Construit le shader à partir des 2 fichiers
/// <name>.vert
/// <name>.frag
///
/// \param shaderFile_ : fichier vertex shader : <name>.vertexshader
///
////////////////////////////////////////////////////////////
GLShader::GLShader(IFile *pFile_)
{
	std::string fragmentFile = pFile_->Filename();

	size_t pos = fragmentFile.find(IRenderer::Get().GetShaderFileExtension());

	if (pos != std::string::npos)
	{
		fragmentFile = fragmentFile.substr(0, pos) + ".frag";
		IFile *pFragFile = MediaManager::Instance().FindMedia(fragmentFile, false);

		if (pFragFile == nullptr)
		{
			throw CLoadingFailed(fragmentFile, "GLShader() : Can't find the fragment shader (maybe add a reference to the right directory ?)");
		}

		if (pFragFile->Exists() == false)
		{
			throw CLoadingFailed(fragmentFile, "GLShader() : The fragment shader doesn't exist");
		}

		m_ProgramID = LoadShaderFrombuffer(pFile_->GetBuffer(), pFragFile->GetBuffer());

		DELETE_AO pFragFile;
	}
	else
	{
		CA_ERROR("GLShader() : Can't find the character '%s' in the filename '%s' to get the fragment shader.", 
			IRenderer::Get().GetShaderFileExtension(), pFile_->Filename().c_str());
	}
}
示例#2
0
/////////////////////////////////////////////////////////////
/// Cherche un fichier dans les répertoires de recherche
///
/// \param Filename : Chemin du media
///
/// \return Chemin complet du media, exception si non trouvé
///
////////////////////////////////////////////////////////////
IFile *MediaManager::FindMedia(const char *fileName_, bool isBinary_) const
{
    for (std::set<std::string>::const_iterator i = m_Paths.begin(); 
		i != m_Paths.end(); 
		++i)
    {
		std::string path = m_RootPath + *i + fileName_;
		//TODO : set if open in BINARY MODE or not
        IFile *pRetFile = IOManager::OpenFile(path, FileMode::READ | (isBinary_ == true ? FileMode::BINARY : 0));

        if (pRetFile->Exists() == true)
		{
            return pRetFile;
		}
		else
		{
			DELETE_AO pRetFile;
		}
    }

    return nullptr;
}