Ignore:
Timestamp:
05/28/13 16:48:29 (12 years ago)
Author:
epyon
Message:
  • context bugfixes, force apply state at creation and apply render state
  • window creates context
  • index buffer
  • vertex arrays (simulation of GL 3 functionality)
  • bugfixes
File:
1 edited

Legend:

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

    r42 r44  
    4040        return m_name.is_valid();
    4141}
     42
     43gl_index_buffer::gl_index_buffer( buffer_hint hint, int size, void* data )
     44        : index_buffer( hint, size ), m_name()
     45{
     46        if (data)
     47        {
     48                assign( data );
     49        }
     50}
     51
     52void gl_index_buffer::assign( void* data )
     53{
     54        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_name.get_value() );
     55        glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_size, data, buffer_hint_to_enum( m_hint ) );
     56        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0);
     57}
     58
     59void gl_index_buffer::bind()
     60{
     61        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_name.get_value() );
     62}
     63
     64void gl_index_buffer::unbind()
     65{
     66        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
     67}
     68
     69bool gl_index_buffer::is_valid() const
     70{
     71        return m_name.is_valid();
     72}
     73
     74gl_vertex_array::gl_vertex_array()
     75{
     76
     77}
     78
     79void gl_vertex_array::bind()
     80{
     81        for ( vertex_buffer_attribute_map::iterator i = m_map.begin();  i != m_map.end(); ++i )
     82        {
     83                int location                = i->first;
     84                vertex_buffer_attribute* va = i->second;
     85                vertex_buffer*           vb = va->get_buffer();
     86                glEnableVertexAttribArray( location );
     87                vb->bind();
     88                glVertexAttribPointer(
     89                        location,
     90                        va->get_components(),
     91                        nv::type_to_gl_enum( va->get_datatype() ),
     92                        GL_FALSE,
     93                        va->get_stride(),
     94                        (void*)va->get_offset()
     95                        );
     96                vb->unbind();
     97        }
     98
     99}
     100
     101void gl_vertex_array::unbind()
     102{
     103        for ( vertex_buffer_attribute_map::iterator i = m_map.begin();  i != m_map.end(); ++i )
     104        {
     105                glDisableVertexAttribArray( i->first );
     106        }
     107}
Note: See TracChangeset for help on using the changeset viewer.