forked from bwrrp/glblaat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGLBuffer.h
44 lines (35 loc) · 1020 Bytes
/
GLBuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
#include "GLResource.h"
#include "GL.h"
class GLBuffer : public GLResource
{
public:
static GLBuffer *New();
virtual ~GLBuffer();
// We use a seperate bind method for each available target.
// Future operations use the same target until a different Bind is called.
void BindAsVertexData() { target = GL_ARRAY_BUFFER; Bind(); }
void BindAsIndexData() { target = GL_ELEMENT_ARRAY_BUFFER; Bind(); }
void Unbind();
void SetData(int size, void *data, GLenum usage);
void SetSubData(int offset, int size, void *data);
// NOTE: clearing data before calling map can actually speed things up
void Clear();
void GetSubData(int offset, int size, void *data);
void *Map(GLenum access);
bool Unmap();
int GetSize() { return size; }
protected:
GLuint id;
GLenum target;
GLenum boundTo;
int size;
GLenum usage;
void *mapped;
GLBuffer();
void Bind();
private:
// Not implemented
GLBuffer(const GLBuffer&);
void operator=(const GLBuffer&);
};