Ignore:
Timestamp:
07/23/15 17:29:49 (10 years ago)
Author:
epyon
Message:
  • massive amount of std::string removal
  • removed slurp, use filesystem::slurp instead
  • lua_values const_string support
  • several bugfixes
  • program_manager and shader loading without std::string/std::stream
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/engine/program_manager.cc

    r433 r438  
    99#include "nv/core/logging.hh"
    1010#include "nv/lua/lua_nova.hh"
    11 
     11#include "nv/io/c_file_system.hh"
    1212
    1313nv::program_manager::program_manager( context* a_context ) : m_context( a_context )
    1414{
    15         m_vertex_head   = a_context->get_device()->get_shader_header();
    16         m_fragment_head = a_context->get_device()->get_shader_header();
     15        m_shader_head = a_context->get_device()->get_shader_header();
    1716}
    1817
     
    2019{
    2120        NV_LOG_DEBUG( table.get_string("id") );
    22         std::string vsource;
    23         std::string fsource;
    24         std::string csource;
     21        string_buffer vsource;
     22        string_buffer fsource;
     23        string_buffer header( m_shader_head );
    2524        if ( table.is_table("common") )
    2625        {
    2726                lua::table_guard common( table, "common" );
    28                 load_source( common, csource, "" );
     27                header.append( "\n" + load_source( common, "" ) + "\n" );
    2928        }
    3029        {
    3130                lua::table_guard vtable( table, "vertex" );
    32                 load_source( vtable, vsource, m_vertex_head+"\n"+csource+"\n");
     31                vsource = load_source( vtable, header );
    3332        }
    3433        {
    3534                lua::table_guard ftable( table, "fragment" );
    36                 load_source( ftable, fsource, m_fragment_head+"\n"+csource+"\n" );
     35                fsource = load_source( ftable, header );
    3736        }
    3837
    39         nv::program program = m_context->get_device()->create_program( string_view( vsource.c_str(), vsource.size() ), string_view( fsource.c_str(), fsource.size() ) );
     38        nv::program program = m_context->get_device()->create_program( vsource, fsource );
    4039        return add( program );
    4140}
     
    4645}
    4746
    48 void nv::program_manager::load_source( lua::table_guard& table, std::string& out, const std::string& append )
     47nv::string_buffer nv::program_manager::load_source( lua::table_guard& table, const string_view& append )
    4948{
    50         out = append;
     49        c_file_system fs;
     50        string_buffer out( append );
    5151        if ( table.is_string( "files" ) )
    5252        {
    53                 out += nv::slurp( table.get_std_string( "files" ) );
     53                out.append( fs.slurp( table.get_string( "files" ) ) );
    5454        }
    5555        else if ( table.is_table( "files" ) )
     
    5959                for ( uint32 i = 1; i <= count; ++i )
    6060                {
    61                         std::string include( inctable.get<std::string,uint32>(i) );
    62                         if ( i == count ) out += "#line 1\n";
    63                         out += nv::slurp( include );
     61                        const_string include( inctable.get<const_string,uint32>(i) );
     62                        if ( i == count ) out.append( "#line 1\n" );
     63                        out.append( fs.slurp( include ) );
    6464                }
    6565        }
     
    6767        if ( table.is_string( "file" ) )
    6868        {
    69                 out += "#line 1\n" + nv::slurp( table.get_std_string( "file" ) );
     69                const_string data = fs.slurp( table.get_string( "file" ) );
     70                out.append( "#line 1\n" + data );
    7071        }
    7172
    7273        if ( table.is_string( "source" ) )
    7374        {
    74                 out += table.get_std_string( "source" );
     75                out.append( table.get_string( "source" ) );
    7576        }
     77        return out;
    7678}
Note: See TracChangeset for help on using the changeset viewer.