source: trunk/src/gl/gl_vertex_buffer.cc @ 43

Last change on this file since 43 was 42, checked in by epyon, 12 years ago
  • vertex_buffer interface and implementation
File size: 922 bytes
Line 
1// Copyright (C) 2012-2013 Kornel Kisielewicz
2// This file is part of NV Libraries.
3// For conditions of distribution and use, see copyright notice in nv.hh
4
5#include "nv/gl/gl_vertex_buffer.hh"
6
7#include "nv/lib/gl.hh"
8#include "nv/gl/gl_enum.hh"
9
10using namespace nv;
11
12gl_vertex_buffer::gl_vertex_buffer( buffer_hint hint, int size, void* data )
13        : vertex_buffer( hint, size ), m_name()
14{
15        if (data)
16        {
17                assign( data );
18        }
19}
20
21void gl_vertex_buffer::assign( void* data )
22{
23        glBindBuffer( GL_ARRAY_BUFFER, m_name.get_value() );
24        glBufferData( GL_ARRAY_BUFFER, m_size, data, buffer_hint_to_enum( m_hint ) );
25        glBindBuffer( GL_ARRAY_BUFFER, 0);
26}
27
28void gl_vertex_buffer::bind()
29{
30        glBindBuffer( GL_ARRAY_BUFFER, m_name.get_value() );
31}
32
33void gl_vertex_buffer::unbind()
34{
35        glBindBuffer( GL_ARRAY_BUFFER, 0 );
36}
37
38bool gl_vertex_buffer::is_valid() const
39{
40        return m_name.is_valid();
41}
Note: See TracBrowser for help on using the repository browser.