Make VertexAttributePointer store index instead of buffer pointer
This commit is contained in:
@@ -38,7 +38,7 @@ VertexAttributePointerList VAO::attributes(const VertexAttributePointerList& att
|
||||
_attrs = attrs_;
|
||||
bind();
|
||||
for (auto attr_ptr : attrs_) {
|
||||
attr_ptr.buffer->bind();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, attr_ptr.buffer);
|
||||
GLuint idx = attr_ptr.index;
|
||||
glVertexAttribPointer(
|
||||
idx,
|
||||
@@ -124,7 +124,7 @@ size_t VertexGroup::buffer(VertexBuffer<false>&& buf_) {
|
||||
GLuint idx = attrs.size();
|
||||
for (auto attr : buf_ptr->attributes) {
|
||||
attrs.emplace_back(
|
||||
VertexAttributePointer{attr, buf_ptr,idx}
|
||||
VertexAttributePointer{attr, buf_ptr->id(),idx}
|
||||
);
|
||||
idx++;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ size_t VertexGroup::buffers(std::vector<VertexBuffer<false>>&& bufs_) {
|
||||
for (auto buf : _vertex_data) {
|
||||
for (auto attr : buf->attributes) {
|
||||
attr_ptrs.emplace_back(
|
||||
VertexAttributePointer{attr, buf.get(), idx}
|
||||
VertexAttributePointer{attr, buf->id(), idx}
|
||||
);
|
||||
idx++;
|
||||
}
|
||||
@@ -197,10 +197,10 @@ void VertexGroup::disableAttr(GLuint idx) {
|
||||
}
|
||||
|
||||
void VertexGroup::disableBuffer(size_t idx) {
|
||||
auto buf_ptr = _vertex_data[idx].get();
|
||||
auto buf_idx = _vertex_data[idx]->id();
|
||||
bind();
|
||||
for (auto attr : _vao.attributes()) {
|
||||
if (attr.buffer == buf_ptr) {
|
||||
if (attr.buffer == buf_idx) {
|
||||
_vao.disable(attr.index);
|
||||
}
|
||||
}
|
||||
@@ -208,10 +208,10 @@ void VertexGroup::disableBuffer(size_t idx) {
|
||||
}
|
||||
|
||||
void VertexGroup::enableBuffer(size_t idx) {
|
||||
auto buf_ptr = _vertex_data[idx].get();
|
||||
auto buf_idx = _vertex_data[idx]->id();
|
||||
bind();
|
||||
for (auto attr : _vao.attributes()) {
|
||||
if (attr.buffer == buf_ptr) {
|
||||
if (attr.buffer == buf_idx) {
|
||||
_vao.enable(attr.index);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user