Ignore:
Timestamp:
06/01/13 01:26:51 (12 years ago)
Author:
epyon
Message:
  • shortcut create_vertex_array based on program and mesh
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/render_test/rl.cc

    r71 r73  
    6666        application();
    6767        bool initialize();
    68         bool init_program( const std::string& name, nv::program*& p, nv::vertex_array*& va, nv::mesh* m );
    6968        bool run();
    7069        ~application();
     
    117116                vtx.emplace_back( x,   h, y ); 
    118117                mat.insert( mat.end(), 6, nv::i8vec3( m, 1, 0 ) );
    119 
    120                 if (!init_program( "char", m_char_program, m_char_va, &cmesh ) ) return false;
     118                m_char_program = m_device->create_program( nv::slurp( "char.vert" ), nv::slurp( "char.frag" ) );
     119                m_char_va      = m_device->create_vertex_array( &cmesh, &(m_char_program->get_attributes()), nv::STATIC_DRAW );
    121120        }
    122121
     
    175174                }
    176175
    177                 m_count = vtx.size();
    178                 if (!init_program( "box",  m_box_program, m_box_va, &wmesh ) ) return false;
    179         }
    180 
    181         return true;
    182 }
    183 
    184 bool application::init_program( const std::string& name, nv::program*& p, nv::vertex_array*& va, nv::mesh* m )
    185 {
    186         p  = m_device->create_program( nv::slurp( name+".vert" ), nv::slurp( name+".frag" ) );
    187         va = m_device->create_vertex_array();
    188         const nv::mesh::map& attrs = m->get_attributes();
    189 
    190         for ( auto attr : attrs )
    191         {
    192                 nv::vertex_buffer* vb = m_device->create_vertex_buffer( nv::STATIC_DRAW, attr.second->get_size(), attr.second->get_data() );
    193                 va->add_vertex_buffer( p->get_attribute( attr.first )->get_location(), vb, attr.second->get_base_type(), attr.second->get_components() );
    194         }
     176                m_count       = vtx.size();
     177                m_box_program = m_device->create_program( nv::slurp( "box.vert" ), nv::slurp( "box.frag" ) );
     178                m_box_va      = m_device->create_vertex_array( &wmesh, &(m_box_program->get_attributes()), nv::STATIC_DRAW );
     179        }
     180
    195181        return true;
    196182}
Note: See TracChangeset for help on using the changeset viewer.