source: trunk/packages/vizservers/nanovis/graphics/VertexBuffer.cpp @ 4587

Last change on this file since 4587 was 3465, checked in by ldelgass, 11 years ago

Rename R2 library to nv::graphics and nv::util.

  • Property svn:eol-style set to native
File size: 985 bytes
RevLine 
[2798]1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
[3465]2/*
3 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
4 */
[776]5#include <memory.h>
6#include <stdlib.h>
7
[2840]8#include <GL/glew.h>
9#include <GL/gl.h>
10
[3465]11#include "VertexBuffer.h"
[2840]12
[3463]13using namespace nv::graphics;
14
15VertexBuffer::VertexBuffer(int type, int vertexCount,
16                           int byteSize, void *data, bool copy) :
17    _graphicObjectID(0),
18    _byteSize(byteSize),
19    _vertexCount(vertexCount)
[776]20{
[2841]21    if (copy) {
22        _data = (void*) malloc(byteSize);
23    } else {
24        _data = data;
25    }
[776]26
[2841]27    glGenBuffers(1, &_graphicObjectID);
28    glBindBuffer(GL_ARRAY_BUFFER, _graphicObjectID);
[776]29    glBufferData(GL_ARRAY_BUFFER,
[2841]30                 _byteSize,
31                 data,
32                 GL_STATIC_DRAW);
[776]33    glBindBuffer(GL_ARRAY_BUFFER, 0);
34}
35
[3463]36VertexBuffer::~VertexBuffer()
[776]37{
[2841]38    if (_graphicObjectID != 0) {
39        glDeleteBuffers(1, &_graphicObjectID);
40    }
41    if (_data) {
42        free(_data);
43    }
[776]44}
Note: See TracBrowser for help on using the repository browser.