Ignore:
Timestamp:
06/06/16 18:54:52 (9 years ago)
Author:
epyon
Message:
  • ecs work
  • particle engine rehaul
  • added map/unmap buffer to ::context
File:
1 edited

Legend:

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

    r493 r499  
    428428                        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 );
    429429        }
     430}
     431
     432void* nv::gl_context::map_buffer( buffer b, buffer_access ba, size_t offset, size_t length )
     433{
     434        const gl_buffer_info* info = static_cast<const gl_buffer_info*>( m_device->get_buffer_info( b ) );
     435        unsigned int glenum = buffer_type_to_enum( info->type );
     436        glBindBuffer( glenum, info->glid );
     437        void* result = glMapBufferRange( glenum, GLintptr( offset ), GLsizeiptr( length ), buffer_access_to_bitfield( ba ) );
     438        if ( result == nullptr )
     439        {
     440                while ( GLenum err = glGetError() )
     441                switch ( err )
     442                {
     443                case GL_INVALID_VALUE     : NV_LOG_ERROR( "map_buffer failed : GL_INVALID_VALUE" ) break;
     444                case GL_INVALID_OPERATION : NV_LOG_ERROR( "map_buffer failed : GL_INVALID_OPERATION " ) break;
     445                case GL_OUT_OF_MEMORY     : NV_LOG_ERROR( "map_buffer failed : GL_OUT_OF_MEMORY " ) break;
     446                default:
     447                        break;
     448                }
     449        }
     450        return result;
     451}
     452
     453void nv::gl_context::unmap_buffer( buffer b )
     454{
     455        const gl_buffer_info* info = static_cast<const gl_buffer_info*>( m_device->get_buffer_info( b ) );
     456        glUnmapBuffer( buffer_type_to_enum( info->type ) );
    430457}
    431458
Note: See TracChangeset for help on using the changeset viewer.