Changeset 438 for trunk/src/engine/program_manager.cc
- Timestamp:
- 07/23/15 17:29:49 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/engine/program_manager.cc
r433 r438 9 9 #include "nv/core/logging.hh" 10 10 #include "nv/lua/lua_nova.hh" 11 11 #include "nv/io/c_file_system.hh" 12 12 13 13 nv::program_manager::program_manager( context* a_context ) : m_context( a_context ) 14 14 { 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(); 17 16 } 18 17 … … 20 19 { 21 20 NV_LOG_DEBUG( table.get_string("id") ); 22 st d::stringvsource;23 st d::stringfsource;24 st d::string csource;21 string_buffer vsource; 22 string_buffer fsource; 23 string_buffer header( m_shader_head ); 25 24 if ( table.is_table("common") ) 26 25 { 27 26 lua::table_guard common( table, "common" ); 28 load_source( common, csource, "" );27 header.append( "\n" + load_source( common, "" ) + "\n" ); 29 28 } 30 29 { 31 30 lua::table_guard vtable( table, "vertex" ); 32 load_source( vtable, vsource, m_vertex_head+"\n"+csource+"\n");31 vsource = load_source( vtable, header ); 33 32 } 34 33 { 35 34 lua::table_guard ftable( table, "fragment" ); 36 load_source( ftable, fsource, m_fragment_head+"\n"+csource+"\n");35 fsource = load_source( ftable, header ); 37 36 } 38 37 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 ); 40 39 return add( program ); 41 40 } … … 46 45 } 47 46 48 void nv::program_manager::load_source( lua::table_guard& table, std::string& out, const std::string& append )47 nv::string_buffer nv::program_manager::load_source( lua::table_guard& table, const string_view& append ) 49 48 { 50 out = append; 49 c_file_system fs; 50 string_buffer out( append ); 51 51 if ( table.is_string( "files" ) ) 52 52 { 53 out += nv::slurp( table.get_std_string( "files") );53 out.append( fs.slurp( table.get_string( "files" ) ) ); 54 54 } 55 55 else if ( table.is_table( "files" ) ) … … 59 59 for ( uint32 i = 1; i <= count; ++i ) 60 60 { 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 ) ); 64 64 } 65 65 } … … 67 67 if ( table.is_string( "file" ) ) 68 68 { 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 ); 70 71 } 71 72 72 73 if ( table.is_string( "source" ) ) 73 74 { 74 out += table.get_std_string( "source");75 out.append( table.get_string( "source" ) ); 75 76 } 77 return out; 76 78 }
Note: See TracChangeset
for help on using the changeset viewer.