2 #ifndef KJY_OBJECT_ORIENTED_OPENGL_BUFFERS_HPP_ 3 #define KJY_OBJECT_ORIENTED_OPENGL_BUFFERS_HPP_ 4 #include "../OOOGL_Core.hpp" 5 #include "../Core_Utilities.hpp" 16 glGenBuffers(1, getIdPtr());
17 glBindBuffer(buffer_type, getNameDirect());
18 glBindBuffer(buffer_type, 0);
19 binding_purity = BINDINGS_UNCLEAN;
23 virtual void bind()
const {glBindBuffer(buffer_type, getNameDirect());};
24 virtual void unbind()
const {glBindBuffer(buffer_type, 0);};
26 virtual void bufferData(GLsizeiptr size,
const GLvoid* data, GLenum usage) {
27 glBindBuffer(buffer_type, getNameDirect());
28 CONDITIONALLY_CHECKED_GL_CALL(glBufferData(buffer_type, size, data, usage));
29 glBindBuffer(buffer_type, 0);
31 virtual void bufferSubData(GLintptr offset, GLsizeiptr size,
const GLvoid* data) {
32 glBindBuffer(buffer_type, getNameDirect());
33 CONDITIONALLY_CHECKED_GL_CALL(glBufferSubData(buffer_type, offset, size, data));
34 glBindBuffer(buffer_type, 0);
36 virtual void bufferStorage(GLsizeiptr size,
const GLvoid* data, GLbitfield flags) {
37 glBindBuffer(buffer_type, getNameDirect());
38 CONDITIONALLY_CHECKED_GL_CALL(glBufferStorage(buffer_type, size, data, flags));
39 glBindBuffer(buffer_type, 0);
41 virtual void clearBufferData(GLenum internal_format, GLenum format, GLenum type,
const void* data) {
42 glBindBuffer(buffer_type, getNameDirect());
43 CONDITIONALLY_CHECKED_GL_CALL(glClearBufferData(buffer_type, internal_format, format, type, data));
44 glBindBuffer(buffer_type, 0);
46 virtual void clearBufferSubData(GLenum internal_format, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type,
const void* data) {
47 glBindBuffer(buffer_type, getNameDirect());
48 CONDITIONALLY_CHECKED_GL_CALL(glClearBufferSubData(buffer_type, internal_format, offset, size, format, type, data));
49 glBindBuffer(buffer_type, 0);
51 virtual void invalidateBufferData() {
52 glBindBuffer(buffer_type, getNameDirect());
53 CONDITIONALLY_CHECKED_GL_CALL(glInvalidateBufferData(getNameDirect()));
54 glBindBuffer(buffer_type, 0);
56 virtual void invalidateBufferSubData(GLintptr offset, GLsizeiptr length) {
57 glBindBuffer(buffer_type, getNameDirect());
58 CONDITIONALLY_CHECKED_GL_CALL(glInvalidateBufferSubData(buffer_type, offset, length));
59 glBindBuffer(buffer_type, 0);
62 static void copy_buffer_subdata(
const OpenGlBuffer& read_buffer,
const OpenGlBuffer& write_buffer, GLintptr read_offset, GLintptr write_offset, GLsizei size){
66 inline GLenum getBufferType()
const {
return(buffer_type);}
69 static void _destroyBuffer(
const GLuint* name){
70 glDeleteBuffers(1, name);
72 GLenum buffer_type = GL_INVALID_ENUM;
81 virtual void bindBase(GLuint index) {
82 _is_index_bound_ =
true;
83 _bound_index_ = index;
84 CONDITIONALLY_CHECKED_GL_CALL(glBindBufferBase(getBufferType(), index, getNameDirect()));
86 virtual void bindBaseRange(GLuint index, GLintptr offset, GLsizeiptr size) {
87 _is_index_bound_ =
true;
88 _bound_index_ = index;
89 CONDITIONALLY_CHECKED_GL_CALL(glBindBufferRange(getBufferType(), index, getNameDirect(), offset, size));
91 virtual void unbindFromBase() {
92 if(_is_index_bound_) CONDITIONALLY_CHECKED_GL_CALL(glBindBufferBase(getBufferType(), _bound_index_, 0));
93 _is_index_bound_ =
false;
96 bool _is_index_bound_ =
false;
97 GLuint _bound_index_ = 0;
111 enum AttribPtrType {FLOATING, INTEGRAL, LONG_INTEGRAL};
112 AttribPtrType attrib_pointer_type = FLOATING;
114 GLenum type = GL_FLOAT;
115 GLboolean normalized = GL_FALSE;
117 const GLvoid* offset = (
const GLvoid*) 0;
Definition: Buffers.hpp:142
Definition: Buffers.hpp:138
Definition: Buffers.hpp:122
Definition: Buffers.hpp:13
Definition: OOOGL_Core.hpp:105
Definition: Buffers.hpp:158
Definition: Buffers.hpp:130
Definition: Buffers.hpp:146
Definition: Buffers.hpp:110
Definition: Buffers.hpp:134
Definition: Buffers.hpp:126
Definition: Buffers.hpp:162
Definition: Buffers.hpp:78
Definition: Core_Utilities.cpp:3
Definition: Buffers.hpp:106
Definition: Buffers.hpp:154
Definition: Buffers.hpp:150