Ignore:
Timestamp:
08/07/14 10:10:24 (11 years ago)
Author:
epyon
Message:
  • all bind and update function for graphics objects are done via context (will simplify directx device, and allow for handles instead of objects)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gfx/keyframed_mesh.cc

    r296 r299  
    1515using namespace nv;
    1616
    17 nv::keyframed_mesh::keyframed_mesh( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
     17nv::keyframed_mesh::keyframed_mesh( const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
    1818        : animated_mesh()
    1919        , m_mesh_data( a_data )
     
    2424        , m_active( false )
    2525{
    26         m_va = a_device->create_vertex_array();
    27 
    2826        m_index_count  = m_mesh_data->get_index_channel()->count;
    2927        m_vertex_count = m_mesh_data->get_channel<vertex_t>()->count;
     
    123121}
    124122
    125 nv::keyframed_mesh_gpu::keyframed_mesh_gpu( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
    126         : keyframed_mesh( a_device, a_data, a_tag_map )
     123nv::keyframed_mesh_gpu::keyframed_mesh_gpu( context* a_context, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
     124        : keyframed_mesh( a_data, a_tag_map )
    127125        , m_loc_next_position( -1 )
    128126        , m_loc_next_normal( -1 )
     
    131129        , m_gpu_next_frame( 0xFFFFFFFF )
    132130{
    133         m_va = a_device->create_vertex_array( a_data, STATIC_DRAW );
     131        m_va = a_context->get_device()->create_vertex_array( a_data, STATIC_DRAW );
    134132}
    135133
     
    177175}
    178176
    179 nv::keyframed_mesh_cpu::keyframed_mesh_cpu( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
    180         : keyframed_mesh( a_device, a_data, a_tag_map )
    181 {
    182         m_vb = a_device->create_vertex_buffer( nv::STATIC_DRAW, m_vertex_count * m_vsize, (void*)m_vchannel->data );
     177nv::keyframed_mesh_cpu::keyframed_mesh_cpu( context* a_context, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
     178        : keyframed_mesh( a_data, a_tag_map )
     179        , m_context( a_context )
     180{
     181        m_va = m_context->get_device()->create_vertex_array();
     182        m_vb = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_vertex_count * m_vsize, (void*)m_vchannel->data );
    183183        m_va->add_vertex_buffers( m_vb, m_vchannel );
    184184
    185         nv::vertex_buffer* vb = a_device->create_vertex_buffer( nv::STATIC_DRAW, m_vertex_count * sizeof( nv::vec2 ), (void*)m_mesh_data->get_channel<vertex_t>()->data );
     185        nv::vertex_buffer* vb = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_vertex_count * sizeof( nv::vec2 ), (void*)m_mesh_data->get_channel<vertex_t>()->data );
    186186        m_va->add_vertex_buffers( vb, m_mesh_data->get_channel<vertex_t>() );
    187187
    188         nv::index_buffer* ib = a_device->create_index_buffer( nv::STATIC_DRAW, m_mesh_data->get_index_channel()->size(), (void*)m_mesh_data->get_index_channel()->data );
     188        nv::index_buffer* ib = m_context->get_device()->create_index_buffer( nv::STATIC_DRAW, m_mesh_data->get_index_channel()->size(), (void*)m_mesh_data->get_index_channel()->data );
    189189        m_va->set_index_buffer( ib, m_mesh_data->get_index_channel()->desc.slots[0].etype, true );
    190190
     
    224224        }
    225225
    226         m_vb->bind();
    227         m_vb->update( m_data, 0, m_vertex_count * m_vsize );
    228         m_vb->unbind();
     226        m_context->update( m_vb, m_data, 0, m_vertex_count * m_vsize );
    229227}
    230228
Note: See TracChangeset for help on using the changeset viewer.