public void dispose() { lock.lock(); try { if (!disposed) { for (int i = 0; i < vertexBuffers.length; i++) { int id = vertexBuffers[i]; if (id != 0) { bufferPool.dispose(id); vertexBuffers[i] = 0; } id = idxBuffers[i]; if (id != 0) { bufferPool.dispose(id); idxBuffers[i] = 0; } } disposed = true; vertexElements = null; } } finally { lock.unlock(); } }
private void generateVBO(RenderType type) { VertexElements elements = vertexElements.get(type); int id = type.getIndex(); if (!disposed && elements.finalIndices.limit() > 0 && elements.finalVertices.limit() > 0) { vertexBuffers[id] = bufferPool.get("chunkMesh"); idxBuffers[id] = bufferPool.get("chunkMesh"); vertexCount[id] = elements.finalIndices.limit(); VertexBufferObjectUtil.bufferVboElementData( idxBuffers[id], elements.finalIndices, GL15.GL_STATIC_DRAW); VertexBufferObjectUtil.bufferVboData( vertexBuffers[id], elements.finalVertices, GL15.GL_STATIC_DRAW); } else { vertexBuffers[id] = 0; idxBuffers[id] = 0; vertexCount[id] = 0; } }