//-------------------------------------------------------------- void ofVbo::setAttributeData(int location, const float * attrib0x, int numCoords, int total, int usage, int stride){ if(location==ofShader::POSITION_ATTRIBUTE){ #if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS) registerVbo(this); #endif if(ofIsGLProgrammableRenderer()){ totalVerts = total; #ifdef TARGET_OPENGLES glGenVertexArrays = (glGenVertexArraysType)dlsym(RTLD_DEFAULT, "glGenVertexArrays"); glDeleteVertexArrays = (glDeleteVertexArraysType)dlsym(RTLD_DEFAULT, "glDeleteVertexArrays"); glBindVertexArray = (glBindVertexArrayType)dlsym(RTLD_DEFAULT, "glBindVertexArrayArrays"); #endif } } bool normalize = false; if(!hasAttribute(location)){ vaoChanged = true; if (ofIsGLProgrammableRenderer()) { bUsingVerts |= (location == ofShader::POSITION_ATTRIBUTE); bUsingColors |= (location == ofShader::COLOR_ATTRIBUTE); bUsingNormals |= (location == ofShader::NORMAL_ATTRIBUTE); bUsingTexCoords |= (location == ofShader::TEXCOORD_ATTRIBUTE); } } getOrCreateAttr(location).setData(attrib0x,numCoords,total,usage,stride,normalize); }
//-------------------------------------------------------------- void ofVbo::setVertexData(const float * vert0x, int numCoords, int total, int usage, int stride) { #ifdef TARGET_OPENGLES if(!vaoChecked){ if(ofGetGLProgrammableRenderer()){ glGenVertexArrays = (glGenVertexArraysType)dlsym(RTLD_DEFAULT, "glGenVertexArrays"); glDeleteVertexArrays = (glDeleteVertexArraysType)dlsym(RTLD_DEFAULT, "glDeleteVertexArrays"); glBindVertexArray = (glBindVertexArrayType)dlsym(RTLD_DEFAULT, "glBindVertexArrayArrays"); }else{ glGenVertexArrays = (glGenVertexArraysType)dlsym(RTLD_DEFAULT, "glGenVertexArraysOES"); glDeleteVertexArrays = (glDeleteVertexArraysType)dlsym(RTLD_DEFAULT, "glDeleteVertexArraysOES"); glBindVertexArray = (glBindVertexArrayType)dlsym(RTLD_DEFAULT, "glBindVertexArrayArraysOES"); } vaoChecked = true; supportVAOs = glGenVertexArrays && glDeleteVertexArrays && glBindVertexArray; } #else if(!vaoChecked){ supportVAOs = ofGetGLProgrammableRenderer() || glewIsSupported("GL_ARB_vertex_array_object"); vaoChecked = true; } #endif if(vertId==0) { bAllocated = true; bUsingVerts = true; vaoChanged=true; glGenBuffers(1, &(vertId)); retain(vertId); #if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS) registerVbo(this); #endif } vertUsage = usage; vertSize = numCoords; vertStride = stride==0?3*sizeof(float):stride; totalVerts = total; glBindBuffer(GL_ARRAY_BUFFER, vertId); glBufferData(GL_ARRAY_BUFFER, total * stride, vert0x, usage); glBindBuffer(GL_ARRAY_BUFFER, 0); }