Ignore:
Timestamp:
10/09/15 14:06:56 (10 years ago)
Author:
epyon
Message:
  • rtti updates
  • device/context initial uniform buffer support
  • fixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gl/gl_context.cc

    r469 r473  
    205205        {
    206206                glBindFramebuffer( framebuffer_slot_to_enum(ft), 0 );
     207        }
     208}
     209
     210void nv::gl_context::bind( buffer b, uint32 index, size_t offset /*= 0*/, size_t size /*= 0 */ )
     211{
     212        const gl_buffer_info* info = static_cast< const gl_buffer_info* >( m_device->get_buffer_info( b ) );
     213        if ( info )
     214        {
     215                if ( size == 0 )
     216                        glBindBufferBase( buffer_type_to_enum( info->type ), index, info->glid );
     217                else
     218                        glBindBufferRange( buffer_type_to_enum( info->type ), index, info->glid, offset, size );
    207219        }
    208220}
     
    339351                else
    340352                        glTexImage2D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum(format.format) ), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data );
     353        }
     354}
     355
     356void nv::gl_context::update( buffer b, uint32 index, const void* data, size_t offset, size_t size )
     357{
     358        const gl_buffer_info* info = static_cast<const gl_buffer_info*>( m_device->get_buffer_info( b ) );
     359        if ( info )
     360        {
     361                GLenum glenum = buffer_type_to_enum( info->type );
     362                if ( size == 0 )
     363                        glBindBufferBase( glenum, index, info->glid );
     364                else
     365                        glBindBufferRange( glenum, index, info->glid, offset, size );
     366                glBufferSubData( glenum, GLintptr( offset ), GLsizeiptr( size ), data );
    341367        }
    342368}
     
    750776}
    751777
    752 void gl_context::draw( primitive prim, const render_state& rs, program p, vertex_array va, nv::size_t count )
     778void gl_context::draw( primitive prim, const render_state& rs, program p, vertex_array va, nv::size_t count, nv::size_t first )
    753779{
    754780        apply_render_state( rs );
     
    760786                if ( info->index.is_valid() )
    761787                {
    762                         glDrawElements( primitive_to_enum(prim), static_cast<GLsizei>( count ), datatype_to_gl_enum( info->index_type ), 0 );
     788                        glDrawElements( primitive_to_enum(prim), static_cast<GLsizei>( count ), datatype_to_gl_enum( info->index_type ), reinterpret_cast< const void* >( get_datatype_info( info->index_type ).size * first ) );
    763789                }
    764790                else
    765791                {
    766                         glDrawArrays( primitive_to_enum(prim), 0, static_cast<GLsizei>( count ) );
     792                        glDrawArrays( primitive_to_enum(prim), first, static_cast<GLsizei>( count ) );
    767793                }
    768794                unbind( va );
Note: See TracChangeset for help on using the changeset viewer.