Changeset 299 for trunk/src/gfx


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)
Location:
trunk/src/gfx
Files:
2 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
  • trunk/src/gfx/skeletal_mesh.cc

    r296 r299  
    1111
    1212
    13 nv::skeletal_mesh_cpu::skeletal_mesh_cpu( device* a_device, const mesh_data* a_mesh_data, const mesh_nodes_data* bones )
     13nv::skeletal_mesh_cpu::skeletal_mesh_cpu( context* a_context, const mesh_data* a_mesh_data, const mesh_nodes_data* bones )
    1414        : skeletal_mesh()
     15        , m_context( a_context )
    1516        , m_data( a_mesh_data )
    1617{
     
    2627        m_vtx_data  = a_mesh_data->get_channel_data<md5_vtx_pntiw>();
    2728        m_indices   = a_mesh_data->get_count();
    28         m_va        = a_device->create_vertex_array( a_mesh_data, nv::STREAM_DRAW );
     29        m_va        = a_context->get_device()->create_vertex_array( a_mesh_data, nv::STREAM_DRAW );
    2930}
    3031
     
    6364
    6465                vertex_buffer* vb = m_va->find_buffer( nv::slot::POSITION );
    65                 vb->bind();
    66                 vb->update( m_pntdata.data(), 0, m_pntdata.raw_size() );
    67                 vb->unbind();
     66                m_context->update( vb, m_pntdata.data(), 0, m_pntdata.raw_size() );
    6867        }
    6968}
     
    200199}
    201200
    202 nv::skeletal_mesh_gpu::skeletal_mesh_gpu( device* a_device, const mesh_data* a_mesh, const mesh_nodes_data* a_bone_data )
     201nv::skeletal_mesh_gpu::skeletal_mesh_gpu( context* a_context, const mesh_data* a_mesh, const mesh_nodes_data* a_bone_data )
    203202        : skeletal_mesh(), m_bone_data( a_bone_data ), m_transform( nullptr )
    204203{
    205         m_va          = a_device->create_vertex_array( a_mesh, nv::STATIC_DRAW );
     204        m_va          = a_context->get_device()->create_vertex_array( a_mesh, nv::STATIC_DRAW );
    206205        m_index_count = a_mesh->get_count();
    207206        if ( m_bone_data )
Note: See TracChangeset for help on using the changeset viewer.