Beispiel #1
0
FeShader *FePresent::add_shader( FeShader::Type type, const char *shader1, const char *shader2 )
{
    std::string path;
    m_feSettings->get_path( FeSettings::Current, path );

    std::string s1 = clean_path( shader1 );

    m_scriptShaders.push_back( new FeShader() );
    FeShader *sh = m_scriptShaders.back();

    if ( !is_relative_path( s1 ) )
        path.clear();

    switch ( type )
    {
    case FeShader::VertexAndFragment:
        if ( is_supported_archive( path ) )
        {
            //
            // Known Issue: We don't properly handle the
            // situation where one shader is specified as a
            // relative path and is in a zip, while the other
            // is specified as an absolute path.  If the first
            // is in a zip, the second is assumed to be in the
            // same zip as well.
            //
            FeZipStream zs1( path );
            zs1.open( shader1 );

            FeZipStream zs2( path );
            zs2.open( shader2 );

            sh->load( zs1, zs2 );
        }
        else
        {
            std::string path2 = path;
            std::string s2 = clean_path( shader2 );
            if ( !is_relative_path( s2 ) )
                path2.clear();

            sh->load( path + s1, path2 + s2 );
        }
        break;

    case FeShader::Vertex:
    case FeShader::Fragment:
        if ( is_supported_archive( path ) )
        {
            FeZipStream zs( path );
            zs.open( shader1 );

            sh->load( zs, type );
        }
        else
        {
            sh->load( path + s1, type );
        }
        break;

    case FeShader::Empty:
    default:
        break;
    }

    return sh;
}