From 3e277f8edf6a97ca863f99c9bc5a5251b0476333 Mon Sep 17 00:00:00 2001 From: Vlj Date: Wed, 13 Aug 2014 23:56:27 +0200 Subject: [PATCH] Dont alloc quaternion buffer if not flip --- src/graphics/gpuparticles.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/graphics/gpuparticles.cpp b/src/graphics/gpuparticles.cpp index 07d0e424a..169af5a73 100644 --- a/src/graphics/gpuparticles.cpp +++ b/src/graphics/gpuparticles.cpp @@ -407,10 +407,11 @@ void ParticleSystemProxy::generateVAOs() glBindVertexArray(non_current_simulation_vao); CommonSimulationVAO(tfb_buffers[1], initial_values_buffer); - float *quaternions = new float[4 * count]; + glBindVertexArray(0); if (flip) { + float *quaternions = new float[4 * count]; for (unsigned i = 0; i < count; i++) { core::vector3df rotationdir(0., 1., 0.); @@ -423,6 +424,7 @@ void ParticleSystemProxy::generateVAOs() glGenBuffers(1, &quaternionsbuffer); glBindBuffer(GL_ARRAY_BUFFER, quaternionsbuffer); glBufferData(GL_ARRAY_BUFFER, 4 * count * sizeof(float), quaternions, GL_STATIC_DRAW); + delete[] quaternions; } glBindVertexArray(current_rendering_vao); @@ -435,8 +437,6 @@ void ParticleSystemProxy::generateVAOs() if (flip) AppendQuaternionRenderingVAO(quaternionsbuffer); glBindVertexArray(0); - - delete[] quaternions; } void ParticleSystemProxy::render() {