<commit_before>#include "vboMesh.h"
#include "shaderProgram.h"
#include "renderState.h"
#include "extension.h"
#include "platform.h"

namespace Tangram {

int VboMesh::s_validGeneration = 0;

VboMesh::VboMesh() {
    m_drawMode = GL_TRIANGLES;
    m_hint = GL_STATIC_DRAW;
    m_keepMemoryData = false;
    m_glVertexBuffer = 0;
    m_glIndexBuffer = 0;
    m_nVertices = 0;
    m_nIndices = 0;
    m_dirtyOffset = 0;
    m_dirtySize = 0;

    m_dirty = false;
    m_isUploaded = false;
    m_isCompiled = false;

    m_generation = -1;
}

VboMesh::VboMesh(std::shared_ptr<VertexLayout> _vertexLayout, GLenum _drawMode, GLenum _hint, bool _keepMemoryData) : VboMesh() {
    m_vertexLayout = _vertexLayout;
    m_hint = _hint;
    m_keepMemoryData = _keepMemoryData;

    setDrawMode(_drawMode);
}

VboMesh::~VboMesh() {
    // Deleting a index/array buffer being used ends up setting up the current vertex/index buffer to 0
    // after the driver finishes using it, force the render state to be 0 for vertex/index buffer

    if (m_glVertexBuffer) {
        if (RenderState::vertexBuffer.compare(m_glVertexBuffer)) {
            RenderState::vertexBuffer.init(0, false);
        }
        glDeleteBuffers(1, &m_glVertexBuffer);
    }
    if (m_glIndexBuffer) {
        if (RenderState::indexBuffer.compare(m_glVertexBuffer)) {
            RenderState::indexBuffer.init(0, false);
        }
        glDeleteBuffers(1, &m_glIndexBuffer);
    }

    delete[] m_glVertexData;
    delete[] m_glIndexData;<commit_msg>unbind index buffer in mesh destructor<commit_after>#include "vboMesh.h"
#include "shaderProgram.h"
#include "renderState.h"
#include "extension.h"
#include "platform.h"

namespace Tangram {

int VboMesh::s_validGeneration = 0;

VboMesh::VboMesh() {
    m_drawMode = GL_TRIANGLES;
    m_hint = GL_STATIC_DRAW;
    m_keepMemoryData = false;
    m_glVertexBuffer = 0;
    m_glIndexBuffer = 0;
    m_nVertices = 0;
    m_nIndices = 0;
    m_dirtyOffset = 0;
    m_dirtySize = 0;

    m_dirty = false;
    m_isUploaded = false;
    m_isCompiled = false;

    m_generation = -1;
}

VboMesh::VboMesh(std::shared_ptr<VertexLayout> _vertexLayout, GLenum _drawMode, GLenum _hint, bool _keepMemoryData) : VboMesh() {
    m_vertexLayout = _vertexLayout;
    m_hint = _hint;
    m_keepMemoryData = _keepMemoryData;

    setDrawMode(_drawMode);
}

VboMesh::~VboMesh() {
    // Deleting a index/array buffer being used ends up setting up the current vertex/index buffer to 0
    // after the driver finishes using it, force the render state to be 0 for vertex/index buffer

    if (m_glVertexBuffer) {
        if (RenderState::vertexBuffer.compare(m_glVertexBuffer)) {
            RenderState::vertexBuffer.init(0, false);
        }
        glDeleteBuffers(1, &m_glVertexBuffer);
    }
    if (m_glIndexBuffer) {
        if (RenderState::indexBuffer.compare(m_glIndexBuffer)) {
            RenderState::indexBuffer.init(0, false);
        }
        glDeleteBuffers(1, &m_glIndexBuffer);
    }

    delete[] m_glVertexData;
    delete[] m_glIndexData;
{'fraction_non_alphanumeric': 0.10236220472440945, 'fraction_numerical': 0.009186351706036745, 'mean_word_length': 3.4060693641618496, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4191024', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1042, 'n_words': 226}