CGVIS Utils
Loading...
Searching...
No Matches
GLBuffer.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include <GL/glew.h>
6#include <GLFW/glfw3.h>
7
17class GLBuffer {
18public:
24 GLBuffer(GLenum target);
25
27 ~GLBuffer();
28
36 void setData(const std::vector<GLfloat>& data, size_t valuesPerElement,GLenum usage=GL_STATIC_DRAW);
37
43 void setData(const std::vector<GLuint>& data);
44
52 void setData(const float data[], size_t elemCount,
53 size_t valuesPerElement,GLenum usage=GL_STATIC_DRAW);
54
60 void setData(const GLuint data[], size_t elemCount);
61
74 void connectVertexAttrib(GLuint location, size_t elemCount,
75 size_t offset=0, GLuint divisor = 0) const;
76
78 void bind() const;
79
80private:
81 GLenum target;
82 GLuint bufferID;
83 size_t elemSize;
84 size_t stride;
85 GLenum type;
86};
void setData(const std::vector< GLfloat > &data, size_t valuesPerElement, GLenum usage=GL_STATIC_DRAW)
Upload interleaved float data and define element stride.
void connectVertexAttrib(GLuint location, size_t elemCount, size_t offset=0, GLuint divisor=0) const
Describe a vertex attribute array for the current buffer contents.
Definition GLBuffer.cpp:57
void bind() const
Bind the buffer to its target with glBindBuffer(target, id).
Definition GLBuffer.cpp:69
~GLBuffer()
Destroy and delete the GL buffer name.
Definition GLBuffer.cpp:17
GLBuffer(GLenum target)
Create a buffer object for the given OpenGL target.
Definition GLBuffer.cpp:7