void MeshCommand::buildVAO() { // FIXME: Assumes that all the passes in the Material share the same Vertex Attribs GLProgramState* programState = (_material != nullptr) ? _material->_currentTechnique->_passes.at(0)->getGLProgramState() : _glProgramState; releaseVAO(); glGenVertexArrays(1, &_vao); GL::bindVAO(_vao); glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); auto flags = programState->getVertexAttribsFlags(); for (int i = 0; flags > 0; i++) { int flag = 1 << i; if (flag & flags) glEnableVertexAttribArray(i); flags &= ~flag; } programState->applyAttributes(false); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer); GL::bindVAO(0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); }
MeshCommand::~MeshCommand() { releaseVAO(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener); #endif }
bool OsmAnd::AtlasMapRendererDebugStage_OpenGL::releaseQuads3D() { const auto gpuAPI = getGPUAPI(); GL_CHECK_PRESENT(glDeleteBuffers); GL_CHECK_PRESENT(glDeleteProgram); if (_vaoQuad3D.isValid()) { gpuAPI->releaseVAO(_vaoQuad3D); _vaoQuad3D.reset(); } if (_iboQuad3D.isValid()) { glDeleteBuffers(1, &_iboQuad3D); GL_CHECK_RESULT; _iboQuad3D.reset(); } if (_vboQuad3D.isValid()) { glDeleteBuffers(1, &_vboQuad3D); GL_CHECK_RESULT; _vboQuad3D.reset(); } if (_programQuad3D.id.isValid()) { glDeleteProgram(_programQuad3D.id); GL_CHECK_RESULT; _programQuad3D = ProgramQuad3D(); } return true; }
//-------------------------------------------------------------- void ofVbo::clear(){ // clear all fixed function attributes clearVertices(); clearColors(); clearNormals(); clearTexCoords(); // we're not using any of these. bUsingVerts = false; bUsingColors = false; bUsingNormals = false; bUsingTexCoords = false; // clear all custom attributes. customAttributes.clear(); clearIndices(); if(vaoID!=0){ releaseVAO(vaoID); vaoID=0; } #if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS) unregisterVbo(this); #endif }
//-------------------------------------------------------------- void ofVbo::clear(){ clearVertices(); clearNormals(); clearColors(); clearTexCoords(); clearIndices(); if(supportVAOs && vaoID!=0){ releaseVAO(vaoID); vaoID=0; } bAllocated = false; #if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS) unregisterVbo(this); #endif }
bool OsmAnd::AtlasMapRendererDebugStage_OpenGL::releaseLines3D(const bool gpuContextLost) { const auto gpuAPI = getGPUAPI(); GL_CHECK_PRESENT(glDeleteBuffers); GL_CHECK_PRESENT(glDeleteProgram); if (_vaoLine3D.isValid()) { gpuAPI->releaseVAO(_vaoLine3D, gpuContextLost); _vaoLine3D.reset(); } if (_iboLine3D.isValid()) { if (!gpuContextLost) { glDeleteBuffers(1, &_iboLine3D); GL_CHECK_RESULT; } _iboLine3D.reset(); } if (_vboLine3D.isValid()) { if (!gpuContextLost) { glDeleteBuffers(1, &_vboLine3D); GL_CHECK_RESULT; } _vboLine3D.reset(); } if (_programLine3D.id.isValid()) { if (!gpuContextLost) { glDeleteProgram(_programLine3D.id); GL_CHECK_RESULT; } _programLine3D = ProgramLine3D(); } return true; }
void MeshCommand::buildVAO() { releaseVAO(); glGenVertexArrays(1, &_vao); GL::bindVAO(_vao); glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); auto flags = _glProgramState->getVertexAttribsFlags(); for (int i = 0; flags > 0; i++) { int flag = 1 << i; if (flag & flags) glEnableVertexAttribArray(i); flags &= ~flag; } _glProgramState->applyAttributes(false); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer); GL::bindVAO(0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); }
//-------------------------------------------------------------- void ofVbo::clear(){ // clear all fixed function attributes clearVertices(); clearColors(); clearNormals(); clearTexCoords(); // we're not using any of these. bUsingVerts = false; bUsingColors = false; bUsingNormals = false; bUsingTexCoords = false; // clear all custom attributes. customAttributes.clear(); clearIndices(); if(vaoID!=0){ releaseVAO(vaoID); vaoID=0; } }