Example #1
0
/** Get a shader file. If the shader is not already in the cache it will be loaded and cached.
 *  \param file Filename of the shader to load.
 *  \param type Type of the shader.
 */
GLuint ShaderFilesManager::getShaderFile(const std::string &file, unsigned type)
{
    // found in cache
    auto it = m_shader_files_loaded.find(file);
    if (it != m_shader_files_loaded.end())
        return it->second;

   // add to the cache now
   return addShaderFile(file, type);
}   // getShaderFile
/** Get a shader file. If the shader is not already in the cache it will be
 *  loaded and cached.
 *  \param file Filename of the shader to load.
 *  \param type Type of the shader.
 */
ShaderFilesManager::SharedShader ShaderFilesManager::getShaderFile
    (const std::string &file, unsigned type)
{
    const std::string full_path = (file.find('/') != std::string::npos ||
        file.find('\\') != std::string::npos) ?
        file : std::string(file_manager->getFileSystem()->getAbsolutePath
        (file_manager->getShadersDir().c_str()).c_str()) + file;
    // found in cache
    auto it = m_shader_files_loaded.find(full_path);
    if (it != m_shader_files_loaded.end())
        return it->second;

    // add to the cache now
    return addShaderFile(full_path, type);
}   // getShaderFile