bool initBuffer() { bool Validated(true); GLint MaxVertexAtomicCounterBuffers(0); GLint MaxControlAtomicCounterBuffers(0); GLint MaxEvaluationAtomicCounterBuffers(0); GLint MaxGeometryAtomicCounterBuffers(0); GLint MaxFragmentAtomicCounterBuffers(0); GLint MaxCombinedAtomicCounterBuffers(0); glGetIntegerv(GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS, &MaxVertexAtomicCounterBuffers); glGetIntegerv(GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS, &MaxControlAtomicCounterBuffers); glGetIntegerv(GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS, &MaxEvaluationAtomicCounterBuffers); glGetIntegerv(GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS, &MaxGeometryAtomicCounterBuffers); glGetIntegerv(GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, &MaxFragmentAtomicCounterBuffers); glGetIntegerv(GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS, &MaxCombinedAtomicCounterBuffers); glCreateBuffers(buffer::MAX, &BufferName[0]); glNamedBufferStorage(BufferName[buffer::VERTEX], VertexSize, VertexData, 0); glNamedBufferStorage(BufferName[buffer::ELEMENT], ElementSize, ElementData, 0); glNamedBufferStorage(BufferName[buffer::ATOMIC_COUNTER], sizeof(GLuint), nullptr, 0); glNamedBufferStorage(BufferName[buffer::TRANSFORM], sizeof(glm::mat4), nullptr, GL_MAP_WRITE_BIT); return Validated; }
bool initBuffer() { bool Validated(true); GLint MaxVertexAtomicCounterBuffers(0); GLint MaxControlAtomicCounterBuffers(0); GLint MaxEvaluationAtomicCounterBuffers(0); GLint MaxGeometryAtomicCounterBuffers(0); GLint MaxFragmentAtomicCounterBuffers(0); GLint MaxCombinedAtomicCounterBuffers(0); glGetIntegerv(GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS, &MaxVertexAtomicCounterBuffers); glGetIntegerv(GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS, &MaxControlAtomicCounterBuffers); glGetIntegerv(GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS, &MaxEvaluationAtomicCounterBuffers); glGetIntegerv(GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS, &MaxGeometryAtomicCounterBuffers); glGetIntegerv(GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, &MaxFragmentAtomicCounterBuffers); glGetIntegerv(GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS, &MaxCombinedAtomicCounterBuffers); glGenBuffers(buffer::MAX, BufferName); glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]); glBufferData(GL_UNIFORM_BUFFER, sizeof(glm::mat4), 0, GL_DYNAMIC_DRAW); glBindBuffer(GL_UNIFORM_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferName[buffer::ELEMENT]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, ElementSize, ElementData, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::VERTEX]); glBufferData(GL_ARRAY_BUFFER, VertexSize, VertexData, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, BufferName[buffer::ATOMIC_COUNTER]); glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint), NULL, GL_DYNAMIC_COPY); glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0); return Validated; }