Last change
on this file since 776 was
776,
checked in by vrinside, 17 years ago
|
Add 3D surface plot and grid rendering
|
File size:
768 bytes
|
Line | |
---|
1 | #include <GL/glew.h> |
---|
2 | #include <R2/graphics/R2VertexBuffer.h> |
---|
3 | #include <GL/gl.h> |
---|
4 | #include <memory.h> |
---|
5 | #include <stdlib.h> |
---|
6 | |
---|
7 | R2VertexBuffer::R2VertexBuffer(int type, int vertexCount, int byteSize, void* data, bool copy) |
---|
8 | : _graphicObjectID(0), _byteSize(byteSize), _vertexCount(vertexCount) |
---|
9 | { |
---|
10 | if (copy) |
---|
11 | { |
---|
12 | _data = (void*) malloc(byteSize); |
---|
13 | } |
---|
14 | else |
---|
15 | { |
---|
16 | _data = data; |
---|
17 | } |
---|
18 | |
---|
19 | glGenBuffers(1, &_graphicObjectID); |
---|
20 | glBindBuffer(GL_ARRAY_BUFFER, _graphicObjectID); |
---|
21 | glBufferData(GL_ARRAY_BUFFER, |
---|
22 | _byteSize, |
---|
23 | data, |
---|
24 | GL_STATIC_DRAW); |
---|
25 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
---|
26 | } |
---|
27 | |
---|
28 | R2VertexBuffer::~R2VertexBuffer() |
---|
29 | { |
---|
30 | if (_graphicObjectID != 0) |
---|
31 | { |
---|
32 | glDeleteBuffers(1, &_graphicObjectID); |
---|
33 | } |
---|
34 | |
---|
35 | if (_data) |
---|
36 | { |
---|
37 | free(_data); |
---|
38 | } |
---|
39 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.