- Timestamp:
- 05/15/15 12:01:41 (10 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/engine/particle_engine.cc
r353 r361 300 300 void nv::particle_engine::load( lua::table_guard& table ) 301 301 { 302 std::string id = table.get_st ring( "id" );302 std::string id = table.get_std_string( "id" ); 303 303 if ( id == "" ) 304 304 { … … 317 317 data.affector_count = 0; 318 318 319 std::string orientation = table.get_string( "orientation", "point" );319 const_string orientation = table.get_string( "orientation", "point" ); 320 320 if ( orientation == "point" ) { data.orientation = particle_orientation::POINT; } 321 321 else if ( orientation == "oriented" ) { data.orientation = particle_orientation::ORIENTED; } … … 329 329 } 330 330 331 std::string origin = table.get_string( "origin", "center" );331 const_string origin = table.get_string( "origin", "center" ); 332 332 if ( origin == "center" ) { data.origin = particle_origin::CENTER; } 333 333 else if ( origin == "top_left" ) { data.origin = particle_origin::TOP_LEFT; } … … 353 353 { 354 354 lua::table_guard element( table, i+1 ); 355 std::string type = element.get_string("type");356 std::string sub_type = element.get_st ring("sub_type");355 const_string type = element.get_string("type"); 356 std::string sub_type = element.get_std_string("sub_type"); 357 357 if ( type == "emmiter" ) 358 358 { -
trunk/src/engine/program_manager.cc
r323 r361 49 49 if ( table.is_string( "files" ) ) 50 50 { 51 out += nv::slurp( table.get_st ring( "files" ) );51 out += nv::slurp( table.get_std_string( "files" ) ); 52 52 } 53 53 else if ( table.is_table( "files" ) ) … … 65 65 if ( table.is_string( "file" ) ) 66 66 { 67 out += "#line 1\n" +nv::slurp( table.get_string( "file" ) );67 out += "#line 1\n" + nv::slurp( table.get_std_string( "file" ) ); 68 68 } 69 69 70 70 if ( table.is_string( "source" ) ) 71 71 { 72 out += table.get_st ring( "source" );72 out += table.get_std_string( "source" ); 73 73 } 74 74 } -
trunk/src/engine/resource_system.cc
r358 r361 35 35 lua::table_guard sub_table( table, i+1 ); 36 36 resource_id rid = load_resource( sub_table ); 37 if ( rid != 0 ) m_names[ sub_table.get_st ring("id") ] = rid;37 if ( rid != 0 ) m_names[ sub_table.get_std_string("id") ] = rid; 38 38 } 39 39 } -
trunk/src/gl/gl_device.cc
r350 r361 22 22 } 23 23 24 program gl_device::create_program( const string& vs_source, const string&fs_source )24 program gl_device::create_program( string_ref vs_source, string_ref fs_source ) 25 25 { 26 26 program result = m_programs.create(); … … 35 35 // this is a temporary function that will be removed once we find a way to 36 36 // pass binary file data around 37 image_data* gl_device::create_image_data( const std::string&filename )37 image_data* gl_device::create_image_data( string_ref filename ) 38 38 { 39 39 load_sdl_image_library(); 40 SDL_Surface* image = IMG_Load( filename. c_str() );40 SDL_Surface* image = IMG_Load( filename.data() ); 41 41 if (!image) 42 42 { 43 NV_LOG( LOG_ERROR, "Image file " << filename .c_str()<< " not found!" );43 NV_LOG( LOG_ERROR, "Image file " << filename << " not found!" ); 44 44 return nullptr; 45 45 } … … 254 254 } 255 255 256 bool nv::gl_device::compile( gl_program_info* p, const string& vertex_program, const string&fragment_program )256 bool nv::gl_device::compile( gl_program_info* p, string_ref vertex_program, string_ref fragment_program ) 257 257 { 258 258 if (!compile( GL_VERTEX_SHADER, vertex_program, p->glidv )) { return false; } … … 397 397 } 398 398 399 bool nv::gl_device::compile( uint32 sh_type, const std::string&shader_code, unsigned& glid )399 bool nv::gl_device::compile( uint32 sh_type, string_ref shader_code, unsigned& glid ) 400 400 { 401 401 glid = glCreateShader( sh_type ); 402 402 403 const char* pc = shader_code.c_str(); 404 405 glShaderSource( glid, 1, &pc, 0 ); 403 const char* pc = shader_code.data(); 404 int l = shader_code.length(); 405 406 glShaderSource( glid, 1, &pc, &l ); 406 407 glCompileShader( glid ); 407 408 -
trunk/src/lua/lua_state.cc
r360 r361 179 179 } 180 180 181 string lua::table_guard::get_string( string_ref element, string_ref defval /*= string_ref() */ ) 182 { 183 lua_getfield( m_state, -1, element.data() ); 184 string result( ( lua_type( m_state, -1 ) == LUA_TSTRING ) ? lua_tostring( m_state, -1 ) : defval.to_string() ); 185 lua_pop( m_state, 1 ); 186 return result; 181 string lua::table_guard::get_std_string( string_ref element, string_ref defval /*= string_ref() */ ) 182 { 183 lua_getfield( m_state, -1, element.data() ); 184 size_t l = 0; 185 const char* str = nullptr; 186 if ( lua_type( m_state, -1 ) == LUA_TSTRING ) 187 { 188 str = lua_tolstring( m_state, -1, &l ); 189 } 190 else 191 { 192 l = defval.size(); 193 str = defval.data(); 194 } 195 std::string result( str, l ); 196 lua_pop( m_state, 1 ); 197 return result; 198 } 199 200 const_string lua::table_guard::get_string( string_ref element, string_ref defval /*= string_ref() */ ) 201 { 202 lua_getfield( m_state, -1, element.data() ); 203 size_t l = 0; 204 const char* str = nullptr; 205 if ( lua_type( m_state, -1 ) == LUA_TSTRING ) 206 { 207 str = lua_tolstring( m_state, -1, &l ); 208 } 209 else 210 { 211 l = defval.size(); 212 str = defval.data(); 213 } 214 const_string result( str, l ); 215 lua_pop( m_state, 1 ); 216 return result; 187 217 } 188 218
Note: See TracChangeset
for help on using the changeset viewer.