Changeset 313 for trunk/src/gfx


Ignore:
Timestamp:
08/18/14 23:25:46 (11 years ago)
Author:
epyon
Message:
  • cleanup of context and device interfaces
  • create_vertex_array moved to context (as it's context bound)
  • added partial framebuffer functions to context
Location:
trunk/src/gfx
Files:
4 edited

Legend:

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

    r303 r313  
    2828        "}\n";
    2929
    30 nv::debug_data::debug_data( device* a_device )
    31         : m_device( a_device ), m_program(), m_va()
     30nv::debug_data::debug_data( context* a_context )
     31        : m_context( a_context ), m_program(), m_va()
    3232{
    33         m_program = m_device->create_program( nv_debug_draw_vertex_shader, nv_debug_draw_fragment_shader );
     33        m_program = m_context->get_device()->create_program( nv_debug_draw_vertex_shader, nv_debug_draw_fragment_shader );
    3434}
    3535
    3636void nv::debug_data::update()
    3737{
    38         m_device->release( m_va );
    39         m_va = m_device->create_vertex_array( m_data, nv::STATIC_DRAW );
     38        m_context->release( m_va );
     39        m_va = m_context->create_vertex_array( m_data, nv::STATIC_DRAW );
    4040}
    4141
     
    7575nv::debug_data::~debug_data()
    7676{
    77         m_device->release( m_va );
    78         m_device->release( m_program );
     77        m_context->release( m_va );
     78        m_context->get_device()->release( m_program );
    7979}
  • trunk/src/gfx/keyframed_mesh.cc

    r304 r313  
    105105nv::keyframed_mesh::~keyframed_mesh()
    106106{
    107         m_context->get_device()->release( m_va );
     107        m_context->release( m_va );
    108108}
    109109
     
    131131        , m_gpu_next_frame( 0xFFFFFFFF )
    132132{
    133         m_va      = a_context->get_device()->create_vertex_array( a_data, STATIC_DRAW );
    134         m_pbuffer = a_context->get_device()->find_buffer( m_va, slot::POSITION );
     133        m_va      = a_context->create_vertex_array( a_data, STATIC_DRAW );
     134        m_pbuffer = a_context->find_buffer( m_va, slot::POSITION );
    135135}
    136136
     
    140140        if ( m_loc_next_position == -1 ) return;
    141141        animated_mesh::update( ms );
    142         device* dev = m_context->get_device();
    143142        if ( m_gpu_last_frame != m_last_frame )
    144143        {
    145144                uint32 base_offset = m_last_frame * m_vertex_count * m_vsize;
    146                 dev->update_attribute_offset( m_va, slot::POSITION, base_offset );
    147                 dev->update_attribute_offset( m_va, slot::NORMAL,   base_offset + sizeof( vec3 ) );
     145                m_context->update_attribute_offset( m_va, slot::POSITION, base_offset );
     146                m_context->update_attribute_offset( m_va, slot::NORMAL,   base_offset + sizeof( vec3 ) );
    148147                if ( m_has_tangent && m_loc_next_tangent != -1 )
    149148                {
    150                         dev->update_attribute_offset( m_va, slot::TANGENT, base_offset + 2*sizeof( vec3 ) );
     149                        m_context->update_attribute_offset( m_va, slot::TANGENT, base_offset + 2*sizeof( vec3 ) );
    151150                }
    152151                m_gpu_last_frame = m_last_frame;
     
    155154        {
    156155                uint32 base_offset = m_next_frame * m_vertex_count * m_vsize;
    157                 dev->update_attribute_offset( m_va, (slot)m_loc_next_position, base_offset );
    158                 dev->update_attribute_offset( m_va, (slot)m_loc_next_normal, base_offset + sizeof( vec3 ) );
     156                m_context->update_attribute_offset( m_va, (slot)m_loc_next_position, base_offset );
     157                m_context->update_attribute_offset( m_va, (slot)m_loc_next_normal, base_offset + sizeof( vec3 ) );
    159158                if ( m_has_tangent && m_loc_next_tangent != -1 )
    160159                {
    161                         dev->update_attribute_offset( m_va, (slot)m_loc_next_tangent, base_offset + 2*sizeof( vec3 ) );
     160                        m_context->update_attribute_offset( m_va, (slot)m_loc_next_tangent, base_offset + 2*sizeof( vec3 ) );
    162161                }
    163162                m_gpu_next_frame = m_next_frame;
     
    175174                        m_loc_next_tangent  = dev->get_attribute_location( a_program, "nv_next_tangent" );
    176175
    177                 dev->add_vertex_buffer( m_va, (slot)m_loc_next_position, m_pbuffer, FLOAT, 3, 0, m_vsize, false );
    178                 dev->add_vertex_buffer( m_va, (slot)m_loc_next_normal,   m_pbuffer, FLOAT, 3, sizeof( vec3 ), m_vsize, false );
     176                m_context->add_vertex_buffer( m_va, (slot)m_loc_next_position, m_pbuffer, FLOAT, 3, 0, m_vsize, false );
     177                m_context->add_vertex_buffer( m_va, (slot)m_loc_next_normal,   m_pbuffer, FLOAT, 3, sizeof( vec3 ), m_vsize, false );
    179178                if ( m_has_tangent )
    180                         dev->add_vertex_buffer( m_va, (slot)m_loc_next_tangent, m_pbuffer, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false );
     179                        m_context->add_vertex_buffer( m_va, (slot)m_loc_next_tangent, m_pbuffer, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false );
    181180        }
    182181        keyframed_mesh::update( a_program );
     
    186185        : keyframed_mesh( a_context, a_data, a_tag_map )
    187186{
    188         m_va      = m_context->get_device()->create_vertex_array();
     187        m_va      = m_context->create_vertex_array();
    189188        m_pbuffer = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * m_vsize, (void*)m_vchannel->data );
    190         m_context->get_device()->add_vertex_buffers( m_va, m_pbuffer, m_vchannel );
     189        m_context->add_vertex_buffers( m_va, m_pbuffer, m_vchannel );
    191190
    192191        buffer  vb = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * sizeof( vec2 ), (void*)m_mesh_data->get_channel<vertex_t>()->data );
    193         m_context->get_device()->add_vertex_buffers( m_va, vb, m_mesh_data->get_channel<vertex_t>() );
     192        m_context->add_vertex_buffers( m_va, vb, m_mesh_data->get_channel<vertex_t>() );
    194193
    195194        buffer  ib = m_context->get_device()->create_buffer( INDEX_BUFFER, STATIC_DRAW, m_mesh_data->get_index_channel()->size(), (void*)m_mesh_data->get_index_channel()->data );
    196195
    197         m_context->get_device()->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc.slots[0].etype, true );
     196        m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc.slots[0].etype, true );
    198197
    199198        m_data = new uint8[ m_vertex_count * m_vsize ];
  • trunk/src/gfx/particle_engine.cc

    r312 r313  
    485485        info->particles = new particle[ data->quota ];
    486486        info->quads     = new particle_quad[ data->quota ];
    487         info->vtx_array = m_device->create_vertex_array<particle_vtx>(
     487        info->vtx_array = m_context->create_vertex_array<particle_vtx>(
    488488                (particle_vtx*)info->quads, data->quota*6, STREAM_DRAW );
    489         info->vtx_buffer = m_device->find_buffer( info->vtx_array, slot::POSITION );
     489        info->vtx_buffer = m_context->find_buffer( info->vtx_array, slot::POSITION );
    490490        info->last_update = 0;
    491491        info->test = false;
     
    519519                delete[] info->quads;
    520520                //if ( system->own_va )
    521                 m_device->release( info->vtx_array );
     521                m_context->release( info->vtx_array );
    522522                m_systems.destroy( system );
    523523        }
  • trunk/src/gfx/skeletal_mesh.cc

    r303 r313  
    2626        m_vtx_data  = a_mesh_data->get_channel_data<md5_vtx_pntiw>();
    2727        m_indices   = a_mesh_data->get_count();
    28         m_va        = a_context->get_device()->create_vertex_array( a_mesh_data,
     28        m_va        = a_context->create_vertex_array( a_mesh_data,
    2929STREAM_DRAW );
    30         m_pbuffer   = a_context->get_device()->find_buffer( m_va, slot::POSITION );
     30        m_pbuffer   = a_context->find_buffer( m_va, slot::POSITION );
    3131}
    3232
     
    195195        : skeletal_mesh( a_context ), m_bone_data( a_bone_data ), m_transform( nullptr )
    196196{
    197         m_va          = a_context->get_device()->create_vertex_array( a_mesh, nv::STATIC_DRAW );
     197        m_va          = a_context->create_vertex_array( a_mesh, nv::STATIC_DRAW );
    198198        m_index_count = a_mesh->get_count();
    199199        if ( m_bone_data )
Note: See TracChangeset for help on using the changeset viewer.