Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #2829 ofVbo custom attribute stride #2839

Merged
merged 1 commit into from Mar 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions libs/openFrameworks/gl/ofVbo.cpp
Expand Up @@ -424,9 +424,10 @@ void ofVbo::setAttributeData(int location, const float * attrib0x, int numCoords

attributeStrides[location] = stride;
attributeNumCoords[location] = numCoords;
attributeSize[location] = (stride == 0) ? numCoords * sizeof(float) : stride;

glBindBuffer(GL_ARRAY_BUFFER, attributeIds[location]);
glBufferData(GL_ARRAY_BUFFER, total * stride, attrib0x, usage);
glBufferData(GL_ARRAY_BUFFER, total * attributeSize[location], attrib0x, usage);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}

Expand Down Expand Up @@ -512,7 +513,7 @@ void ofVbo::updateIndexData(const ofIndexType * indices, int total) {
void ofVbo::updateAttributeData(int location, const float * attr0x, int total){
if(attributeIds.find(location)!=attributeIds.end() && attributeIds[location]!=0) {
glBindBuffer(GL_ARRAY_BUFFER, attributeIds[location]);
glBufferSubData(GL_ARRAY_BUFFER, 0, total*attributeStrides[location], attr0x);
glBufferSubData(GL_ARRAY_BUFFER, 0, total * attributeSize[location], attr0x);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
}
Expand Down
1 change: 1 addition & 0 deletions libs/openFrameworks/gl/ofVbo.h
Expand Up @@ -134,6 +134,7 @@ class ofVbo {
bool bBound;

map<int,GLuint> attributeIds;
map<int,int> attributeSize;
map<int,int> attributeStrides;
map<int,int> attributeNumCoords;

Expand Down