1 #include "glfBufferObject.hh"
2 #include "glfException.hh"
7 target_(target), queryName_(queryName), bufferObjID_(0), boundRevertably_(false), previousBinding_(0)
12 glDeleteBuffers(1, &bufferObjID_);
14 GLF_THROW_ON_OPENGL_ERROR_DEBUG;
21 glGenBuffers(1, &bufferObjID_);
22 GLF_THROW_ON_OPENGL_ERROR_DEBUG;
28 BIASASSERT( bufferObjID_ != 0);
29 glBindBuffer(
target_, bufferObjID_);
30 boundRevertably_ =
false;
31 GLF_THROW_ON_OPENGL_ERROR_DEBUG;
36 BIASASSERT( bufferObjID_ != 0);
37 glGetIntegerv(queryName_, &previousBinding_);
38 boundRevertably_ =
true;
39 glBindBuffer(
target_, bufferObjID_);
40 GLF_THROW_ON_OPENGL_ERROR_DEBUG;
45 if(boundRevertably_) {
46 glBindBuffer(
target_, previousBinding_);
47 boundRevertably_ =
false;
48 GLF_THROW_ON_OPENGL_ERROR_DEBUG;
50 BIASWARN(
"Unable to revert binding! Use BindRevertable() without subsequent call to Bind()!");
56 UploadData(GLenum usageHint, GLsizeiptr size, GLvoid* data)
59 glBufferData(
target_, size, data, usageHint);
60 GLF_THROW_ON_OPENGL_ERROR;
65 UploadData(
float* data,
unsigned int numElements, GLenum usageHint)
67 UploadData(usageHint,
sizeof(
float)*numElements, data);
virtual ~glfBufferObject()
void UploadData(float *data, unsigned int numElements, GLenum usageHint=GL_STATIC_DRAW)
glfBufferObject(GLenum target, GLenum queryName)